ohai 13.1.0 → 13.2.0
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.
- checksums.yaml +4 -4
- data/Gemfile +15 -6
- data/lib/ohai/common/dmi.rb +11 -13
- data/lib/ohai/dsl/plugin.rb +6 -8
- data/lib/ohai/dsl/plugin/versionvi.rb +1 -1
- data/lib/ohai/dsl/plugin/versionvii.rb +4 -4
- data/lib/ohai/mash.rb +1 -1
- data/lib/ohai/mixin/command.rb +3 -3
- data/lib/ohai/mixin/dmi_decode.rb +1 -1
- data/lib/ohai/mixin/ec2_metadata.rb +10 -10
- data/lib/ohai/mixin/os.rb +11 -11
- data/lib/ohai/mixin/softlayer_metadata.rb +2 -2
- data/lib/ohai/mixin/string.rb +1 -1
- data/lib/ohai/plugins/azure.rb +2 -2
- data/lib/ohai/plugins/c.rb +9 -10
- data/lib/ohai/plugins/darwin/cpu.rb +24 -20
- data/lib/ohai/plugins/darwin/hardware.rb +15 -9
- data/lib/ohai/plugins/digital_ocean.rb +2 -2
- data/lib/ohai/plugins/ec2.rb +5 -5
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +2 -2
- data/lib/ohai/plugins/eucalyptus.rb +2 -2
- data/lib/ohai/plugins/go.rb +1 -1
- data/lib/ohai/plugins/hostname.rb +7 -10
- data/lib/ohai/plugins/ip_scopes.rb +2 -0
- data/lib/ohai/plugins/java.rb +19 -21
- data/lib/ohai/plugins/kernel.rb +1 -1
- data/lib/ohai/plugins/linux/cpu.rb +4 -0
- data/lib/ohai/plugins/linux/filesystem.rb +43 -30
- data/lib/ohai/plugins/linux/lsb.rb +1 -1
- data/lib/ohai/plugins/linux/mdadm.rb +9 -1
- data/lib/ohai/plugins/linux/network.rb +8 -12
- data/lib/ohai/plugins/linux/platform.rb +9 -1
- data/lib/ohai/plugins/linux/systemd_paths.rb +39 -0
- data/lib/ohai/plugins/mono.rb +1 -1
- data/lib/ohai/plugins/nodejs.rb +1 -1
- data/lib/ohai/plugins/openstack.rb +5 -5
- data/lib/ohai/plugins/packages.rb +8 -2
- data/lib/ohai/plugins/perl.rb +1 -1
- data/lib/ohai/plugins/php.rb +1 -1
- data/lib/ohai/plugins/powershell.rb +1 -1
- data/lib/ohai/plugins/python.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +4 -4
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/solaris2/dmi.rb +3 -3
- data/lib/ohai/plugins/solaris2/network.rb +2 -2
- data/lib/ohai/plugins/ssh_host_key.rb +1 -1
- data/lib/ohai/plugins/uptime.rb +1 -1
- data/lib/ohai/plugins/{solaris2/zpools.rb → zpools.rb} +39 -16
- data/lib/ohai/util/file_helper.rb +2 -2
- data/lib/ohai/version.rb +1 -1
- data/spec/data/plugins/lslpp.output +1 -0
- data/spec/unit/plugins/darwin/cpu_spec.rb +66 -19
- data/spec/unit/plugins/darwin/hardware_spec.rb +2 -14
- data/spec/unit/plugins/linux/cpu_spec.rb +47 -0
- data/spec/unit/plugins/linux/filesystem_spec.rb +99 -9
- data/spec/unit/plugins/linux/mdadm_spec.rb +26 -1
- data/spec/unit/plugins/linux/network_spec.rb +8 -26
- data/spec/unit/plugins/linux/platform_spec.rb +41 -0
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +122 -0
- data/spec/unit/plugins/packages_spec.rb +4 -0
- data/spec/unit/plugins/rackspace_spec.rb +3 -3
- data/spec/unit/plugins/zpools_spec.rb +242 -0
- metadata +7 -5
- data/spec/unit/plugins/solaris2/zpools_spec.rb +0 -153
@@ -31,21 +31,9 @@ describe Ohai::System, "Darwin hardware plugin", :unix_only do
|
|
31
31
|
)
|
32
32
|
|
33
33
|
allow(plugin).to receive(:shell_out).with(
|
34
|
-
"sw_vers
|
34
|
+
"sw_vers"
|
35
35
|
).and_return(
|
36
|
-
mock_shell_out(0, "Mac OS X", "")
|
37
|
-
)
|
38
|
-
|
39
|
-
allow(plugin).to receive(:shell_out).with(
|
40
|
-
"sw_vers -productVersion"
|
41
|
-
).and_return(
|
42
|
-
mock_shell_out(0, "10.12", "")
|
43
|
-
)
|
44
|
-
|
45
|
-
allow(plugin).to receive(:shell_out).with(
|
46
|
-
"sw_vers -buildVersion"
|
47
|
-
).and_return(
|
48
|
-
mock_shell_out(0, "16A239j", "")
|
36
|
+
mock_shell_out(0, "ProductName: Mac OS X\nProductVersion: 10.12\nBuildVersion: 16A239j", "")
|
49
37
|
)
|
50
38
|
|
51
39
|
allow(plugin).to receive(:shell_out).with(
|
@@ -60,6 +60,22 @@ shared_examples "S390 processor info" do |cpu_no, version, identification, machi
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
shared_examples "arm64 processor info" do |cpu_no, bogomips, features|
|
64
|
+
describe "arm64 processor" do
|
65
|
+
it "has bogomips for cpu #{cpu_no}" do
|
66
|
+
plugin.run
|
67
|
+
expect(plugin[:cpu]["#{cpu_no}"]).to have_key("bogomips")
|
68
|
+
expect(plugin[:cpu]["#{cpu_no}"]["bogomips"]).to eql(bogomips)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "has features for cpu #{cpu_no}" do
|
72
|
+
plugin.run
|
73
|
+
expect(plugin[:cpu]["#{cpu_no}"]).to have_key("features")
|
74
|
+
expect(plugin[:cpu]["#{cpu_no}"]["features"]).to eql(features)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
63
79
|
describe Ohai::System, "General Linux cpu plugin" do
|
64
80
|
let(:plugin) { get_plugin("linux/cpu") }
|
65
81
|
|
@@ -355,3 +371,34 @@ describe Ohai::System, "S390 linux cpu plugin" do
|
|
355
371
|
it_behaves_like "S390 processor info", 0, "EE", "06E276", "2717"
|
356
372
|
it_behaves_like "S390 processor info", 1, "FF", "06E278", "2818"
|
357
373
|
end
|
374
|
+
|
375
|
+
describe Ohai::System, "arm64 linux cpu plugin" do
|
376
|
+
let(:plugin) { get_plugin("linux/cpu") }
|
377
|
+
|
378
|
+
before(:each) do
|
379
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
380
|
+
|
381
|
+
@double_file = double("/proc/cpuinfo")
|
382
|
+
allow(@double_file).to receive(:each).
|
383
|
+
and_yield("processor : 0").
|
384
|
+
and_yield("BogoMIPS : 40.00").
|
385
|
+
and_yield("Features : fp asimd evtstrm aes pmull sha1 sha2 crc32").
|
386
|
+
and_yield("").
|
387
|
+
and_yield("processor : 1").
|
388
|
+
and_yield("BogoMIPS : 40.00").
|
389
|
+
and_yield("Features : fp asimd evtstrm aes pmull sha1 sha2 crc32").
|
390
|
+
and_yield("")
|
391
|
+
allow(File).to receive(:open).with("/proc/cpuinfo").and_return(@double_file)
|
392
|
+
end
|
393
|
+
|
394
|
+
it_behaves_like "Common cpu info", 2, 0
|
395
|
+
|
396
|
+
it "has a cpu 1" do
|
397
|
+
plugin.run
|
398
|
+
expect(plugin[:cpu]).to have_key("1")
|
399
|
+
end
|
400
|
+
|
401
|
+
features = %w{fp asimd evtstrm aes pmull sha1 sha2 crc32}
|
402
|
+
it_behaves_like "arm64 processor info", 0, "40.00", features
|
403
|
+
it_behaves_like "arm64 processor info", 1, "40.00", features
|
404
|
+
end
|
@@ -26,8 +26,9 @@ describe Ohai::System, "Linux filesystem plugin" do
|
|
26
26
|
allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
|
27
27
|
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
|
28
28
|
allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
|
29
|
-
allow(
|
30
|
-
allow(plugin).to receive(:
|
29
|
+
allow(plugin).to receive(:which).with("lsblk").and_return(nil)
|
30
|
+
allow(plugin).to receive(:which).with("blkid").and_return("/sbin/blkid")
|
31
|
+
allow(plugin).to receive(:shell_out).with("/sbin/blkid").and_return(mock_shell_out(0, "", ""))
|
31
32
|
|
32
33
|
allow(plugin).to receive(:shell_out).
|
33
34
|
with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
@@ -218,7 +219,7 @@ DFi
|
|
218
219
|
/dev/mapper/sys.vg-var.lv: LABEL=\"/var\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" TYPE=\"ext4\"
|
219
220
|
/dev/mapper/sys.vg-home.lv: LABEL=\"/home\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" TYPE=\"xfs\"
|
220
221
|
BLKID_TYPE
|
221
|
-
allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, @stdout, ""))
|
222
|
+
allow(plugin).to receive(:shell_out).with("/sbin/blkid").and_return(mock_shell_out(0, @stdout, ""))
|
222
223
|
end
|
223
224
|
|
224
225
|
it "should run blkid" do
|
@@ -260,7 +261,8 @@ none 126922 1 126921 1% /run/shm
|
|
260
261
|
DFi
|
261
262
|
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
262
263
|
|
263
|
-
allow(
|
264
|
+
allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk")
|
265
|
+
allow(plugin).to receive(:which).with("blkid").and_return(nil)
|
264
266
|
@stdout = <<-BLKID_TYPE
|
265
267
|
NAME=\"sdb1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
|
266
268
|
NAME=\"sdb2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
|
@@ -277,7 +279,7 @@ NAME=\"sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/h
|
|
277
279
|
NAME=\"debian--7-root (dm-0)\" UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" LABEL=\"root\" FSTYPE=\"ext4\"
|
278
280
|
BLKID_TYPE
|
279
281
|
allow(plugin).to receive(:shell_out).
|
280
|
-
with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
282
|
+
with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
281
283
|
and_return(mock_shell_out(0, @stdout, ""))
|
282
284
|
end
|
283
285
|
|
@@ -299,6 +301,92 @@ BLKID_TYPE
|
|
299
301
|
|
300
302
|
end
|
301
303
|
|
304
|
+
describe "when gathering filesystem type data from both lsblk and blkid" do
|
305
|
+
before(:each) do
|
306
|
+
@dfstdout = <<-DF
|
307
|
+
Filesystem 1024-blocks Used Available Capacity Mounted on
|
308
|
+
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
|
309
|
+
tmpfs 2030944 0 2030944 0% /lib/init/rw
|
310
|
+
udev 2025576 228 2025348 1% /dev
|
311
|
+
tmpfs 2030944 2960 2027984 1% /dev/shm
|
312
|
+
/dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
|
313
|
+
/dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
|
314
|
+
/dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
|
315
|
+
/dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
|
316
|
+
/dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
|
317
|
+
/dev/md0 960492 36388 875312 4% /boot
|
318
|
+
DF
|
319
|
+
allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
|
320
|
+
|
321
|
+
@inode_stdout = <<-DFi
|
322
|
+
Filesystem Inodes IUsed IFree IUse% Mounted on
|
323
|
+
/dev/xvda1 1310720 107407 1203313 9% /
|
324
|
+
/dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
|
325
|
+
tmpfs 126922 273 126649 1% /run
|
326
|
+
none 126922 1 126921 1% /run/lock
|
327
|
+
none 126922 1 126921 1% /run/shm
|
328
|
+
DFi
|
329
|
+
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
330
|
+
|
331
|
+
allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk")
|
332
|
+
allow(plugin).to receive(:which).with("blkid").and_return("/sbin/blkid")
|
333
|
+
@stdout = <<-BLKID_TYPE
|
334
|
+
NAME=\"sdb1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
|
335
|
+
NAME=\"sdb2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
|
336
|
+
NAME=\"sda1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
|
337
|
+
NAME=\"sda2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
|
338
|
+
NAME=\"md0\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" LABEL=\"/boot\" FSTYPE=\"ext3\"
|
339
|
+
NAME=\"md1\" UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" LABEL=\"\" FSTYPE=\"LVM2_member\"
|
340
|
+
NAME=\"sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\"
|
341
|
+
NAME=\"sys.vg-swap.lv\" UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" LABEL=\"\" FSTYPE=\"swap\"
|
342
|
+
NAME=\"sys.vg-tmp.lv\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" LABEL=\"/tmp\" FSTYPE=\"ext4\"
|
343
|
+
NAME=\"sys.vg-usr.lv\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" LABEL=\"/usr\"
|
344
|
+
NAME=\"sys.vg-var.lv\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/var\" FSTYPE=\"ext4\"
|
345
|
+
NAME=\"sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/BADhome\" FSTYPE=\"xfs\"
|
346
|
+
NAME=\"debian--7-root (dm-0)\" UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" LABEL=\"root\" FSTYPE=\"ext4\"
|
347
|
+
BLKID_TYPE
|
348
|
+
allow(plugin).to receive(:shell_out).
|
349
|
+
with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
350
|
+
and_return(mock_shell_out(0, @stdout, ""))
|
351
|
+
@stdout = <<-BLKID_TYPE
|
352
|
+
/dev/sdb1: LABEL=\"fuego:0\" TYPE=\"linux_raid_member\"
|
353
|
+
/dev/sdb2: LABEL=\"fuego:1\" TYPE=\"linux_raid_member\"
|
354
|
+
/dev/sda1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
|
355
|
+
/dev/sda2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
|
356
|
+
/dev/md0: LABEL=\"/boot\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" TYPE=\"ext3\"
|
357
|
+
/dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" TYPE=\"LVM2_member\"
|
358
|
+
/dev/mapper/sys.vg-root.lv: LABEL=\"/\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" TYPE=\"ext4\"
|
359
|
+
/dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" TYPE=\"swap\"
|
360
|
+
/dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" TYPE=\"ext4\"
|
361
|
+
/dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" TYPE=\"ext4\"
|
362
|
+
/dev/mapper/sys.vg-var.lv: LABEL=\"/var\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" TYPE=\"ext4\"
|
363
|
+
/dev/mapper/sys.vg-home.lv: LABEL=\"/home\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" TYPE=\"xfs\"
|
364
|
+
BLKID_TYPE
|
365
|
+
allow(plugin).to receive(:shell_out).with("/sbin/blkid").and_return(mock_shell_out(0, @stdout, ""))
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should fill in missing FS data from lsblk using blkid" do
|
369
|
+
plugin.run
|
370
|
+
pairs = plugin[:filesystem]["by_pair"]
|
371
|
+
expect(pairs["/dev/mapper/sys.vg-root.lv,/"]["fs_type"]).to eq("ext4")
|
372
|
+
expect(pairs["/dev/mapper/sys.vg-usr.lv,/usr"]["fs_type"]).to eq("ext4")
|
373
|
+
end
|
374
|
+
|
375
|
+
it "should fill in missing FS data from blkid using lsblk" do
|
376
|
+
plugin.run
|
377
|
+
pairs = plugin[:filesystem]["by_pair"]
|
378
|
+
expect(pairs["/dev/sdb1,"]["uuid"]).to eq("bd1197e0-6997-1f3a-e27e-7801388308b5")
|
379
|
+
expect(pairs["/dev/sdb2,"]["uuid"]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
|
380
|
+
end
|
381
|
+
|
382
|
+
it "should prefer lsblk data to blkid data when they conflict" do
|
383
|
+
plugin.run
|
384
|
+
pairs = plugin[:filesystem]["by_pair"]
|
385
|
+
expect(pairs["/dev/mapper/sys.vg-home.lv,/home"]["label"]).to eq("/home")
|
386
|
+
end
|
387
|
+
|
388
|
+
end
|
389
|
+
|
302
390
|
describe "when gathering data from /proc/mounts" do
|
303
391
|
before(:each) do
|
304
392
|
allow(File).to receive(:exist?).with("/proc/mounts").and_return(true)
|
@@ -378,13 +466,14 @@ udev 126922 1 126921 1% /dev
|
|
378
466
|
DFi
|
379
467
|
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
380
468
|
|
381
|
-
allow(
|
469
|
+
allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk")
|
470
|
+
allow(plugin).to receive(:which).with("blkid").and_return(nil)
|
382
471
|
@stdout = <<-BLKID_TYPE
|
383
472
|
NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
|
384
473
|
NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
|
385
474
|
BLKID_TYPE
|
386
475
|
allow(plugin).to receive(:shell_out).
|
387
|
-
with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
476
|
+
with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
388
477
|
and_return(mock_shell_out(0, @stdout, ""))
|
389
478
|
end
|
390
479
|
|
@@ -422,7 +511,8 @@ udev 126922 1 126921 1% /dev
|
|
422
511
|
DFi
|
423
512
|
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
424
513
|
|
425
|
-
allow(
|
514
|
+
allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk")
|
515
|
+
allow(plugin).to receive(:which).with("blkid").and_return(nil)
|
426
516
|
@stdout = <<-BLKID_TYPE
|
427
517
|
NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
|
428
518
|
NAME=\"/dev/sdb1\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/mnt\" FSTYPE=\"ext4\"
|
@@ -430,7 +520,7 @@ NAME=\"/dev/sdc1\" UUID=\"7f1e51bf-3608-4351-b7cd-379e39cff36a\" LABEL=\"/mnt\"
|
|
430
520
|
NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
|
431
521
|
BLKID_TYPE
|
432
522
|
allow(plugin).to receive(:shell_out).
|
433
|
-
with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
523
|
+
with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
434
524
|
and_return(mock_shell_out(0, @stdout, ""))
|
435
525
|
end
|
436
526
|
|
@@ -99,12 +99,37 @@ MD
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
it "should detect member
|
102
|
+
it "should detect member devices" do
|
103
103
|
@plugin.run
|
104
104
|
expect(@plugin[:mdadm][:md0][:members].sort).to eq(
|
105
105
|
%w{sdc sdd sde sdf sdg sdh}
|
106
106
|
)
|
107
107
|
end
|
108
|
+
|
109
|
+
it "should detect member devices even if mdstat has extra entries" do
|
110
|
+
new_mdstat = double("/proc/mdstat2")
|
111
|
+
allow(new_mdstat).to receive(:each).
|
112
|
+
and_yield("Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10]").
|
113
|
+
and_yield("md0 : active (somecraphere) <morestuff> raid10 sdh[5] sdg[4] sdf[3] sde[2] sdd[1] sdc[0]").
|
114
|
+
and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]")
|
115
|
+
allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat)
|
116
|
+
|
117
|
+
@plugin.run
|
118
|
+
expect(@plugin[:mdadm][:md0][:members].sort).to eq(
|
119
|
+
%w{sdc sdd sde sdf sdg sdh}
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should accurately report inactive arrays" do
|
124
|
+
new_mdstat = double("/proc/mdstat_inactive")
|
125
|
+
allow(new_mdstat).to receive(:each).
|
126
|
+
and_yield("Personalities :").
|
127
|
+
and_yield("md0 : inactive nvme2n1p3[2](S)")
|
128
|
+
allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat)
|
129
|
+
|
130
|
+
@plugin.run
|
131
|
+
expect(@plugin[:mdadm][:md0][:members].sort).to eq(%w{nvme2n1p3})
|
132
|
+
end
|
108
133
|
end
|
109
134
|
|
110
135
|
end
|
@@ -377,26 +377,6 @@ EOM
|
|
377
377
|
allow(plugin).to receive(:shell_out).with(/ethtool [^\-]/).and_return(mock_shell_out(0, linux_ethtool, ""))
|
378
378
|
end
|
379
379
|
|
380
|
-
describe "#iproute2_binary_available?" do
|
381
|
-
["/sbin/ip", "/usr/bin/ip", "/bin/ip"].each do |path|
|
382
|
-
it "accepts #{path}" do
|
383
|
-
allow(File).to receive(:exist?).and_return(false)
|
384
|
-
allow(File).to receive(:exist?).with(path).and_return(true)
|
385
|
-
expect(plugin.iproute2_binary_available?).to be_truthy
|
386
|
-
end
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
describe "#find_ethtool_binary" do
|
391
|
-
["/sbin/ethtool", "/usr/sbin/ethtool"].each do |path|
|
392
|
-
it "accepts #{path}" do
|
393
|
-
allow(File).to receive(:exist?).and_return(false)
|
394
|
-
allow(File).to receive(:exist?).with(path).and_return(true)
|
395
|
-
expect(plugin.find_ethtool_binary).to end_with("/ethtool")
|
396
|
-
end
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
380
|
describe "#interface_has_no_addresses_in_family?" do
|
401
381
|
context "when interface has no addresses" do
|
402
382
|
let(:iface) { {} }
|
@@ -555,8 +535,8 @@ EOM
|
|
555
535
|
%w{ifconfig iproute2}.each do |network_method|
|
556
536
|
describe "gathering IP layer address info via #{network_method}" do
|
557
537
|
before(:each) do
|
558
|
-
allow(plugin).to receive(:
|
559
|
-
allow(plugin).to receive(:
|
538
|
+
allow(plugin).to receive(:which).with("ip").and_return( network_method == "iproute2" ? "/sbin/ip" : false )
|
539
|
+
allow(plugin).to receive(:which).with("ethtool").and_return( "/sbin/ethtool" )
|
560
540
|
plugin.run
|
561
541
|
end
|
562
542
|
|
@@ -674,7 +654,8 @@ EOM
|
|
674
654
|
|
675
655
|
describe "gathering interface counters via #{network_method}" do
|
676
656
|
before(:each) do
|
677
|
-
allow(plugin).to receive(:
|
657
|
+
allow(plugin).to receive(:which).with("ip").and_return(network_method == "iproute2" ? "/sbin/ip" : false)
|
658
|
+
allow(plugin).to receive(:which).with("ethtool").and_return("/sbin/ethtool")
|
678
659
|
plugin.run
|
679
660
|
end
|
680
661
|
|
@@ -712,7 +693,8 @@ EOM
|
|
712
693
|
|
713
694
|
describe "setting the node's default IP address attribute with #{network_method}" do
|
714
695
|
before(:each) do
|
715
|
-
allow(plugin).to receive(:
|
696
|
+
allow(plugin).to receive(:which).with("ip").and_return(network_method == "iproute2" ? "/sbin/ip" : false)
|
697
|
+
allow(plugin).to receive(:which).with("ethtool").and_return("/sbin/ethtool")
|
716
698
|
plugin.run
|
717
699
|
end
|
718
700
|
|
@@ -790,9 +772,9 @@ EOM
|
|
790
772
|
|
791
773
|
describe "for newer network features using iproute2 only" do
|
792
774
|
before(:each) do
|
793
|
-
allow(
|
775
|
+
allow(plugin).to receive(:which).with("ip").and_return("/sbin/ip")
|
776
|
+
allow(plugin).to receive(:which).with("ethtool").and_return( "/sbin/ethtool" )
|
794
777
|
allow(File).to receive(:exist?).with("/proc/net/if_inet6").and_return(true) # ipv6 is enabled
|
795
|
-
allow(File).to receive(:exist?).with("/sbin/ethtool").and_return(true) # ethtool is available
|
796
778
|
plugin.run
|
797
779
|
end
|
798
780
|
|
@@ -35,6 +35,7 @@ describe Ohai::System, "Linux plugin platform" do
|
|
35
35
|
let(:have_parallels_release) { false }
|
36
36
|
let(:have_raspi_config) { false }
|
37
37
|
let(:have_os_release) { false }
|
38
|
+
let(:have_usr_lib_os_release) { false }
|
38
39
|
let(:have_cisco_release) { false }
|
39
40
|
let(:have_cumulus_dir) { false }
|
40
41
|
|
@@ -57,6 +58,7 @@ describe Ohai::System, "Linux plugin platform" do
|
|
57
58
|
allow(File).to receive(:exist?).with("/etc/parallels-release").and_return(have_parallels_release)
|
58
59
|
allow(File).to receive(:exist?).with("/usr/bin/raspi-config").and_return(have_raspi_config)
|
59
60
|
allow(File).to receive(:exist?).with("/etc/os-release").and_return(have_os_release)
|
61
|
+
allow(File).to receive(:exist?).with("/usr/lib/os-release").and_return(have_usr_lib_os_release)
|
60
62
|
allow(File).to receive(:exist?).with("/etc/shared/os-release").and_return(have_cisco_release)
|
61
63
|
allow(Dir).to receive(:exist?).with("/etc/cumulus").and_return(have_cumulus_dir)
|
62
64
|
|
@@ -429,6 +431,14 @@ OS_RELEASE
|
|
429
431
|
expect(@plugin[:platform_version].to_i).to eq(13)
|
430
432
|
end
|
431
433
|
|
434
|
+
it "should read the platform as clearos and version as 7.3" do
|
435
|
+
expect(File).to receive(:read).with("/etc/redhat-release").and_return("ClearOS release 7.3.0 (Final)")
|
436
|
+
@plugin.run
|
437
|
+
expect(@plugin[:platform]).to eq("clearos")
|
438
|
+
expect(@plugin[:platform_family]).to eq("rhel")
|
439
|
+
expect(@plugin[:platform_version].to_f).to eq(7.3)
|
440
|
+
end
|
441
|
+
|
432
442
|
# https://github.com/chef/ohai/issues/560
|
433
443
|
# Issue is seen on EL7, so that's what we're testing.
|
434
444
|
context "on versions that have /etc/os-release" do
|
@@ -853,4 +863,35 @@ CISCO_RELEASE
|
|
853
863
|
expect(@plugin[:platform_version]).to eq("6.0.0.14I")
|
854
864
|
end
|
855
865
|
end
|
866
|
+
|
867
|
+
describe "on clearlinux" do
|
868
|
+
let(:have_usr_lib_os_release) { true }
|
869
|
+
let(:usr_lib_os_release_content) do
|
870
|
+
<<-CLEARLINUX_RELEASE
|
871
|
+
NAME="Clear Linux Software for Intel Architecture"
|
872
|
+
VERSION=1
|
873
|
+
ID=clear-linux-os
|
874
|
+
VERSION_ID=16140
|
875
|
+
PRETTY_NAME="Clear Linux OS for Intel Architecture"
|
876
|
+
ANSI_COLOR="1;35"
|
877
|
+
HOME_URL="https://clearlinux.org"
|
878
|
+
SUPPORT_URL="https://clearlinux.org"
|
879
|
+
BUG_REPORT_URL="mailto:dev@lists.clearlinux.org"
|
880
|
+
PRIVACY_POLICY_URL="http://www.intel.com/privacy"
|
881
|
+
CLEARLINUX_RELEASE
|
882
|
+
end
|
883
|
+
|
884
|
+
before do
|
885
|
+
expect(File).to receive(:read).with("/usr/lib/os-release").and_return(usr_lib_os_release_content)
|
886
|
+
end
|
887
|
+
|
888
|
+
it "should set platform to clearlinux and platform_family to clearlinux" do
|
889
|
+
@plugin.lsb = nil
|
890
|
+
@plugin.run
|
891
|
+
|
892
|
+
expect(@plugin[:platform]).to eq("clearlinux")
|
893
|
+
expect(@plugin[:platform_family]).to eq("clearlinux")
|
894
|
+
expect(@plugin[:platform_version]).to eq("16140")
|
895
|
+
end
|
896
|
+
end
|
856
897
|
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Davide Cavalca <dcavalca@fb.com>
|
3
|
+
# Copyright:: Copyright (c) 2017 Facebook
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS"BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
|
20
|
+
|
21
|
+
describe Ohai::System, "Linux systemd paths plugin" do
|
22
|
+
let(:plugin) { get_plugin("linux/systemd_paths") }
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should populate systemd_paths if systemd-path is found" do
|
29
|
+
systemd_path_out = <<-SYSTEMD_PATH_OUT
|
30
|
+
temporary: /tmp
|
31
|
+
temporary-large: /var/tmp
|
32
|
+
system-binaries: /usr/bin
|
33
|
+
system-include: /usr/include
|
34
|
+
system-library-private: /usr/lib
|
35
|
+
system-library-arch: /usr/lib/x86_64-linux-gnu
|
36
|
+
system-shared: /usr/share
|
37
|
+
system-configuration-factory: /usr/share/factory/etc
|
38
|
+
system-state-factory: /usr/share/factory/var
|
39
|
+
system-configuration: /etc
|
40
|
+
system-runtime: /run
|
41
|
+
system-runtime-logs: /run/log
|
42
|
+
system-state-private: /var/lib
|
43
|
+
system-state-logs: /var/log
|
44
|
+
system-state-cache: /var/cache
|
45
|
+
system-state-spool: /var/spool
|
46
|
+
user-binaries: /home/foo/.local/bin
|
47
|
+
user-library-private: /home/foo/.local/lib
|
48
|
+
user-library-arch: /home/foo/.local/lib/x86_64-linux-gnu
|
49
|
+
user-shared: /home/foo/.local/share
|
50
|
+
user-configuration: /home/foo/.config
|
51
|
+
user-runtime: /run/user/1000
|
52
|
+
user-state-cache: /home/foo/.cache
|
53
|
+
user: /home/foo
|
54
|
+
user-documents: /home/foo/Documents
|
55
|
+
user-music: /home/foo/Music
|
56
|
+
user-pictures: /home/foo/Pictures
|
57
|
+
user-videos: /home/foo/Videos
|
58
|
+
user-download: /home/foo/Downloads
|
59
|
+
user-public: /home/foo/Public
|
60
|
+
user-templates: /home/foo/Templates
|
61
|
+
user-desktop: /home/foo/Desktop
|
62
|
+
search-binaries: /home/foo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/facebook/bin:/home/foo/.rvm/bin:/home/foo/.rvm/bin
|
63
|
+
search-library-private: /home/foo/.local/lib:/usr/local/lib:/usr/lib:/lib
|
64
|
+
search-library-arch: /home/foo/.local/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu
|
65
|
+
search-shared: /home/foo/.local/share:/usr/share/gnome:/home/foo/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
|
66
|
+
search-configuration-factory: /usr/local/share/factory/etc:/usr/share/factory/etc
|
67
|
+
search-state-factory: /usr/local/share/factory/var:/usr/share/factory/var
|
68
|
+
search-configuration: /home/foo/.config:/etc
|
69
|
+
SYSTEMD_PATH_OUT
|
70
|
+
|
71
|
+
allow(plugin).to receive(:which).with("systemd-path").and_return("/bin/systemd-path")
|
72
|
+
allow(plugin).to receive(:shell_out).with("/bin/systemd-path").and_return(mock_shell_out(0, systemd_path_out, ""))
|
73
|
+
plugin.run
|
74
|
+
expect(plugin[:systemd_paths].to_hash).to eq({
|
75
|
+
"search-binaries" => "/home/foo/bin",
|
76
|
+
"search-configuration" => "/home/foo/.config",
|
77
|
+
"search-configuration-factory" => "/usr/local/share/factory/etc",
|
78
|
+
"search-library-arch" => "/home/foo/.local/lib/x86_64-linux-gnu",
|
79
|
+
"search-library-private" => "/home/foo/.local/lib",
|
80
|
+
"search-shared" => "/home/foo/.local/share",
|
81
|
+
"search-state-factory" => "/usr/local/share/factory/var",
|
82
|
+
"system-binaries" => "/usr/bin",
|
83
|
+
"system-configuration" => "/etc",
|
84
|
+
"system-configuration-factory" => "/usr/share/factory/etc",
|
85
|
+
"system-include" => "/usr/include",
|
86
|
+
"system-library-arch" => "/usr/lib/x86_64-linux-gnu",
|
87
|
+
"system-library-private" => "/usr/lib",
|
88
|
+
"system-runtime" => "/run",
|
89
|
+
"system-runtime-logs" => "/run/log",
|
90
|
+
"system-shared" => "/usr/share",
|
91
|
+
"system-state-cache" => "/var/cache",
|
92
|
+
"system-state-factory" => "/usr/share/factory/var",
|
93
|
+
"system-state-logs" => "/var/log",
|
94
|
+
"system-state-private" => "/var/lib",
|
95
|
+
"system-state-spool" => "/var/spool",
|
96
|
+
"temporary" => "/tmp",
|
97
|
+
"temporary-large" => "/var/tmp",
|
98
|
+
"user" => "/home/foo",
|
99
|
+
"user-binaries" => "/home/foo/.local/bin",
|
100
|
+
"user-configuration" => "/home/foo/.config",
|
101
|
+
"user-desktop" => "/home/foo/Desktop",
|
102
|
+
"user-documents" => "/home/foo/Documents",
|
103
|
+
"user-download" => "/home/foo/Downloads",
|
104
|
+
"user-library-arch" => "/home/foo/.local/lib/x86_64-linux-gnu",
|
105
|
+
"user-library-private" => "/home/foo/.local/lib",
|
106
|
+
"user-music" => "/home/foo/Music",
|
107
|
+
"user-pictures" => "/home/foo/Pictures",
|
108
|
+
"user-public" => "/home/foo/Public",
|
109
|
+
"user-runtime" => "/run/user/1000",
|
110
|
+
"user-shared" => "/home/foo/.local/share",
|
111
|
+
"user-state-cache" => "/home/foo/.cache",
|
112
|
+
"user-templates" => "/home/foo/Templates",
|
113
|
+
"user-videos" => "/home/foo/Videos",
|
114
|
+
})
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should not populate systemd paths if systemd-path is not found" do
|
118
|
+
allow(plugin).to receive(:which).with("systemd-path").and_return(false)
|
119
|
+
plugin.run
|
120
|
+
expect(plugin[:systemd_paths]).to be(nil)
|
121
|
+
end
|
122
|
+
end
|