linux_admin 1.2.4 → 2.0.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 -8
- data/lib/linux_admin/disk.rb +12 -5
- data/lib/linux_admin/registration_system.rb +8 -4
- data/lib/linux_admin/scap.rb +1 -1
- data/lib/linux_admin/service/sys_v_init_service.rb +2 -1
- data/lib/linux_admin/service/systemd_service.rb +6 -2
- data/lib/linux_admin/version.rb +1 -1
- metadata +8 -100
- data/lib/linux_admin/registration_system/rhn.rb +0 -111
- data/spec/chrony_spec.rb +0 -64
- data/spec/common_spec.rb +0 -37
- data/spec/data/rhn/output_rhn-channel_list +0 -2
- data/spec/data/rhn/output_rhn-channel_list_available +0 -4
- data/spec/data/rhn/systemid +0 -57
- data/spec/data/rhn/systemid.missing_system_id +0 -57
- data/spec/data/rpm/cmd_output_for_list_installed +0 -20
- data/spec/data/subscription_manager/output_list_all_available +0 -42
- data/spec/data/subscription_manager/output_list_installed_not_subscribed +0 -19
- data/spec/data/subscription_manager/output_list_installed_subscribed +0 -19
- data/spec/data/subscription_manager/output_orgs +0 -6
- data/spec/data/subscription_manager/output_repos +0 -18
- data/spec/data/time_date/timedatectl_output +0 -14
- data/spec/data/yum/first.repo +0 -19
- data/spec/data/yum/output_repo_list +0 -13
- data/spec/data/yum/output_repoquery_multiple +0 -3
- data/spec/data/yum/output_repoquery_single +0 -1
- data/spec/data/yum/second.repo +0 -9
- data/spec/deb_spec.rb +0 -52
- data/spec/disk_spec.rb +0 -307
- data/spec/distro_spec.rb +0 -77
- data/spec/dns_spec.rb +0 -105
- data/spec/etc_issue_spec.rb +0 -37
- data/spec/fstab_spec.rb +0 -132
- data/spec/hardware_spec.rb +0 -46
- data/spec/hosts_spec.rb +0 -150
- data/spec/ip_address_spec.rb +0 -148
- data/spec/logical_volume_spec.rb +0 -166
- data/spec/mountable_spec.rb +0 -182
- data/spec/network_interface/network_interface_rh_spec.rb +0 -291
- data/spec/network_interface_spec.rb +0 -284
- data/spec/partition_spec.rb +0 -24
- data/spec/physical_volume_spec.rb +0 -101
- data/spec/registration_system_spec.rb +0 -85
- data/spec/rhn_spec.rb +0 -144
- data/spec/rpm_spec.rb +0 -85
- data/spec/scap_spec.rb +0 -48
- data/spec/service/sys_v_init_service_spec.rb +0 -127
- data/spec/service/systemd_service_spec.rb +0 -133
- data/spec/service_spec.rb +0 -54
- data/spec/spec_helper.rb +0 -116
- data/spec/ssh_spec.rb +0 -53
- data/spec/subscription_manager_spec.rb +0 -228
- data/spec/system_spec.rb +0 -15
- data/spec/time_date_spec.rb +0 -106
- data/spec/volume_group_spec.rb +0 -99
- data/spec/yum_spec.rb +0 -155
@@ -1,228 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::SubscriptionManager do
|
2
|
-
context "#run!" do
|
3
|
-
it "raises a CredentialError if the error message contained a credential error" do
|
4
|
-
result = AwesomeSpawn::CommandResult.new("stuff", "things", "invalid username or password", 1)
|
5
|
-
err = AwesomeSpawn::CommandResultError.new("things", result)
|
6
|
-
expect(LinuxAdmin::Common).to receive(:run!).and_raise(err)
|
7
|
-
|
8
|
-
expect { subject.run!("stuff") }.to raise_error(LinuxAdmin::CredentialError)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "raises a SubscriptionManagerError if the error message does not contain a credential error" do
|
12
|
-
result = AwesomeSpawn::CommandResult.new("stuff", "things", "not a credential error", 1)
|
13
|
-
err = AwesomeSpawn::CommandResultError.new("things", result)
|
14
|
-
expect(LinuxAdmin::Common).to receive(:run!).and_raise(err)
|
15
|
-
|
16
|
-
expect { subject.run!("stuff") }.to raise_error(LinuxAdmin::SubscriptionManagerError)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "#registered?" do
|
21
|
-
it "system with subscription-manager commands" do
|
22
|
-
expect(LinuxAdmin::Common).to receive(:run).once.with("subscription-manager identity")
|
23
|
-
.and_return(double(:exit_status => 0))
|
24
|
-
expect(described_class.new.registered?).to be_truthy
|
25
|
-
end
|
26
|
-
|
27
|
-
it "system without subscription-manager commands" do
|
28
|
-
expect(LinuxAdmin::Common).to receive(:run).once.with("subscription-manager identity")
|
29
|
-
.and_return(double(:exit_status => 255))
|
30
|
-
expect(described_class.new.registered?).to be_falsey
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "#refresh" do
|
35
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager refresh", {})
|
36
|
-
described_class.new.refresh
|
37
|
-
end
|
38
|
-
|
39
|
-
context "#register" do
|
40
|
-
it "no username" do
|
41
|
-
expect { described_class.new.register }.to raise_error(ArgumentError)
|
42
|
-
end
|
43
|
-
|
44
|
-
context "with username and password" do
|
45
|
-
let(:base_options) { {:username => "SomeUser@SomeDomain.org",
|
46
|
-
:password => "SomePass",
|
47
|
-
:environment => "Library",
|
48
|
-
:org => "IT",
|
49
|
-
:proxy_address => "1.2.3.4",
|
50
|
-
:proxy_username => "ProxyUser",
|
51
|
-
:proxy_password => "ProxyPass",
|
52
|
-
}
|
53
|
-
}
|
54
|
-
let(:run_params) { {:params=>{"--username="=>"SomeUser@SomeDomain.org", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass", "--environment="=>"Library"}} }
|
55
|
-
|
56
|
-
it "with server_url" do
|
57
|
-
run_params.store_path(:params, "--org=", "IT")
|
58
|
-
base_options.store_path(:server_url, "https://server.url")
|
59
|
-
|
60
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager register", run_params)
|
61
|
-
expect(LinuxAdmin::Rpm).to receive(:upgrade).with("http://server.url/pub/katello-ca-consumer-latest.noarch.rpm")
|
62
|
-
|
63
|
-
described_class.new.register(base_options)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "without server_url" do
|
67
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager register", run_params)
|
68
|
-
expect_any_instance_of(described_class).not_to receive(:install_server_certificate)
|
69
|
-
|
70
|
-
described_class.new.register(base_options)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "#subscribe" do
|
76
|
-
it "with pools" do
|
77
|
-
expect(LinuxAdmin::Common).to receive(:run!).once
|
78
|
-
.with("subscription-manager attach", :params => [["--pool", 123], ["--pool", 456]])
|
79
|
-
described_class.new.subscribe({:pools => [123, 456]})
|
80
|
-
end
|
81
|
-
|
82
|
-
it "without pools" do
|
83
|
-
expect(LinuxAdmin::Common).to receive(:run!).once
|
84
|
-
.with("subscription-manager attach", :params => {"--auto" => nil})
|
85
|
-
described_class.new.subscribe({})
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "#subscribed_products" do
|
90
|
-
it "subscribed" do
|
91
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager list --installed", {})
|
92
|
-
.and_return(double(:output => sample_output("subscription_manager/output_list_installed_subscribed")))
|
93
|
-
expect(described_class.new.subscribed_products).to eq(["69", "167"])
|
94
|
-
end
|
95
|
-
|
96
|
-
it "not subscribed" do
|
97
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager list --installed", {})
|
98
|
-
.and_return(double(:output => sample_output("subscription_manager/output_list_installed_not_subscribed")))
|
99
|
-
expect(described_class.new.subscribed_products).to eq(["167"])
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
it "#available_subscriptions" do
|
104
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager list --all --available", {})
|
105
|
-
.and_return(double(:output => sample_output("subscription_manager/output_list_all_available")))
|
106
|
-
expect(described_class.new.available_subscriptions).to eq({
|
107
|
-
"82c042fca983889b10178893f29b06e3" => {
|
108
|
-
:subscription_name => "Example Subscription",
|
109
|
-
:sku => "SER0123",
|
110
|
-
:pool_id => "82c042fca983889b10178893f29b06e3",
|
111
|
-
:quantity => "1690",
|
112
|
-
:service_level => "None",
|
113
|
-
:service_type => "None",
|
114
|
-
:multi_entitlement => "No",
|
115
|
-
:ends => Date.parse("2022-01-01"),
|
116
|
-
:system_type => "Physical",
|
117
|
-
},
|
118
|
-
"4f738052ec866192c775c62f408ab868" => {
|
119
|
-
:subscription_name => "My Private Subscription",
|
120
|
-
:sku => "SER9876",
|
121
|
-
:pool_id => "4f738052ec866192c775c62f408ab868",
|
122
|
-
:quantity => "Unlimited",
|
123
|
-
:service_level => "None",
|
124
|
-
:service_type => "None",
|
125
|
-
:multi_entitlement => "No",
|
126
|
-
:ends => Date.parse("2013-06-04"),
|
127
|
-
:system_type => "Virtual",
|
128
|
-
},
|
129
|
-
"3d81297f352305b9a3521981029d7d83" => {
|
130
|
-
:subscription_name => "Shared Subscription - With other characters, (2 sockets) (Up to 1 guest)",
|
131
|
-
:sku => "RH0123456",
|
132
|
-
:pool_id => "3d81297f352305b9a3521981029d7d83",
|
133
|
-
:quantity => "1",
|
134
|
-
:service_level => "Self-support",
|
135
|
-
:service_type => "L1-L3",
|
136
|
-
:multi_entitlement => "No",
|
137
|
-
:ends => Date.parse("2013-05-15"),
|
138
|
-
:system_type => "Virtual",
|
139
|
-
},
|
140
|
-
"87cefe63b67984d5c7e401d833d2f87f" => {
|
141
|
-
:subscription_name => "Example Subscription, Premium (up to 2 sockets) 3 year",
|
142
|
-
:sku => "MCT0123A9",
|
143
|
-
:pool_id => "87cefe63b67984d5c7e401d833d2f87f",
|
144
|
-
:quantity => "1",
|
145
|
-
:service_level => "Premium",
|
146
|
-
:service_type => "L1-L3",
|
147
|
-
:multi_entitlement => "No",
|
148
|
-
:ends => Date.parse("2013-07-05"),
|
149
|
-
:system_type => "Virtual",
|
150
|
-
},
|
151
|
-
})
|
152
|
-
end
|
153
|
-
|
154
|
-
context "#organizations" do
|
155
|
-
it "with valid credentials" do
|
156
|
-
run_options = ["subscription-manager orgs", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass"}}]
|
157
|
-
|
158
|
-
expect(LinuxAdmin::Rpm).to receive(:upgrade).with("http://192.168.1.1/pub/katello-ca-consumer-latest.noarch.rpm")
|
159
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with(*run_options)
|
160
|
-
.and_return(double(:output => sample_output("subscription_manager/output_orgs")))
|
161
|
-
|
162
|
-
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"}})
|
163
|
-
end
|
164
|
-
|
165
|
-
it "with invalid credentials" do
|
166
|
-
run_options = ["subscription-manager orgs", {:params=>{"--username="=>"BadUser", "--password="=>"BadPass"}}]
|
167
|
-
error = AwesomeSpawn::CommandResultError.new("",
|
168
|
-
double(
|
169
|
-
:error => "Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html",
|
170
|
-
:exit_status => 255
|
171
|
-
)
|
172
|
-
)
|
173
|
-
expect(AwesomeSpawn).to receive(:run!).once.with(*run_options).and_raise(error)
|
174
|
-
expect { described_class.new.organizations({:username=>"BadUser", :password=>"BadPass"}) }.to raise_error(LinuxAdmin::CredentialError)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
it "#enable_repo" do
|
179
|
-
expect(LinuxAdmin::Common).to receive(:run!).once
|
180
|
-
.with("subscription-manager repos", :params => {"--enable=" => "abc"})
|
181
|
-
|
182
|
-
described_class.new.enable_repo("abc")
|
183
|
-
end
|
184
|
-
|
185
|
-
it "#disable_repo" do
|
186
|
-
expect(LinuxAdmin::Common).to receive(:run!).once
|
187
|
-
.with("subscription-manager repos", :params => {"--disable=" => "abc"})
|
188
|
-
|
189
|
-
described_class.new.disable_repo("abc")
|
190
|
-
end
|
191
|
-
|
192
|
-
it "#all_repos" do
|
193
|
-
expected = [
|
194
|
-
{
|
195
|
-
:repo_id => "some-repo-source-rpms",
|
196
|
-
:repo_name => "Some Repo (Source RPMs)",
|
197
|
-
:repo_url => "https://my.host.example.com/repos/some-repo/source/rpms",
|
198
|
-
:enabled => true
|
199
|
-
},
|
200
|
-
{
|
201
|
-
:repo_id => "some-repo-rpms",
|
202
|
-
:repo_name => "Some Repo",
|
203
|
-
:repo_url => "https://my.host.example.com/repos/some-repo/rpms",
|
204
|
-
:enabled => true
|
205
|
-
},
|
206
|
-
{
|
207
|
-
:repo_id => "some-repo-2-beta-rpms",
|
208
|
-
:repo_name => "Some Repo (Beta RPMs)",
|
209
|
-
:repo_url => "https://my.host.example.com/repos/some-repo-2/beta/rpms",
|
210
|
-
:enabled => false
|
211
|
-
}
|
212
|
-
]
|
213
|
-
|
214
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager repos", {})
|
215
|
-
.and_return(double(:output => sample_output("subscription_manager/output_repos")))
|
216
|
-
|
217
|
-
expect(described_class.new.all_repos).to eq(expected)
|
218
|
-
end
|
219
|
-
|
220
|
-
it "#enabled_repos" do
|
221
|
-
expected = ["some-repo-source-rpms", "some-repo-rpms"]
|
222
|
-
|
223
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("subscription-manager repos", {})
|
224
|
-
.and_return(double(:output => sample_output("subscription_manager/output_repos")))
|
225
|
-
|
226
|
-
expect(described_class.new.enabled_repos).to eq(expected)
|
227
|
-
end
|
228
|
-
end
|
data/spec/system_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::System do
|
2
|
-
describe "#reboot!" do
|
3
|
-
it "reboots the system" do
|
4
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(LinuxAdmin::Common.cmd(:shutdown), :params => {'-r' => 'now'})
|
5
|
-
LinuxAdmin::System.reboot!
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "#shutdown!" do
|
10
|
-
it "shuts down the system" do
|
11
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(LinuxAdmin::Common.cmd(:shutdown), :params => {'-h' => '0'})
|
12
|
-
LinuxAdmin::System.shutdown!
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/spec/time_date_spec.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::TimeDate do
|
2
|
-
RUN_COMMAND = LinuxAdmin::Common.cmd("timedatectl")
|
3
|
-
|
4
|
-
def timedatectl_result
|
5
|
-
output = File.read(Pathname.new(data_file_path("time_date/timedatectl_output")))
|
6
|
-
AwesomeSpawn::CommandResult.new("", output, "", 0)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".system_timezone_detailed" do
|
10
|
-
it "returns the correct timezone" do
|
11
|
-
awesome_spawn_args = [
|
12
|
-
RUN_COMMAND,
|
13
|
-
:params => ["status"]
|
14
|
-
]
|
15
|
-
expect(AwesomeSpawn).to receive(:run).with(*awesome_spawn_args).and_return(timedatectl_result)
|
16
|
-
tz = described_class.system_timezone_detailed
|
17
|
-
expect(tz).to eq("America/New_York (EDT, -0400)")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe ".system_timezone" do
|
22
|
-
it "returns the correct timezone" do
|
23
|
-
awesome_spawn_args = [
|
24
|
-
RUN_COMMAND,
|
25
|
-
:params => ["status"]
|
26
|
-
]
|
27
|
-
expect(AwesomeSpawn).to receive(:run).with(*awesome_spawn_args).and_return(timedatectl_result)
|
28
|
-
tz = described_class.system_timezone
|
29
|
-
expect(tz).to eq("America/New_York")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe ".timezones" do
|
34
|
-
let(:timezones) do
|
35
|
-
<<-EOS
|
36
|
-
Africa/Bangui
|
37
|
-
Africa/Banjul
|
38
|
-
Africa/Bissau
|
39
|
-
Africa/Blantyre
|
40
|
-
Africa/Brazzaville
|
41
|
-
Africa/Bujumbura
|
42
|
-
Africa/Cairo
|
43
|
-
America/Havana
|
44
|
-
America/Hermosillo
|
45
|
-
America/Indiana/Indianapolis
|
46
|
-
America/Indiana/Knox
|
47
|
-
America/Argentina/San_Juan
|
48
|
-
America/Argentina/San_Luis
|
49
|
-
America/Argentina/Tucuman
|
50
|
-
America/Argentina/Ushuaia
|
51
|
-
EOS
|
52
|
-
end
|
53
|
-
|
54
|
-
it "returns the correct list" do
|
55
|
-
awesome_spawn_args = [
|
56
|
-
RUN_COMMAND,
|
57
|
-
:params => ["list-timezones"]
|
58
|
-
]
|
59
|
-
result = AwesomeSpawn::CommandResult.new("", timezones, "", 0)
|
60
|
-
expect(AwesomeSpawn).to receive(:run!).with(*awesome_spawn_args).and_return(result)
|
61
|
-
expect(described_class.timezones).to eq(timezones.split("\n"))
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe ".system_time=" do
|
66
|
-
it "sets the time" do
|
67
|
-
time = Time.new(2015, 1, 1, 1, 1, 1)
|
68
|
-
awesome_spawn_args = [
|
69
|
-
RUN_COMMAND,
|
70
|
-
:params => ["set-time", "2015-01-01 01:01:01", :adjust_system_clock]
|
71
|
-
]
|
72
|
-
expect(AwesomeSpawn).to receive(:run!).with(*awesome_spawn_args)
|
73
|
-
described_class.system_time = time
|
74
|
-
end
|
75
|
-
|
76
|
-
it "raises when the command fails" do
|
77
|
-
time = Time.new(2015, 1, 1, 1, 1, 1)
|
78
|
-
err = AwesomeSpawn::CommandResultError.new("message", nil)
|
79
|
-
allow(AwesomeSpawn).to receive(:run!).and_raise(err)
|
80
|
-
expect do
|
81
|
-
described_class.send(:system_time=, time)
|
82
|
-
end.to raise_error(described_class::TimeCommandError, "message")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe ".system_timezone=" do
|
87
|
-
it "sets the timezone" do
|
88
|
-
zone = "Location/City"
|
89
|
-
awesome_spawn_args = [
|
90
|
-
RUN_COMMAND,
|
91
|
-
:params => ["set-timezone", zone]
|
92
|
-
]
|
93
|
-
expect(AwesomeSpawn).to receive(:run!).with(*awesome_spawn_args)
|
94
|
-
described_class.system_timezone = zone
|
95
|
-
end
|
96
|
-
|
97
|
-
it "raises when the command fails" do
|
98
|
-
zone = "Location/City"
|
99
|
-
err = AwesomeSpawn::CommandResultError.new("message", nil)
|
100
|
-
allow(AwesomeSpawn).to receive(:run!).and_raise(err)
|
101
|
-
expect do
|
102
|
-
described_class.send(:system_timezone=, zone)
|
103
|
-
end.to raise_error(described_class::TimeCommandError, "message")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
data/spec/volume_group_spec.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::VolumeGroup do
|
2
|
-
before(:each) do
|
3
|
-
@groups = <<eos
|
4
|
-
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
|
5
|
-
eos
|
6
|
-
end
|
7
|
-
|
8
|
-
after(:each) do
|
9
|
-
# reset local copies of volumes / groups
|
10
|
-
LinuxAdmin::LogicalVolume.instance_variable_set(:@lvs, nil)
|
11
|
-
LinuxAdmin::PhysicalVolume.instance_variable_set(:@pvs, nil)
|
12
|
-
described_class.instance_variable_set(:@vgs, nil)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#attach_to" do
|
16
|
-
it "uses lvextend" do
|
17
|
-
vg = described_class.new :name => 'vg'
|
18
|
-
lv = LinuxAdmin::LogicalVolume.new :name => 'lv', :volume_group => vg
|
19
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
20
|
-
.with(LinuxAdmin::Common.cmd(:lvextend), :params => %w(lv vg))
|
21
|
-
vg.attach_to(lv)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "returns self" do
|
25
|
-
vg = described_class.new :name => 'vg'
|
26
|
-
lv = LinuxAdmin::LogicalVolume.new :name => 'lv', :volume_group => vg
|
27
|
-
allow(LinuxAdmin::Common).to receive(:run!)
|
28
|
-
expect(vg.attach_to(lv)).to eq(vg)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#extend_with" do
|
33
|
-
it "uses vgextend" do
|
34
|
-
vg = described_class.new :name => 'vg'
|
35
|
-
pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
36
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
37
|
-
.with(LinuxAdmin::Common.cmd(:vgextend), :params => ['vg', '/dev/hda'])
|
38
|
-
vg.extend_with(pv)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "assigns volume group to physical volume" do
|
42
|
-
vg = described_class.new :name => 'vg'
|
43
|
-
pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
44
|
-
allow(LinuxAdmin::Common).to receive(:run!)
|
45
|
-
vg.extend_with(pv)
|
46
|
-
expect(pv.volume_group).to eq(vg)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "returns self" do
|
50
|
-
vg = described_class.new :name => 'vg'
|
51
|
-
pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
52
|
-
allow(LinuxAdmin::Common).to receive(:run!)
|
53
|
-
expect(vg.extend_with(pv)).to eq(vg)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "#create" do
|
58
|
-
before(:each) do
|
59
|
-
@pv = LinuxAdmin::PhysicalVolume.new :device_name => '/dev/hda'
|
60
|
-
end
|
61
|
-
|
62
|
-
it "uses vgcreate" do
|
63
|
-
described_class.instance_variable_set(:@vgs, [])
|
64
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
65
|
-
.with(LinuxAdmin::Common.cmd(:vgcreate), :params => ['vg', '/dev/hda'])
|
66
|
-
described_class.create 'vg', @pv
|
67
|
-
end
|
68
|
-
|
69
|
-
it "returns new volume group" do
|
70
|
-
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
71
|
-
vg = described_class.create 'vg', @pv
|
72
|
-
expect(vg).to be_an_instance_of(described_class)
|
73
|
-
expect(vg.name).to eq('vg')
|
74
|
-
end
|
75
|
-
|
76
|
-
it "adds volume group to local registry" do
|
77
|
-
allow(LinuxAdmin::Common).to receive_messages(:run! => double(:output => ""))
|
78
|
-
vg = described_class.create 'vg', @pv
|
79
|
-
expect(described_class.scan).to include(vg)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "#scan" do
|
84
|
-
it "uses vgdisplay" do
|
85
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
86
|
-
.with(LinuxAdmin::Common.cmd(:vgdisplay), :params => {'-c' => nil})
|
87
|
-
.and_return(double(:output => @groups))
|
88
|
-
described_class.scan
|
89
|
-
end
|
90
|
-
|
91
|
-
it "returns local volume groups" do
|
92
|
-
expect(LinuxAdmin::Common).to receive(:run!).and_return(double(:output => @groups))
|
93
|
-
vgs = described_class.scan
|
94
|
-
|
95
|
-
expect(vgs[0]).to be_an_instance_of(described_class)
|
96
|
-
expect(vgs[0].name).to eq('vg_foobar')
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|