linux_admin 1.2.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/linux_admin.rb +0 -8
- data/lib/linux_admin/chrony.rb +1 -0
- data/lib/linux_admin/disk.rb +31 -7
- data/lib/linux_admin/fstab.rb +29 -14
- data/lib/linux_admin/partition.rb +1 -1
- 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 +36 -120
- 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 -244
- 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 -66
- 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,18 +0,0 @@
|
|
1
|
-
+----------------------------------------------------------+
|
2
|
-
Available Repositories in /etc/yum.repos.d/redhat.repo
|
3
|
-
+----------------------------------------------------------+
|
4
|
-
Repo ID: some-repo-source-rpms
|
5
|
-
Repo Name: Some Repo (Source RPMs)
|
6
|
-
Repo URL: https://my.host.example.com/repos/some-repo/source/rpms
|
7
|
-
Enabled: 1
|
8
|
-
|
9
|
-
Repo ID: some-repo-rpms
|
10
|
-
Repo Name: Some Repo
|
11
|
-
Repo URL: https://my.host.example.com/repos/some-repo/rpms
|
12
|
-
Enabled: 1
|
13
|
-
|
14
|
-
Repo ID: some-repo-2-beta-rpms
|
15
|
-
Repo Name: Some Repo (Beta RPMs)
|
16
|
-
Repo URL: https://my.host.example.com/repos/some-repo-2/beta/rpms
|
17
|
-
Enabled: 0
|
18
|
-
|
@@ -1,14 +0,0 @@
|
|
1
|
-
Local time: Thu 2015-09-24 17:54:02 EDT
|
2
|
-
Universal time: Thu 2015-09-24 21:54:02 UTC
|
3
|
-
RTC time: Thu 2015-09-24 21:54:02
|
4
|
-
Time zone: America/New_York (EDT, -0400)
|
5
|
-
NTP enabled: yes
|
6
|
-
NTP synchronized: yes
|
7
|
-
RTC in local TZ: no
|
8
|
-
DST active: yes
|
9
|
-
Last DST change: DST began at
|
10
|
-
Sun 2015-03-08 01:59:59 EST
|
11
|
-
Sun 2015-03-08 03:00:00 EDT
|
12
|
-
Next DST change: DST ends (the clock jumps one hour backwards) at
|
13
|
-
Sun 2015-11-01 01:59:59 EDT
|
14
|
-
Sun 2015-11-01 01:00:00 EST
|
data/spec/data/yum/first.repo
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
[my-local-repo-a]
|
2
|
-
name = My Local Repo A
|
3
|
-
baseurl = https://mirror.example.com/a/content/os_ver
|
4
|
-
enabled = 0
|
5
|
-
gpgcheck = 1
|
6
|
-
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-my-local-server
|
7
|
-
sslverify = 1
|
8
|
-
sslcacert = /etc/rhsm/ca/my-loacl-server.pem
|
9
|
-
sslclientkey = /etc/pki/entitlement/0123456789012345678-key.pem
|
10
|
-
sslclientcert = /etc/pki/entitlement/0123456789012345678.pem
|
11
|
-
metadata_expire = 86400
|
12
|
-
|
13
|
-
[my-local-repo-b]
|
14
|
-
name = My Local Repo B
|
15
|
-
baseurl = https://mirror.example.com/b/content/os_ver
|
16
|
-
enabled = 1
|
17
|
-
gpgcheck = 0
|
18
|
-
sslverify = 0
|
19
|
-
metadata_expire = 86400
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Loaded plugins: product-id, rhnplugin, security, subscription-manager
|
2
|
-
This system is receiving updates from Red Hat Subscription Management.
|
3
|
-
This system is not registered with RHN Classic or RHN Satellite.
|
4
|
-
You can use rhn_register to register.
|
5
|
-
RHN Satellite or RHN Classic support will be disabled.
|
6
|
-
rhel-6-server-rpms | 3.7 kB 00:00
|
7
|
-
rhel-ha-for-rhel-6-server-rpms | 3.7 kB 00:00
|
8
|
-
rhel-lb-for-rhel-6-server-rpms | 3.7 kB 00:00
|
9
|
-
repo id repo name status
|
10
|
-
rhel-6-server-rpms Red Hat Enterprise Linux 6 Server (RPMs) 11,016
|
11
|
-
rhel-ha-for-rhel-6-server-rpms Red Hat Enterprise Linux High Availability (for RHEL 6 Server) (RPMs) 269
|
12
|
-
rhel-lb-for-rhel-6-server-rpms Red Hat Enterprise Linux Load Balancer (for RHEL 6 Server) (RPMs) 0
|
13
|
-
repolist: 11,909
|
@@ -1 +0,0 @@
|
|
1
|
-
subscription-manager 1.1.23.1
|
data/spec/data/yum/second.repo
DELETED
data/spec/deb_spec.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::Deb do
|
2
|
-
describe "#info" do
|
3
|
-
it "returns package metadata" do
|
4
|
-
# as output w/ apt-cache show ruby on ubuntu 13.04
|
5
|
-
data = <<EOS
|
6
|
-
Package: ruby
|
7
|
-
Priority: optional
|
8
|
-
Section: interpreters
|
9
|
-
Installed-Size: 31
|
10
|
-
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
11
|
-
Original-Maintainer: akira yamada <akira@debian.org>
|
12
|
-
Architecture: all
|
13
|
-
Source: ruby-defaults
|
14
|
-
Version: 4.9
|
15
|
-
Replaces: irb, rdoc
|
16
|
-
Provides: irb, rdoc
|
17
|
-
Depends: ruby1.9.1 (>= 1.9.3.194-1)
|
18
|
-
Suggests: ri, ruby-dev
|
19
|
-
Conflicts: irb, rdoc
|
20
|
-
Filename: pool/main/r/ruby-defaults/ruby_4.9_all.deb
|
21
|
-
Size: 4896
|
22
|
-
MD5sum: b1991f2e0eafb04f5930ed242cfe1476
|
23
|
-
SHA1: a7c55fbb83dd8382631ea771b5555d989351f840
|
24
|
-
SHA256: 84d042e0273bd2f0082dd9e7dda0246267791fd09607041a35485bfff92f38d9
|
25
|
-
Description-en: Interpreter of object-oriented scripting language Ruby (default version)
|
26
|
-
Ruby is the interpreted scripting language for quick and easy
|
27
|
-
object-oriented programming. It has many features to process text
|
28
|
-
files and to do system management tasks (as in perl). It is simple,
|
29
|
-
straight-forward, and extensible.
|
30
|
-
.
|
31
|
-
This package is a dependency package, which depends on Debian's default Ruby
|
32
|
-
version (currently v1.9.3).
|
33
|
-
Homepage: http://www.ruby-lang.org/
|
34
|
-
Description-md5: da2991b37e3991230d79ba70f9c01682
|
35
|
-
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
|
36
|
-
Origin: Ubuntu
|
37
|
-
Supported: 9m
|
38
|
-
Task: kubuntu-desktop, kubuntu-full, kubuntu-active, kubuntu-active-desktop, kubuntu-active-full, kubuntu-active, edubuntu-desktop-gnome, ubuntustudio-font-meta
|
39
|
-
EOS
|
40
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
41
|
-
.with(described_class::APT_CACHE_CMD, :params => %w(show ruby))
|
42
|
-
.and_return(double(:output => data))
|
43
|
-
metadata = described_class.info("ruby")
|
44
|
-
expect(metadata['package']).to eq('ruby')
|
45
|
-
expect(metadata['priority']).to eq('optional')
|
46
|
-
expect(metadata['section']).to eq('interpreters')
|
47
|
-
expect(metadata['architecture']).to eq('all')
|
48
|
-
expect(metadata['version']).to eq('4.9')
|
49
|
-
expect(metadata['origin']).to eq('Ubuntu')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/spec/disk_spec.rb
DELETED
@@ -1,244 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::Disk do
|
2
|
-
describe "#local" do
|
3
|
-
it "returns local disks" do
|
4
|
-
expect(Dir).to receive(:glob).with(['/dev/[vhs]d[a-z]', '/dev/xvd[a-z]']).
|
5
|
-
and_return(['/dev/hda', '/dev/sda'])
|
6
|
-
disks = LinuxAdmin::Disk.local
|
7
|
-
paths = disks.collect { |disk| disk.path }
|
8
|
-
expect(paths).to include('/dev/hda')
|
9
|
-
expect(paths).to include('/dev/sda')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#size" do
|
14
|
-
it "uses fdisk" do
|
15
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
16
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
17
|
-
.with(LinuxAdmin::Common.cmd(:fdisk),
|
18
|
-
:params => {"-l" => nil})
|
19
|
-
.and_return(double(:output => ""))
|
20
|
-
disk.size
|
21
|
-
end
|
22
|
-
|
23
|
-
it "returns disk size" do
|
24
|
-
fdisk = <<eos
|
25
|
-
Disk /dev/hda: 500.1 GB, 500107862016 bytes
|
26
|
-
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
|
27
|
-
Units = sectors of 1 * 512 = 512 bytes
|
28
|
-
Sector size (logical/physical): 512 bytes / 512 bytes
|
29
|
-
I/O size (minimum/optimal): 512 bytes / 512 bytes
|
30
|
-
Disk identifier: 0x3ddb508b
|
31
|
-
|
32
|
-
Device Boot Start End Blocks Id System
|
33
|
-
1 1259MB 81.8GB 80.5GB primary ntfs
|
34
|
-
2 81.8GB 162GB 80.5GB primary ext4
|
35
|
-
3 162GB 163GB 1074MB logical linux-swap(v1)
|
36
|
-
eos
|
37
|
-
|
38
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
39
|
-
allow(LinuxAdmin::Common).to receive(:run!).and_return(double(:output => fdisk))
|
40
|
-
expect(disk.size).to eq(500_107_862_016)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#partitions" do
|
45
|
-
it "uses parted" do
|
46
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
47
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
48
|
-
.with(LinuxAdmin::Common.cmd(:parted),
|
49
|
-
:params => {nil => %w(--script /dev/hda print)}).and_return(double(:output => ""))
|
50
|
-
disk.partitions
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns [] on non-zero parted rc" do
|
54
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
55
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:output => "", :exit_status => 1))
|
56
|
-
expect(disk.partitions).to eq([])
|
57
|
-
end
|
58
|
-
|
59
|
-
it "sets partitons" do
|
60
|
-
partitions = <<eos
|
61
|
-
Model: ATA TOSHIBA MK5061GS (scsi)
|
62
|
-
Disk /dev/sda: 500GB
|
63
|
-
Sector size (logical/physical): 512B/512B
|
64
|
-
Partition Table: msdos
|
65
|
-
Disk Flags:
|
66
|
-
|
67
|
-
Number Start End Size Type File system Flags
|
68
|
-
1 1259MB 81.8GB 80.5GB primary ntfs
|
69
|
-
2 81.8GB 162GB 80.5GB primary ext4
|
70
|
-
3 162GB 163GB 1074MB logical linux-swap(v1)
|
71
|
-
eos
|
72
|
-
disk = LinuxAdmin::Disk.new
|
73
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:output => partitions))
|
74
|
-
|
75
|
-
expect(disk.partitions[0].id).to eq(1)
|
76
|
-
expect(disk.partitions[0].disk).to eq(disk)
|
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
|
-
expect(disk.partitions[0].partition_type).to eq('primary')
|
81
|
-
expect(disk.partitions[0].fs_type).to eq('ntfs')
|
82
|
-
expect(disk.partitions[1].id).to eq(2)
|
83
|
-
expect(disk.partitions[1].disk).to eq(disk)
|
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
|
-
expect(disk.partitions[1].partition_type).to eq('primary')
|
88
|
-
expect(disk.partitions[1].fs_type).to eq('ext4')
|
89
|
-
expect(disk.partitions[2].id).to eq(3)
|
90
|
-
expect(disk.partitions[2].disk).to eq(disk)
|
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
|
-
expect(disk.partitions[2].partition_type).to eq('logical')
|
95
|
-
expect(disk.partitions[2].fs_type).to eq('linux-swap(v1)')
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe "#create_partitions" do
|
100
|
-
before(:each) do
|
101
|
-
@disk = LinuxAdmin::Disk.new(:path => '/dev/hda')
|
102
|
-
end
|
103
|
-
|
104
|
-
it "dispatches to create_partition" do
|
105
|
-
expect(@disk).to receive(:create_partition).with("primary", "0%", "50%")
|
106
|
-
@disk.create_partitions "primary", :start => "0%", :end => "50%"
|
107
|
-
end
|
108
|
-
|
109
|
-
context "multiple partitions specified" do
|
110
|
-
it "calls create_partition for each partition" do
|
111
|
-
expect(@disk).to receive(:create_partition).with("primary", "0%", "49%")
|
112
|
-
expect(@disk).to receive(:create_partition).with("primary", "50%", "100%")
|
113
|
-
@disk.create_partitions("primary", {:start => "0%", :end => "49%"},
|
114
|
-
{:start => "50%", :end => "100%"})
|
115
|
-
end
|
116
|
-
|
117
|
-
context "partitions overlap" do
|
118
|
-
it "raises argument error" do
|
119
|
-
expect{
|
120
|
-
@disk.create_partitions("primary", {:start => "0%", :end => "50%"},
|
121
|
-
{:start => "49%", :end => "100%"})
|
122
|
-
}.to raise_error(ArgumentError)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "#create_partition" do
|
129
|
-
before(:each) do
|
130
|
-
# test disk w/ existing partition
|
131
|
-
@disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
132
|
-
@disk.instance_variable_set(:@partitions,
|
133
|
-
[LinuxAdmin::Partition.new(:id => 1,
|
134
|
-
:end_sector => 1024)])
|
135
|
-
allow(@disk).to receive_messages(:has_partition_table? => true)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "uses parted" do
|
139
|
-
params = ['--script', '/dev/hda', 'mkpart', '-a', 'opt', 'primary', 1024, 2048]
|
140
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(LinuxAdmin::Common.cmd(:parted), :params => {nil => params})
|
141
|
-
@disk.create_partition 'primary', 1024
|
142
|
-
end
|
143
|
-
|
144
|
-
it "accepts start/end params" do
|
145
|
-
params = ['--script', '/dev/hda', 'mkpart', '-a', 'opt', 'primary', "0%", "50%"]
|
146
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(LinuxAdmin::Common.cmd(:parted), :params => {nil => params})
|
147
|
-
@disk.create_partition 'primary', "0%", "50%"
|
148
|
-
end
|
149
|
-
|
150
|
-
context "missing params" do
|
151
|
-
it "raises ArgumentError" do
|
152
|
-
expect{
|
153
|
-
@disk.create_partition 'primary'
|
154
|
-
}.to raise_error(ArgumentError)
|
155
|
-
|
156
|
-
expect{
|
157
|
-
@disk.create_partition 'primary', '0%', '50%', 100
|
158
|
-
}.to raise_error(ArgumentError)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
it "returns partition" do
|
163
|
-
expect(LinuxAdmin::Common).to receive(:run!) # stub out call to parted
|
164
|
-
partition = @disk.create_partition 'primary', 1024
|
165
|
-
expect(partition).to be_an_instance_of(LinuxAdmin::Partition)
|
166
|
-
end
|
167
|
-
|
168
|
-
it "increments partition id" do
|
169
|
-
expect(LinuxAdmin::Common).to receive(:run!) # stub out call to parted
|
170
|
-
partition = @disk.create_partition 'primary', 1024
|
171
|
-
expect(partition.id).to eq(2)
|
172
|
-
end
|
173
|
-
|
174
|
-
it "sets partition start to first unused sector on disk" do
|
175
|
-
expect(LinuxAdmin::Common).to receive(:run!) # stub out call to parted
|
176
|
-
partition = @disk.create_partition 'primary', 1024
|
177
|
-
expect(partition.start_sector).to eq(1024)
|
178
|
-
end
|
179
|
-
|
180
|
-
it "stores new partition locally" do
|
181
|
-
expect(LinuxAdmin::Common).to receive(:run!) # stub out call to parted
|
182
|
-
expect {
|
183
|
-
@disk.create_partition 'primary', 1024
|
184
|
-
}.to change{@disk.partitions.size}.by(1)
|
185
|
-
end
|
186
|
-
|
187
|
-
it "creates partition table if missing" do
|
188
|
-
allow(@disk).to receive_messages(:has_partition_table? => false)
|
189
|
-
expect(@disk).to receive(:create_partition_table)
|
190
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
191
|
-
@disk.create_partition 'primary', 1024
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
describe "#has_partition_table?" do
|
196
|
-
it "positive case" do
|
197
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
198
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:output => "", :exit_status => 0))
|
199
|
-
expect(disk).to have_partition_table
|
200
|
-
end
|
201
|
-
|
202
|
-
it "negative case" do
|
203
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
204
|
-
output = "\e[?1034h\r\rError: /dev/sdb: unrecognised disk label\n"
|
205
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:output => output, :exit_status => 1))
|
206
|
-
expect(disk).not_to have_partition_table
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
it "#create_partition_table" do
|
211
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
212
|
-
options = {:params => {nil => %w(--script /dev/hda mklabel msdos)}}
|
213
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(LinuxAdmin::Common.cmd(:parted), options)
|
214
|
-
disk.create_partition_table
|
215
|
-
end
|
216
|
-
|
217
|
-
describe "#clear!" do
|
218
|
-
it "clears partitions" do
|
219
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
220
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:output => "")) # stub out call to cmds
|
221
|
-
disk.partitions << LinuxAdmin::Partition.new
|
222
|
-
|
223
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
224
|
-
disk.clear!
|
225
|
-
expect(disk.partitions).to be_empty
|
226
|
-
end
|
227
|
-
|
228
|
-
it "uses dd to clear partition table" do
|
229
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
230
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
231
|
-
.with(LinuxAdmin::Common.cmd(:dd),
|
232
|
-
:params => {'if=' => '/dev/zero', 'of=' => '/dev/hda',
|
233
|
-
'bs=' => 512, 'count=' => 1})
|
234
|
-
disk.clear!
|
235
|
-
end
|
236
|
-
|
237
|
-
it "returns self" do
|
238
|
-
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
239
|
-
allow(LinuxAdmin::Common).to receive(:run!) # stub out call to dd
|
240
|
-
expect(disk.clear!).to eq(disk)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
end
|
data/spec/distro_spec.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::Distros::Distro do
|
2
|
-
let(:subject) { LinuxAdmin::Distros.local }
|
3
|
-
describe "#local" do
|
4
|
-
before do
|
5
|
-
allow(LinuxAdmin::Distros).to receive(:local).and_call_original
|
6
|
-
end
|
7
|
-
|
8
|
-
[['ubuntu', :ubuntu],
|
9
|
-
['Fedora', :fedora],
|
10
|
-
['red hat', :rhel],
|
11
|
-
['CentOS', :rhel],
|
12
|
-
['centos', :rhel]].each do |i, d|
|
13
|
-
context "/etc/issue contains '#{i}'" do
|
14
|
-
before(:each) do
|
15
|
-
etc_issue_contains(i)
|
16
|
-
exists("/etc/fedora-release" => false, "/etc/redhat-release" => false)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "returns Distros.#{d}" do
|
20
|
-
distro = LinuxAdmin::Distros.send(d)
|
21
|
-
expect(subject).to eq(distro)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "/etc/issue did not match" do
|
27
|
-
before(:each) do
|
28
|
-
etc_issue_contains('')
|
29
|
-
end
|
30
|
-
|
31
|
-
context "/etc/redhat-release exists" do
|
32
|
-
it "returns Distros.rhel" do
|
33
|
-
exists("/etc/fedora-release" => false, "/etc/redhat-release" => true)
|
34
|
-
expect(subject).to eq(LinuxAdmin::Distros.rhel)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "/etc/fedora-release exists" do
|
39
|
-
it "returns Distros.fedora" do
|
40
|
-
exists("/etc/fedora-release" => true, "/etc/redhat-release" => false)
|
41
|
-
expect(subject).to eq(LinuxAdmin::Distros.fedora)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns Distros.generic" do
|
47
|
-
etc_issue_contains('')
|
48
|
-
exists("/etc/fedora-release" => false, "/etc/redhat-release" => false)
|
49
|
-
expect(subject).to eq(LinuxAdmin::Distros.generic)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#info" do
|
54
|
-
it "dispatches to redhat lookup mechanism" do
|
55
|
-
stub_distro(LinuxAdmin::Distros.rhel)
|
56
|
-
expect(LinuxAdmin::Rpm).to receive(:info).with('ruby')
|
57
|
-
LinuxAdmin::Distros.local.info 'ruby'
|
58
|
-
end
|
59
|
-
|
60
|
-
it "dispatches to ubuntu lookup mechanism" do
|
61
|
-
stub_distro(LinuxAdmin::Distros.ubuntu)
|
62
|
-
expect(LinuxAdmin::Deb).to receive(:info).with('ruby')
|
63
|
-
LinuxAdmin::Distros.local.info 'ruby'
|
64
|
-
end
|
65
|
-
|
66
|
-
it "dispatches to ubuntu lookup mechanism" do
|
67
|
-
stub_distro(LinuxAdmin::Distros.generic)
|
68
|
-
expect { LinuxAdmin::Distros.local.info 'ruby' }.not_to raise_error
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
def exists(files)
|
75
|
-
files.each_pair { |file, value| allow(File).to receive(:exist?).with(file).and_return(value) }
|
76
|
-
end
|
77
|
-
end
|