linux_admin 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/linux_admin.rb +0 -2
- data/lib/linux_admin/disk.rb +9 -5
- data/lib/linux_admin/logging.rb +3 -1
- data/lib/linux_admin/logical_volume.rb +6 -6
- data/lib/linux_admin/registration_system/subscription_manager.rb +2 -2
- data/lib/linux_admin/version.rb +1 -1
- data/lib/linux_admin/yum.rb +2 -2
- data/spec/disk_spec.rb +9 -9
- data/spec/logical_volume_spec.rb +7 -7
- metadata +11 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6162494c6bbe50d72eb1ba5f6102b51ad3fef53d
|
4
|
+
data.tar.gz: 4a33bb3aa96008c3ca5b21f70456215d368077ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b318a87324409d59dd08155db3bff3e4c076fc1ea289f21e8b449c3c670f1a96466d3d4d62003eeec33d8889c6b257080db0ceb64bfba2ed7c62f3a703235246
|
7
|
+
data.tar.gz: ac2029fe7890c370a2c30d2a5b46cfafb94bb5aa55838d9798632c870d20d42d3e2835ac25c3d9d4edef533bc65090447fe112fa983e8707f9348d777bd2e217
|
data/lib/linux_admin.rb
CHANGED
data/lib/linux_admin/disk.rb
CHANGED
@@ -13,23 +13,27 @@ module LinuxAdmin
|
|
13
13
|
def str_to_bytes(val, unit)
|
14
14
|
case unit
|
15
15
|
when 'K' then
|
16
|
-
val.to_f.kilobytes
|
16
|
+
val.to_f * 1_024 # 1.kilobytes
|
17
17
|
when 'M' then
|
18
|
-
val.to_f.
|
18
|
+
val.to_f * 1_048_576 # 1.megabyte
|
19
19
|
when 'G' then
|
20
|
-
val.to_f.gigabytes
|
20
|
+
val.to_f * 1_073_741_824 # 1.gigabytes
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def overlapping_ranges?(ranges)
|
25
25
|
ranges.find do |range1|
|
26
26
|
ranges.any? do |range2|
|
27
27
|
range1 != range2 &&
|
28
|
-
|
28
|
+
ranges_overlap?(range1, range2)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def ranges_overlap?(range1, range2) # copied from activesupport Range#overlaps?
|
34
|
+
range1.cover?(range2.first) || range2.cover?(range1.first)
|
35
|
+
end
|
36
|
+
|
33
37
|
def check_if_partitions_overlap(partitions)
|
34
38
|
ranges =
|
35
39
|
partitions.collect do |partition|
|
data/lib/linux_admin/logging.rb
CHANGED
@@ -57,12 +57,12 @@ module LinuxAdmin
|
|
57
57
|
private
|
58
58
|
|
59
59
|
def self.bytes_to_string(bytes)
|
60
|
-
if bytes > 1.gigabytes
|
61
|
-
(bytes /
|
62
|
-
elsif bytes > 1.megabytes
|
63
|
-
(bytes /
|
64
|
-
elsif bytes > 1.kilobytes
|
65
|
-
(bytes /
|
60
|
+
if bytes > 1_073_741_824 # 1.gigabytes
|
61
|
+
(bytes / 1_073_741_824).to_s + "G"
|
62
|
+
elsif bytes > 1_048_576 # 1.megabytes
|
63
|
+
(bytes / 1_048_576).to_s + "M"
|
64
|
+
elsif bytes > 1_024 # 1.kilobytes
|
65
|
+
(bytes / 1_024).to_s + "K"
|
66
66
|
else
|
67
67
|
bytes.to_s
|
68
68
|
end
|
@@ -34,7 +34,7 @@ module LinuxAdmin
|
|
34
34
|
params.merge!(proxy_params(options))
|
35
35
|
|
36
36
|
result = run!(cmd, :params => params)
|
37
|
-
parse_output(result.output).
|
37
|
+
parse_output(result.output).each_with_object({}) { |i, h| h[i[:name]] = i }
|
38
38
|
end
|
39
39
|
|
40
40
|
def register(options)
|
@@ -76,7 +76,7 @@ module LinuxAdmin
|
|
76
76
|
def available_subscriptions
|
77
77
|
cmd = "subscription-manager list --all --available"
|
78
78
|
output = run!(cmd).output
|
79
|
-
parse_output(output).
|
79
|
+
parse_output(output).each_with_object({}) { |i, h| h[i[:pool_id]] = i }
|
80
80
|
end
|
81
81
|
|
82
82
|
def enable_repo(repo, options = nil)
|
data/lib/linux_admin/version.rb
CHANGED
data/lib/linux_admin/yum.rb
CHANGED
@@ -5,7 +5,7 @@ module LinuxAdmin
|
|
5
5
|
class Yum
|
6
6
|
def self.create_repo(path, options = {})
|
7
7
|
raise ArgumentError, "path is required" unless path
|
8
|
-
options =
|
8
|
+
options = {:database => true, :unique_file_names => true}.merge(options)
|
9
9
|
|
10
10
|
FileUtils.mkdir_p(path)
|
11
11
|
|
@@ -20,7 +20,7 @@ module LinuxAdmin
|
|
20
20
|
def self.download_packages(path, packages, options = {})
|
21
21
|
raise ArgumentError, "path is required" unless path
|
22
22
|
raise ArgumentError, "packages are required" unless packages
|
23
|
-
options =
|
23
|
+
options = {:mirror_type => :package}.merge(options)
|
24
24
|
|
25
25
|
FileUtils.mkdir_p(path)
|
26
26
|
|
data/spec/disk_spec.rb
CHANGED
@@ -74,23 +74,23 @@ eos
|
|
74
74
|
|
75
75
|
expect(disk.partitions[0].id).to eq(1)
|
76
76
|
expect(disk.partitions[0].disk).to eq(disk)
|
77
|
-
expect(disk.partitions[0].size).to eq(80.5.gigabytes
|
78
|
-
expect(disk.partitions[0].start_sector).to eq(1259.megabytes
|
79
|
-
expect(disk.partitions[0].end_sector).to eq(81.8.gigabytes
|
77
|
+
expect(disk.partitions[0].size).to eq(86_436_216_832.0) # 80.5.gigabytes
|
78
|
+
expect(disk.partitions[0].start_sector).to eq(1_320_157_184) # 1259.megabytes
|
79
|
+
expect(disk.partitions[0].end_sector).to eq(87_832_081_203.2) # 81.8.gigabytes
|
80
80
|
expect(disk.partitions[0].partition_type).to eq('primary')
|
81
81
|
expect(disk.partitions[0].fs_type).to eq('ntfs')
|
82
82
|
expect(disk.partitions[1].id).to eq(2)
|
83
83
|
expect(disk.partitions[1].disk).to eq(disk)
|
84
|
-
expect(disk.partitions[1].size).to eq(80.5.gigabytes
|
85
|
-
expect(disk.partitions[1].start_sector).to eq(81.8.gigabytes
|
86
|
-
expect(disk.partitions[1].end_sector).to eq(162.gigabytes
|
84
|
+
expect(disk.partitions[1].size).to eq(86_436_216_832.0) # 80.5.gigabytes
|
85
|
+
expect(disk.partitions[1].start_sector).to eq(87_832_081_203.2) # 81.8.gigabytes
|
86
|
+
expect(disk.partitions[1].end_sector).to eq(173_946_175_488) # 162.gigabytes
|
87
87
|
expect(disk.partitions[1].partition_type).to eq('primary')
|
88
88
|
expect(disk.partitions[1].fs_type).to eq('ext4')
|
89
89
|
expect(disk.partitions[2].id).to eq(3)
|
90
90
|
expect(disk.partitions[2].disk).to eq(disk)
|
91
|
-
expect(disk.partitions[2].size).to eq(1074.megabytes
|
92
|
-
expect(disk.partitions[2].start_sector).to eq(162.gigabytes
|
93
|
-
expect(disk.partitions[2].end_sector).to eq(163.gigabytes
|
91
|
+
expect(disk.partitions[2].size).to eq(1_126_170_624) # 1074.megabytes
|
92
|
+
expect(disk.partitions[2].start_sector).to eq(173_946_175_488) # 162.gigabytes
|
93
|
+
expect(disk.partitions[2].end_sector).to eq(175_019_917_312) # 163.gigabytes
|
94
94
|
expect(disk.partitions[2].partition_type).to eq('logical')
|
95
95
|
expect(disk.partitions[2].fs_type).to eq('linux-swap(v1)')
|
96
96
|
end
|
data/spec/logical_volume_spec.rb
CHANGED
@@ -55,7 +55,7 @@ eos
|
|
55
55
|
:params => {'-n' => 'lv',
|
56
56
|
nil => 'vg',
|
57
57
|
'-L' => '256G'})
|
58
|
-
described_class.create 'lv', @vg, 256.gigabytes
|
58
|
+
described_class.create 'lv', @vg, 274_877_906_944 # 256.gigabytes
|
59
59
|
end
|
60
60
|
|
61
61
|
context "size is specified" do
|
@@ -66,7 +66,7 @@ eos
|
|
66
66
|
:params => {'-n' => 'lv',
|
67
67
|
nil => 'vg',
|
68
68
|
'-L' => '256G'})
|
69
|
-
described_class.create 'lv', @vg, 256.gigabytes
|
69
|
+
described_class.create 'lv', @vg, 274_877_906_944 # 256.gigabytes
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -85,7 +85,7 @@ eos
|
|
85
85
|
it "returns new logical volume" do
|
86
86
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
87
87
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
88
|
-
lv = described_class.create 'lv', @vg, 256.gigabytes
|
88
|
+
lv = described_class.create 'lv', @vg, 274_877_906_944 # 256.gigabytes
|
89
89
|
expect(lv).to be_an_instance_of(described_class)
|
90
90
|
expect(lv.name).to eq('lv')
|
91
91
|
end
|
@@ -94,7 +94,7 @@ eos
|
|
94
94
|
it "sets path under volume group" do
|
95
95
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
96
96
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
97
|
-
lv = described_class.create 'lv', @vg, 256.gigabytes
|
97
|
+
lv = described_class.create 'lv', @vg, 274_877_906_944 # 256.gigabytes
|
98
98
|
expect(lv.path.to_s).to eq("#{described_class::DEVICE_PATH}#{@vg.name}/lv")
|
99
99
|
end
|
100
100
|
end
|
@@ -103,7 +103,7 @@ eos
|
|
103
103
|
it "sets name" do
|
104
104
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
105
105
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
106
|
-
lv = described_class.create '/dev/lv', @vg, 256.gigabytes
|
106
|
+
lv = described_class.create '/dev/lv', @vg, 274_877_906_944 # 256.gigabytes
|
107
107
|
expect(lv.name).to eq("lv")
|
108
108
|
end
|
109
109
|
end
|
@@ -113,7 +113,7 @@ eos
|
|
113
113
|
require 'pathname'
|
114
114
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
115
115
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
116
|
-
lv = described_class.create Pathname.new("/dev/#{@vg.name}/lv"), @vg, 256.gigabytes
|
116
|
+
lv = described_class.create Pathname.new("/dev/#{@vg.name}/lv"), @vg, 274_877_906_944 # 256.gigabytes
|
117
117
|
expect(lv.name).to eq("lv")
|
118
118
|
expect(lv.path).to eq("/dev/vg/lv")
|
119
119
|
end
|
@@ -122,7 +122,7 @@ eos
|
|
122
122
|
it "adds logical volume to local registry" do
|
123
123
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
124
124
|
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
125
|
-
lv = described_class.create 'lv', @vg, 256.gigabytes
|
125
|
+
lv = described_class.create 'lv', @vg, 274_877_906_944 # 256.gigabytes
|
126
126
|
expect(described_class.scan).to include(lv)
|
127
127
|
end
|
128
128
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Dunne
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date: 2016-
|
19
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: bundler
|
@@ -89,19 +89,19 @@ dependencies:
|
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
92
|
+
name: awesome_spawn
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "
|
95
|
+
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '3
|
97
|
+
version: '1.3'
|
98
98
|
type: :runtime
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - "
|
102
|
+
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '3
|
104
|
+
version: '1.3'
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: inifile
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,28 +122,14 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
126
|
-
type: :runtime
|
127
|
-
prerelease: false
|
128
|
-
version_requirements: !ruby/object:Gem::Requirement
|
129
|
-
requirements:
|
130
|
-
- - "~>"
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: '2.0'
|
133
|
-
- !ruby/object:Gem::Dependency
|
134
|
-
name: awesome_spawn
|
135
|
-
requirement: !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
- - "~>"
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: '1.3'
|
125
|
+
version: '3.0'
|
140
126
|
type: :runtime
|
141
127
|
prerelease: false
|
142
128
|
version_requirements: !ruby/object:Gem::Requirement
|
143
129
|
requirements:
|
144
130
|
- - "~>"
|
145
131
|
- !ruby/object:Gem::Version
|
146
|
-
version: '
|
132
|
+
version: '3.0'
|
147
133
|
- !ruby/object:Gem::Dependency
|
148
134
|
name: nokogiri
|
149
135
|
requirement: !ruby/object:Gem::Requirement
|
@@ -292,7 +278,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
292
278
|
requirements:
|
293
279
|
- - ">="
|
294
280
|
- !ruby/object:Gem::Version
|
295
|
-
version:
|
281
|
+
version: 2.0.0
|
296
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
297
283
|
requirements:
|
298
284
|
- - ">="
|
@@ -300,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
286
|
version: '0'
|
301
287
|
requirements: []
|
302
288
|
rubyforge_project:
|
303
|
-
rubygems_version: 2.
|
289
|
+
rubygems_version: 2.6.3
|
304
290
|
signing_key:
|
305
291
|
specification_version: 4
|
306
292
|
summary: LinuxAdmin is a module to simplify management of linux systems.
|