linux_admin 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/linux_admin/common.rb +5 -12
- data/lib/linux_admin/disk.rb +82 -16
- data/lib/linux_admin/distro.rb +18 -7
- data/lib/linux_admin/exceptions.rb +1 -0
- data/lib/linux_admin/fstab.rb +9 -0
- data/lib/linux_admin/logical_volume.rb +65 -1
- data/lib/linux_admin/partition.rb +12 -4
- data/lib/linux_admin/physical_volume.rb +75 -0
- data/lib/linux_admin/{rhn.rb → registration_system/rhn.rb} +10 -8
- data/lib/linux_admin/registration_system/subscription_manager.rb +89 -0
- data/lib/linux_admin/registration_system.rb +45 -0
- data/lib/linux_admin/version.rb +1 -1
- data/lib/linux_admin/volume_group.rb +73 -0
- data/lib/linux_admin/yum.rb +1 -1
- data/lib/linux_admin.rb +6 -16
- data/linux_admin.gemspec +6 -2
- data/spec/common_spec.rb +39 -34
- data/spec/data/subscription_manager/output_orgs +6 -0
- data/spec/disk_spec.rb +117 -0
- data/spec/distro_spec.rb +1 -1
- data/spec/fstab_spec.rb +18 -0
- data/spec/linux_admin_spec.rb +0 -38
- data/spec/logical_volume_spec.rb +108 -0
- data/spec/partition_spec.rb +15 -0
- data/spec/physical_volume_spec.rb +110 -0
- data/spec/registration_system_spec.rb +60 -0
- data/spec/rhn_spec.rb +17 -21
- data/spec/spec_helper.rb +12 -0
- data/spec/subscription_manager_spec.rb +23 -18
- data/spec/volume_group_spec.rb +108 -0
- data/spec/yum_spec.rb +1 -1
- metadata +25 -5
- data/lib/linux_admin/subscription_manager.rb +0 -61
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LinuxAdmin::RegistrationSystem do
|
4
|
+
context ".registration_type" do
|
5
|
+
it "when registered Subscription Manager" do
|
6
|
+
stub_registered_to_system(:sm)
|
7
|
+
expect(described_class.registration_type).to eq(LinuxAdmin::SubscriptionManager)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "when registered RHN" do
|
11
|
+
stub_registered_to_system(:rhn)
|
12
|
+
expect(described_class.registration_type).to eq(LinuxAdmin::Rhn)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "when unregistered" do
|
16
|
+
stub_registered_to_system(nil)
|
17
|
+
expect(described_class.registration_type).to eq(described_class)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should memoize results" do
|
21
|
+
described_class.should_receive(:registration_type_uncached).once.and_call_original
|
22
|
+
described_class.registration_type
|
23
|
+
described_class.registration_type
|
24
|
+
end
|
25
|
+
|
26
|
+
it "with reload should refresh results" do
|
27
|
+
described_class.should_receive(:registration_type_uncached).twice.and_call_original
|
28
|
+
described_class.registration_type
|
29
|
+
described_class.registration_type(true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "#registered? when unregistered" do
|
34
|
+
stub_registered_to_system(nil)
|
35
|
+
expect(described_class.registered?).to be_false
|
36
|
+
end
|
37
|
+
|
38
|
+
context ".method_missing" do
|
39
|
+
before do
|
40
|
+
stub_registered_to_system(:rhn)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "exists on the subclass" do
|
44
|
+
expect(LinuxAdmin::RegistrationSystem.registered?).to be_true
|
45
|
+
end
|
46
|
+
|
47
|
+
it "does not exist on the subclass" do
|
48
|
+
expect { LinuxAdmin::RegistrationSystem.organizations }.to raise_error(NotImplementedError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "is an unknown method" do
|
52
|
+
expect { LinuxAdmin::RegistrationSystem.method_does_not_exist }.to be_true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def stub_registered_to_system(system)
|
57
|
+
LinuxAdmin::SubscriptionManager.any_instance.stub(:registered? => (system == :sm))
|
58
|
+
LinuxAdmin::Rhn.any_instance.stub(:registered? => data_file_path("rhn/systemid")) if system == :rhn
|
59
|
+
end
|
60
|
+
end
|
data/spec/rhn_spec.rb
CHANGED
@@ -1,35 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LinuxAdmin::Rhn do
|
4
|
-
|
5
|
-
expect(described_class.systemid_file).to be_kind_of(String)
|
6
|
-
end
|
7
|
-
|
8
|
-
context ".registered?" do
|
4
|
+
context "#registered?" do
|
9
5
|
it "with registered system_id" do
|
10
|
-
described_class.stub(:systemid_file => data_file_path("rhn/systemid"))
|
11
|
-
expect(described_class).to be_registered
|
6
|
+
described_class.any_instance.stub(:systemid_file => data_file_path("rhn/systemid"))
|
7
|
+
expect(described_class.new).to be_registered
|
12
8
|
end
|
13
9
|
|
14
10
|
it "with unregistered system_id" do
|
15
|
-
described_class.stub(:systemid_file => data_file_path("rhn/systemid.missing_system_id"))
|
16
|
-
expect(described_class).to_not be_registered
|
11
|
+
described_class.any_instance.stub(:systemid_file => data_file_path("rhn/systemid.missing_system_id"))
|
12
|
+
expect(described_class.new).to_not be_registered
|
17
13
|
end
|
18
14
|
|
19
15
|
it "with missing systemid file" do
|
20
|
-
described_class.stub(:systemid_file => data_file_path("rhn/systemid.missing_file"))
|
21
|
-
expect(described_class).to_not be_registered
|
16
|
+
described_class.any_instance.stub(:systemid_file => data_file_path("rhn/systemid.missing_file"))
|
17
|
+
expect(described_class.new).to_not be_registered
|
22
18
|
end
|
23
19
|
end
|
24
20
|
|
25
|
-
context "
|
21
|
+
context "#register" do
|
26
22
|
it "no username or activation key" do
|
27
|
-
expect { described_class.register({}) }.to raise_error(ArgumentError)
|
23
|
+
expect { described_class.new.register({}) }.to raise_error(ArgumentError)
|
28
24
|
end
|
29
25
|
|
30
26
|
it "with username and password" do
|
31
|
-
described_class.should_receive(:run).once.with("rhnreg_ks", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}}).and_return(0)
|
32
|
-
described_class.register(
|
27
|
+
described_class.any_instance.should_receive(:run).once.with("rhnreg_ks", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}}).and_return(0)
|
28
|
+
described_class.new.register(
|
33
29
|
:username => "SomeUser",
|
34
30
|
:password => "SomePass",
|
35
31
|
:proxy_address => "1.2.3.4",
|
@@ -40,8 +36,8 @@ describe LinuxAdmin::Rhn do
|
|
40
36
|
end
|
41
37
|
|
42
38
|
it "with activation key" do
|
43
|
-
described_class.should_receive(:run).once.with("rhnreg_ks", {:params=>{"--activationkey="=>"123abc", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}}).and_return(0)
|
44
|
-
described_class.register(
|
39
|
+
described_class.any_instance.should_receive(:run).once.with("rhnreg_ks", {:params=>{"--activationkey="=>"123abc", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}}).and_return(0)
|
40
|
+
described_class.new.register(
|
45
41
|
:activationkey => "123abc",
|
46
42
|
:proxy_address => "1.2.3.4",
|
47
43
|
:proxy_username => "ProxyUser",
|
@@ -51,14 +47,14 @@ describe LinuxAdmin::Rhn do
|
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
54
|
-
context "
|
50
|
+
context "#subscribe" do
|
55
51
|
it "without arguments" do
|
56
|
-
expect { described_class.subscribe({}) }.to raise_error(ArgumentError)
|
52
|
+
expect { described_class.new.subscribe({}) }.to raise_error(ArgumentError)
|
57
53
|
end
|
58
54
|
|
59
55
|
it "with pools" do
|
60
|
-
described_class.should_receive(:run).once.with("rhn-channel -a", {:params=>[["--user=", "SomeUser"], ["--password=", "SomePass"], ["--channel=", 123], ["--channel=", 456]]})
|
61
|
-
described_class.subscribe({
|
56
|
+
described_class.any_instance.should_receive(:run).once.with("rhn-channel -a", {:params=>[["--user=", "SomeUser"], ["--password=", "SomePass"], ["--channel=", 123], ["--channel=", 456]]})
|
57
|
+
described_class.new.subscribe({
|
62
58
|
:username => "SomeUser",
|
63
59
|
:password => "SomePass",
|
64
60
|
:pools => [123, 456]
|
data/spec/spec_helper.rb
CHANGED
@@ -18,6 +18,14 @@ RSpec.configure do |config|
|
|
18
18
|
# the seed, which is printed after each run.
|
19
19
|
# --seed 1234
|
20
20
|
config.order = 'random'
|
21
|
+
|
22
|
+
config.before do
|
23
|
+
Kernel.stub(:spawn).and_raise("Spawning is not permitted in specs. Please change your spec to use expectations/stubs.")
|
24
|
+
end
|
25
|
+
|
26
|
+
config.after do
|
27
|
+
clear_caches
|
28
|
+
end
|
21
29
|
end
|
22
30
|
|
23
31
|
def data_file_path(to)
|
@@ -28,6 +36,10 @@ def sample_output(to)
|
|
28
36
|
File.read(data_file_path(to))
|
29
37
|
end
|
30
38
|
|
39
|
+
def clear_caches
|
40
|
+
LinuxAdmin::RegistrationSystem.instance_variable_set(:@registration_type, nil)
|
41
|
+
end
|
42
|
+
|
31
43
|
class LinuxAdmin
|
32
44
|
module Distros
|
33
45
|
# simply alias test distro to redhat distro for time being
|
@@ -1,31 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LinuxAdmin::SubscriptionManager do
|
4
|
-
context "
|
4
|
+
context "#registered?" do
|
5
5
|
it "system with subscription-manager commands" do
|
6
|
-
described_class.should_receive(:run).once.with("subscription-manager identity", {:return_exitstatus=>true}).and_return(0)
|
7
|
-
expect(described_class.registered?).to be_true
|
6
|
+
described_class.any_instance.should_receive(:run).once.with("subscription-manager identity", {:return_exitstatus=>true}).and_return(0)
|
7
|
+
expect(described_class.new.registered?).to be_true
|
8
8
|
end
|
9
9
|
|
10
10
|
it "system without subscription-manager commands" do
|
11
|
-
described_class.should_receive(:run).once.with("subscription-manager identity", {:return_exitstatus=>true}).and_return(255)
|
12
|
-
expect(described_class.registered?).to be_false
|
11
|
+
described_class.any_instance.should_receive(:run).once.with("subscription-manager identity", {:return_exitstatus=>true}).and_return(255)
|
12
|
+
expect(described_class.new.registered?).to be_false
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
described_class.should_receive(:run).once.with("subscription-manager refresh").and_return(0)
|
18
|
-
described_class.refresh
|
16
|
+
it "#refresh" do
|
17
|
+
described_class.any_instance.should_receive(:run).once.with("subscription-manager refresh").and_return(0)
|
18
|
+
described_class.new.refresh
|
19
19
|
end
|
20
20
|
|
21
|
-
context "
|
21
|
+
context "#register" do
|
22
22
|
it "no username" do
|
23
|
-
expect { described_class.register }.to raise_error(ArgumentError)
|
23
|
+
expect { described_class.new.register }.to raise_error(ArgumentError)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "with username and password" do
|
27
|
-
described_class.should_receive(:run).once.with("subscription-manager register", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--org="=>"IT", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass", "--serverurl="=>"192.168.1.1"}}).and_return(0)
|
28
|
-
described_class.register(
|
27
|
+
described_class.any_instance.should_receive(:run).once.with("subscription-manager register", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--org="=>"IT", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass", "--serverurl="=>"192.168.1.1"}}).and_return(0)
|
28
|
+
described_class.new.register(
|
29
29
|
:username => "SomeUser",
|
30
30
|
:password => "SomePass",
|
31
31
|
:org => "IT",
|
@@ -37,14 +37,14 @@ describe LinuxAdmin::SubscriptionManager do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
41
|
-
described_class.should_receive(:run).once.with("subscription-manager attach", {:params=>[["--pool", 123], ["--pool", 456]]})
|
42
|
-
described_class.subscribe({:pools => [123, 456]})
|
40
|
+
it "#subscribe" do
|
41
|
+
described_class.any_instance.should_receive(:run).once.with("subscription-manager attach", {:params=>[["--pool", 123], ["--pool", 456]]})
|
42
|
+
described_class.new.subscribe({:pools => [123, 456]})
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
46
|
-
described_class.should_receive(:run).once.with("subscription-manager list --all --available", :return_output => true).and_return(sample_output("subscription_manager/output_list_all_available"))
|
47
|
-
expect(described_class.available_subscriptions).to eq({
|
45
|
+
it "#available_subscriptions" do
|
46
|
+
described_class.any_instance.should_receive(:run).once.with("subscription-manager list --all --available", :return_output => true).and_return(sample_output("subscription_manager/output_list_all_available"))
|
47
|
+
expect(described_class.new.available_subscriptions).to eq({
|
48
48
|
"82c042fca983889b10178893f29b06e3" => {
|
49
49
|
:subscription_name => "Example Subscription",
|
50
50
|
:sku => "SER0123",
|
@@ -91,4 +91,9 @@ describe LinuxAdmin::SubscriptionManager do
|
|
91
91
|
},
|
92
92
|
})
|
93
93
|
end
|
94
|
+
|
95
|
+
it "#organizations" do
|
96
|
+
described_class.any_instance.should_receive(:run).once.with("subscription-manager orgs", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass", "--serverurl="=>"192.168.1.1"}, :return_output => true}).and_return(sample_output("subscription_manager/output_orgs"))
|
97
|
+
expect(described_class.new.organizations({:username=>"SomeUser", :password=>"SomePass", :proxy_address=>"1.2.3.4", :proxy_username=>"ProxyUser", :proxy_password=>"ProxyPass", :server_url=>"192.168.1.1"})).to eq({"SomeOrg"=>{:name=>"SomeOrg", :key=>"1234567"}})
|
98
|
+
end
|
94
99
|
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LinuxAdmin::VolumeGroup do
|
4
|
+
before(:each) do
|
5
|
+
LinuxAdmin::Distro.stub(:local => LinuxAdmin::Distros::Test.new)
|
6
|
+
|
7
|
+
@groups = <<eos
|
8
|
+
vg_foobar:r/w:772:-1:0:2:2:-1:0:1:1:12058624:32768:368:368:0:tILZUF-IspH-H90I-pT5j-vVFl-b76L-zWx3CW
|
9
|
+
eos
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
# reset local copies of volumes / groups
|
14
|
+
LinuxAdmin::LogicalVolume.instance_variable_set(:@lvs, nil)
|
15
|
+
LinuxAdmin::PhysicalVolume.instance_variable_set(:@pvs, nil)
|
16
|
+
described_class.instance_variable_set(:@vgs, nil)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#attach_to" do
|
20
|
+
it "uses lvextend" do
|
21
|
+
lv = LinuxAdmin::LogicalVolume.new :name => 'lv'
|
22
|
+
vg = described_class.new :name => 'vg'
|
23
|
+
vg.should_receive(:run).
|
24
|
+
with(vg.cmd(:lvextend),
|
25
|
+
:params => ['lv', 'vg'])
|
26
|
+
vg.attach_to(lv)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns self" do
|
30
|
+
lv = LinuxAdmin::LogicalVolume.new :name => 'lv'
|
31
|
+
vg = described_class.new :name => 'vg'
|
32
|
+
vg.stub(:run)
|
33
|
+
vg.attach_to(lv).should == vg
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#extend_with" do
|
38
|
+
it "uses vgextend" do
|
39
|
+
vg = described_class.new :name => 'vg'
|
40
|
+
pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
41
|
+
vg.should_receive(:run).
|
42
|
+
with(vg.cmd(:vgextend),
|
43
|
+
:params => ['vg', '/dev/hda'])
|
44
|
+
vg.extend_with(pv)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "assigns volume group to physical volume" do
|
48
|
+
vg = described_class.new :name => 'vg'
|
49
|
+
pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
50
|
+
vg.stub(:run)
|
51
|
+
vg.extend_with(pv)
|
52
|
+
pv.volume_group.should == vg
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns self" do
|
56
|
+
vg = described_class.new :name => 'vg'
|
57
|
+
pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
58
|
+
vg.stub(:run)
|
59
|
+
vg.extend_with(pv).should == vg
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#create" do
|
64
|
+
before(:each) do
|
65
|
+
@pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
66
|
+
end
|
67
|
+
|
68
|
+
it "uses vgcreate" do
|
69
|
+
described_class.instance_variable_set(:@vgs, [])
|
70
|
+
described_class.should_receive(:run).
|
71
|
+
with(LinuxAdmin.cmd(:vgcreate),
|
72
|
+
:params => ['vg', '/dev/hda'])
|
73
|
+
described_class.create 'vg', @pv
|
74
|
+
end
|
75
|
+
|
76
|
+
it "returns new volume group" do
|
77
|
+
described_class.stub(:run => "")
|
78
|
+
vg = described_class.create 'vg', @pv
|
79
|
+
vg.should be_an_instance_of(described_class)
|
80
|
+
vg.name.should == 'vg'
|
81
|
+
end
|
82
|
+
|
83
|
+
it "adds volume group to local registry" do
|
84
|
+
described_class.stub(:run => "")
|
85
|
+
vg = described_class.create 'vg', @pv
|
86
|
+
described_class.scan.should include(vg)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#scan" do
|
91
|
+
it "uses vgdisplay" do
|
92
|
+
described_class.should_receive(:run).
|
93
|
+
with(LinuxAdmin.cmd(:vgdisplay),
|
94
|
+
:return_output => true,
|
95
|
+
:params => { '-c' => nil}).
|
96
|
+
and_return(@groups)
|
97
|
+
described_class.scan
|
98
|
+
end
|
99
|
+
|
100
|
+
it "returns local volume groups" do
|
101
|
+
described_class.should_receive(:run).and_return(@groups)
|
102
|
+
vgs = described_class.scan
|
103
|
+
|
104
|
+
vgs[0].should be_an_instance_of(described_class)
|
105
|
+
vgs[0].name.should == 'vg_foobar'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/spec/yum_spec.rb
CHANGED
@@ -107,7 +107,7 @@ describe LinuxAdmin::Yum do
|
|
107
107
|
|
108
108
|
context ".version_available" do
|
109
109
|
it "no packages" do
|
110
|
-
expect { described_class.version_available }.to raise_error
|
110
|
+
expect { described_class.version_available }.to raise_error(ArgumentError)
|
111
111
|
end
|
112
112
|
|
113
113
|
it "with packages" do
|
metadata
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brandon Dunne
|
9
|
+
- Jason Frey
|
10
|
+
- Mo Morsi
|
11
|
+
- Joe Rafaniello
|
9
12
|
autorequire:
|
10
13
|
bindir: bin
|
11
14
|
cert_chain: []
|
12
|
-
date: 2013-
|
15
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
13
16
|
dependencies:
|
14
17
|
- !ruby/object:Gem::Dependency
|
15
18
|
name: bundler
|
@@ -149,7 +152,10 @@ description: ! '
|
|
149
152
|
|
150
153
|
'
|
151
154
|
email:
|
152
|
-
-
|
155
|
+
- bdunne@redhat.com
|
156
|
+
- fryguy9@gmail.com
|
157
|
+
- mmorsi@redhat.com
|
158
|
+
- jrafanie@redhat.com
|
153
159
|
executables: []
|
154
160
|
extensions: []
|
155
161
|
extra_rdoc_files: []
|
@@ -165,15 +171,19 @@ files:
|
|
165
171
|
- lib/linux_admin/common.rb
|
166
172
|
- lib/linux_admin/disk.rb
|
167
173
|
- lib/linux_admin/distro.rb
|
174
|
+
- lib/linux_admin/exceptions.rb
|
168
175
|
- lib/linux_admin/fstab.rb
|
169
176
|
- lib/linux_admin/logical_volume.rb
|
170
177
|
- lib/linux_admin/partition.rb
|
171
|
-
- lib/linux_admin/
|
178
|
+
- lib/linux_admin/physical_volume.rb
|
179
|
+
- lib/linux_admin/registration_system.rb
|
180
|
+
- lib/linux_admin/registration_system/rhn.rb
|
181
|
+
- lib/linux_admin/registration_system/subscription_manager.rb
|
172
182
|
- lib/linux_admin/rpm.rb
|
173
183
|
- lib/linux_admin/service.rb
|
174
|
-
- lib/linux_admin/subscription_manager.rb
|
175
184
|
- lib/linux_admin/system.rb
|
176
185
|
- lib/linux_admin/version.rb
|
186
|
+
- lib/linux_admin/volume_group.rb
|
177
187
|
- lib/linux_admin/yum.rb
|
178
188
|
- linux_admin.gemspec
|
179
189
|
- spec/common_spec.rb
|
@@ -181,6 +191,7 @@ files:
|
|
181
191
|
- spec/data/rhn/systemid.missing_system_id
|
182
192
|
- spec/data/rpm/cmd_output_for_list_installed
|
183
193
|
- spec/data/subscription_manager/output_list_all_available
|
194
|
+
- spec/data/subscription_manager/output_orgs
|
184
195
|
- spec/data/yum/first.repo
|
185
196
|
- spec/data/yum/output_repoquery
|
186
197
|
- spec/data/yum/second.repo
|
@@ -188,13 +199,17 @@ files:
|
|
188
199
|
- spec/distro_spec.rb
|
189
200
|
- spec/fstab_spec.rb
|
190
201
|
- spec/linux_admin_spec.rb
|
202
|
+
- spec/logical_volume_spec.rb
|
191
203
|
- spec/partition_spec.rb
|
204
|
+
- spec/physical_volume_spec.rb
|
205
|
+
- spec/registration_system_spec.rb
|
192
206
|
- spec/rhn_spec.rb
|
193
207
|
- spec/rpm_spec.rb
|
194
208
|
- spec/service_spec.rb
|
195
209
|
- spec/spec_helper.rb
|
196
210
|
- spec/subscription_manager_spec.rb
|
197
211
|
- spec/system_spec.rb
|
212
|
+
- spec/volume_group_spec.rb
|
198
213
|
- spec/yum_spec.rb
|
199
214
|
homepage: http://github.com/ManageIQ/linux_admin
|
200
215
|
licenses:
|
@@ -227,6 +242,7 @@ test_files:
|
|
227
242
|
- spec/data/rhn/systemid.missing_system_id
|
228
243
|
- spec/data/rpm/cmd_output_for_list_installed
|
229
244
|
- spec/data/subscription_manager/output_list_all_available
|
245
|
+
- spec/data/subscription_manager/output_orgs
|
230
246
|
- spec/data/yum/first.repo
|
231
247
|
- spec/data/yum/output_repoquery
|
232
248
|
- spec/data/yum/second.repo
|
@@ -234,11 +250,15 @@ test_files:
|
|
234
250
|
- spec/distro_spec.rb
|
235
251
|
- spec/fstab_spec.rb
|
236
252
|
- spec/linux_admin_spec.rb
|
253
|
+
- spec/logical_volume_spec.rb
|
237
254
|
- spec/partition_spec.rb
|
255
|
+
- spec/physical_volume_spec.rb
|
256
|
+
- spec/registration_system_spec.rb
|
238
257
|
- spec/rhn_spec.rb
|
239
258
|
- spec/rpm_spec.rb
|
240
259
|
- spec/service_spec.rb
|
241
260
|
- spec/spec_helper.rb
|
242
261
|
- spec/subscription_manager_spec.rb
|
243
262
|
- spec/system_spec.rb
|
263
|
+
- spec/volume_group_spec.rb
|
244
264
|
- spec/yum_spec.rb
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
|
-
class LinuxAdmin
|
4
|
-
class SubscriptionManager < LinuxAdmin
|
5
|
-
def self.registered?
|
6
|
-
run("subscription-manager identity", :return_exitstatus => true) == 0
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.refresh
|
10
|
-
run("subscription-manager refresh")
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.register(options)
|
14
|
-
raise ArgumentError, "username and password are required" unless options[:username] && options[:password]
|
15
|
-
cmd = "subscription-manager register"
|
16
|
-
|
17
|
-
params = {"--username=" => options[:username], "--password=" => options[:password]}
|
18
|
-
params.merge!(proxy_params(options))
|
19
|
-
params["--org="] = options[:org] if options[:server_url] && options[:org]
|
20
|
-
params["--serverurl="] = options[:server_url] if options[:server_url]
|
21
|
-
|
22
|
-
run(cmd, :params => params)
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.subscribe(options)
|
26
|
-
cmd = "subscription-manager attach"
|
27
|
-
pools = options[:pools].collect {|pool| ["--pool", pool]}
|
28
|
-
params = proxy_params(options).to_a + pools
|
29
|
-
|
30
|
-
run(cmd, :params => params)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.available_subscriptions
|
34
|
-
out = run("subscription-manager list --all --available", :return_output => true)
|
35
|
-
|
36
|
-
out.split("\n\n").each_with_object({}) do |subscription, subscriptions_hash|
|
37
|
-
hash = {}
|
38
|
-
subscription.each_line do |line|
|
39
|
-
# Strip the header lines if they exist
|
40
|
-
next if (line.start_with?("+---") && line.end_with?("---+\n")) || line.strip == "Available Subscriptions"
|
41
|
-
|
42
|
-
key, value = line.split(":", 2)
|
43
|
-
hash[key.strip.downcase.tr(" -", "_").to_sym] = value.strip
|
44
|
-
end
|
45
|
-
hash[:ends] = Date.strptime(hash[:ends], "%m/%d/%Y")
|
46
|
-
|
47
|
-
subscriptions_hash[hash[:pool_id]] = hash
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def self.proxy_params(options)
|
54
|
-
config = {}
|
55
|
-
config["--proxy="] = options[:proxy_address] if options[:proxy_address]
|
56
|
-
config["--proxyuser="] = options[:proxy_username] if options[:proxy_username]
|
57
|
-
config["--proxypassword="] = options[:proxy_password] if options[:proxy_password]
|
58
|
-
config
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|