ohai 13.12.6 → 14.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -12
- data/README.md +7 -12
- data/Rakefile +16 -23
- data/docs/man/man1/ohai.1 +97 -0
- data/lib/ohai/application.rb +9 -4
- data/lib/ohai/common/dmi.rb +4 -16
- data/lib/ohai/config.rb +5 -1
- data/lib/ohai/dsl.rb +0 -1
- data/lib/ohai/dsl/plugin.rb +12 -16
- data/lib/ohai/dsl/plugin/versionvii.rb +17 -5
- data/lib/ohai/hints.rb +2 -2
- data/lib/ohai/loader.rb +21 -70
- data/lib/ohai/log.rb +1 -1
- data/lib/ohai/mixin/azure_metadata.rb +4 -4
- data/lib/ohai/mixin/command.rb +3 -3
- data/lib/ohai/mixin/dmi_decode.rb +0 -2
- data/lib/ohai/mixin/do_metadata.rb +1 -1
- data/lib/ohai/mixin/ec2_metadata.rb +8 -8
- data/lib/ohai/mixin/gce_metadata.rb +1 -5
- data/lib/ohai/mixin/http_helper.rb +3 -3
- data/lib/ohai/mixin/scaleway_metadata.rb +46 -0
- data/lib/ohai/mixin/softlayer_metadata.rb +3 -3
- data/lib/ohai/plugins/aix/filesystem.rb +1 -1
- data/lib/ohai/plugins/aix/memory.rb +1 -1
- data/lib/ohai/plugins/aix/network.rb +2 -2
- data/lib/ohai/plugins/aix/virtualization.rb +1 -1
- data/lib/ohai/plugins/azure.rb +5 -5
- data/lib/ohai/plugins/bsd/virtualization.rb +11 -11
- data/lib/ohai/plugins/c.rb +8 -8
- data/lib/ohai/plugins/chef.rb +2 -1
- data/lib/ohai/plugins/cloud.rb +0 -3
- data/lib/ohai/plugins/darwin/cpu.rb +2 -2
- data/lib/ohai/plugins/darwin/filesystem.rb +0 -2
- data/lib/ohai/plugins/darwin/hardware.rb +9 -3
- data/lib/ohai/plugins/darwin/network.rb +2 -2
- data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
- data/lib/ohai/plugins/darwin/virtualization.rb +10 -0
- data/lib/ohai/plugins/digital_ocean.rb +4 -4
- data/lib/ohai/plugins/dmi.rb +15 -14
- data/lib/ohai/plugins/docker.rb +57 -0
- data/lib/ohai/plugins/ec2.rb +11 -11
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +2 -2
- data/lib/ohai/plugins/eucalyptus.rb +5 -5
- data/lib/ohai/plugins/gce.rb +2 -2
- data/lib/ohai/plugins/go.rb +1 -1
- data/lib/ohai/plugins/groovy.rb +1 -1
- data/lib/ohai/plugins/haskell.rb +4 -4
- data/lib/ohai/plugins/hostname.rb +6 -6
- data/lib/ohai/plugins/init_package.rb +1 -1
- data/lib/ohai/plugins/java.rb +1 -1
- data/lib/ohai/plugins/kernel.rb +109 -40
- data/lib/ohai/plugins/libvirt.rb +113 -0
- data/lib/ohai/plugins/linode.rb +4 -4
- data/lib/ohai/plugins/linux/block_device.rb +4 -4
- data/lib/ohai/plugins/linux/cpu.rb +3 -3
- data/lib/ohai/plugins/linux/filesystem.rb +4 -6
- data/lib/ohai/plugins/linux/lsb.rb +3 -3
- data/lib/ohai/plugins/linux/lspci.rb +2 -1
- data/lib/ohai/plugins/linux/machineid.rb +4 -4
- data/lib/ohai/plugins/linux/network.rb +16 -16
- data/lib/ohai/plugins/linux/platform.rb +4 -10
- data/lib/ohai/plugins/linux/sessions.rb +2 -1
- data/lib/ohai/plugins/linux/virtualization.rb +53 -31
- data/lib/ohai/plugins/lua.rb +1 -1
- data/lib/ohai/plugins/mono.rb +2 -2
- data/lib/ohai/plugins/network.rb +11 -11
- data/lib/ohai/plugins/nodejs.rb +1 -1
- data/lib/ohai/plugins/ohai.rb +0 -2
- data/lib/ohai/plugins/openstack.rb +7 -10
- data/lib/ohai/plugins/packages.rb +1 -1
- data/lib/ohai/plugins/passwd.rb +1 -0
- 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 +5 -5
- data/lib/ohai/plugins/root_group.rb +6 -9
- data/lib/ohai/plugins/ruby.rb +2 -2
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/scala.rb +1 -1
- data/lib/ohai/plugins/scaleway.rb +56 -0
- data/lib/ohai/plugins/shard.rb +1 -0
- data/lib/ohai/plugins/softlayer.rb +2 -2
- data/lib/ohai/plugins/solaris2/cpu.rb +1 -1
- data/lib/ohai/plugins/solaris2/dmi.rb +13 -13
- data/lib/ohai/plugins/solaris2/network.rb +6 -6
- data/lib/ohai/plugins/solaris2/platform.rb +2 -2
- data/lib/ohai/plugins/ssh_host_key.rb +7 -7
- data/lib/ohai/plugins/uptime.rb +2 -7
- data/lib/ohai/plugins/virtualbox.rb +1 -1
- data/lib/ohai/plugins/vmware.rb +2 -2
- data/lib/ohai/plugins/windows/cpu.rb +2 -16
- data/lib/ohai/plugins/windows/network.rb +4 -2
- data/lib/ohai/plugins/zpools.rb +3 -3
- data/lib/ohai/provides_map.rb +1 -1
- data/lib/ohai/runner.rb +11 -14
- data/lib/ohai/system.rb +8 -71
- data/lib/ohai/util/file_helper.rb +2 -2
- data/lib/ohai/util/win32/group_helper.rb +0 -2
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +6 -5
- data/spec/functional/plugins/root_group_spec.rb +2 -2
- data/spec/functional/plugins/windows/uptime_spec.rb +0 -29
- data/spec/unit/dsl/plugin_spec.rb +14 -46
- data/spec/unit/loader_spec.rb +8 -70
- data/spec/unit/mixin/azure_metadata_spec.rb +9 -4
- data/spec/unit/mixin/command_spec.rb +11 -8
- data/spec/unit/mixin/ec2_metadata_spec.rb +5 -0
- data/spec/unit/mixin/softlayer_metadata_spec.rb +6 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +10 -10
- data/spec/unit/plugins/aix/network_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/cloud_spec.rb +0 -12
- data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
- data/spec/unit/plugins/darwin/filesystem_spec.rb +1 -6
- data/spec/unit/plugins/darwin/hardware_spec.rb +1 -1
- data/spec/unit/plugins/darwin/virtualization_spec.rb +8 -0
- data/spec/unit/plugins/dmi_spec.rb +17 -25
- data/spec/unit/plugins/docker_spec.rb +100 -0
- data/spec/unit/plugins/fail_spec.rb +3 -58
- data/spec/unit/plugins/haskell_spec.rb +1 -1
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/kernel_spec.rb +0 -52
- data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
- data/spec/unit/plugins/linux/filesystem_spec.rb +2 -7
- data/spec/unit/plugins/linux/lsb_spec.rb +5 -5
- data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
- data/spec/unit/plugins/linux/machineid_spec.rb +5 -5
- data/spec/unit/plugins/linux/network_spec.rb +16 -16
- data/spec/unit/plugins/linux/platform_spec.rb +1 -17
- data/spec/unit/plugins/linux/virtualization_spec.rb +21 -1
- data/spec/unit/plugins/network_spec.rb +58 -58
- data/spec/unit/plugins/openstack_spec.rb +5 -24
- data/spec/unit/plugins/rackspace_spec.rb +6 -6
- data/spec/unit/plugins/root_group_spec.rb +1 -1
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/rust_spec.rb +1 -1
- data/spec/unit/plugins/scala_spec.rb +1 -1
- data/spec/unit/plugins/scaleway_spec.rb +91 -0
- data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/platform_spec.rb +2 -2
- data/spec/unit/plugins/ssh_host_keys_spec.rb +8 -8
- data/spec/unit/plugins/sysconf_spec.rb +1 -0
- data/spec/unit/plugins/windows/kernel_spec.rb +79 -0
- data/spec/unit/plugins/windows/uptime_spec.rb +8 -58
- data/spec/unit/provides_map_spec.rb +4 -4
- data/spec/unit/runner_spec.rb +15 -54
- data/spec/unit/system_spec.rb +35 -348
- data/spec/unit/util/file_helper_spec.rb +2 -0
- metadata +28 -28
- data/lib/ohai/dsl/plugin/versionvi.rb +0 -61
- data/lib/ohai/plugins/bsd/filesystem2.rb +0 -121
- data/lib/ohai/plugins/ip_scopes.rb +0 -67
- data/lib/ohai/plugins/virtualization.rb +0 -83
- data/spec/data/plugins/messages.rb +0 -8
- data/spec/data/plugins/v6message.rb +0 -2
- data/spec/unit/plugins/bsd/filesystem2_spec.rb +0 -126
- data/spec/unit/plugins/ip_scopes_spec.rb +0 -139
@@ -458,22 +458,6 @@ OS_RELEASE
|
|
458
458
|
expect(@plugin[:platform_version].to_f).to eq(7.3)
|
459
459
|
end
|
460
460
|
|
461
|
-
it "should read the platform as amazon and version as 2 on the RC release" do
|
462
|
-
expect(File).to receive(:read).with("/etc/redhat-release").and_return("Amazon Linux release 2 (2017.12) LTS Release Candidate")
|
463
|
-
@plugin.run
|
464
|
-
expect(@plugin[:platform]).to eq("amazon")
|
465
|
-
expect(@plugin[:platform_family]).to eq("amazon")
|
466
|
-
expect(@plugin[:platform_version].to_f).to eq(2)
|
467
|
-
end
|
468
|
-
|
469
|
-
it "should read the platform as amazon and version as 2 on the final release" do
|
470
|
-
expect(File).to receive(:read).with("/etc/redhat-release").and_return("Amazon Linux 2")
|
471
|
-
@plugin.run
|
472
|
-
expect(@plugin[:platform]).to eq("amazon")
|
473
|
-
expect(@plugin[:platform_family]).to eq("amazon")
|
474
|
-
expect(@plugin[:platform_version].to_f).to eq(2)
|
475
|
-
end
|
476
|
-
|
477
461
|
# https://github.com/chef/ohai/issues/560
|
478
462
|
# Issue is seen on EL7, so that's what we're testing.
|
479
463
|
context "on versions that have /etc/os-release" do
|
@@ -727,7 +711,7 @@ OS_RELEASE
|
|
727
711
|
|
728
712
|
it "correctly detects SLES15" do
|
729
713
|
@plugin.run
|
730
|
-
expect(@plugin[:platform]).to eq("
|
714
|
+
expect(@plugin[:platform]).to eq("sles")
|
731
715
|
expect(@plugin[:platform_version]).to eq("15")
|
732
716
|
expect(@plugin[:platform_family]).to eq("suse")
|
733
717
|
end
|
@@ -40,11 +40,13 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
40
40
|
allow(File).to receive(:exist?).with("/sys/devices/virtual/misc/kvm").and_return(false)
|
41
41
|
allow(File).to receive(:exist?).with("/dev/lxd/sock").and_return(false)
|
42
42
|
allow(File).to receive(:exist?).with("/var/lib/lxd/devlxd").and_return(false)
|
43
|
+
allow(File).to receive(:exist?).with("/var/snap/lxd/common/lxd/devlxd").and_return(false)
|
43
44
|
allow(File).to receive(:exist?).with("/proc/1/environ").and_return(false)
|
44
45
|
|
45
46
|
# default the which wrappers to nil
|
46
47
|
allow(plugin).to receive(:which).with("lxc-version").and_return(nil)
|
47
48
|
allow(plugin).to receive(:which).with("lxc-start").and_return(nil)
|
49
|
+
allow(plugin).to receive(:which).with("docker").and_return(nil)
|
48
50
|
allow(plugin).to receive(:nova_exists?).and_return(false)
|
49
51
|
end
|
50
52
|
|
@@ -85,6 +87,16 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
90
|
+
describe "when we are checking for docker" do
|
91
|
+
it "sets docker host if docker binary exists" do
|
92
|
+
allow(plugin).to receive(:which).with("docker").and_return(true)
|
93
|
+
plugin.run
|
94
|
+
expect(plugin[:virtualization][:system]).to eq("docker")
|
95
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
96
|
+
expect(plugin[:virtualization][:systems][:docker]).to eq("host")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
88
100
|
describe "when we are checking for openstack" do
|
89
101
|
it "sets openstack host if nova binary exists" do
|
90
102
|
allow(plugin).to receive(:nova_exists?).and_return("/usr/bin/nova")
|
@@ -495,13 +507,21 @@ VEERTU
|
|
495
507
|
expect(plugin[:virtualization][:role]).to eq("guest")
|
496
508
|
end
|
497
509
|
|
498
|
-
it "
|
510
|
+
it "sets lxd host if /var/lib/lxd/devlxd exists" do
|
499
511
|
expect(File).to receive(:exist?).with("/var/lib/lxd/devlxd").and_return(true)
|
500
512
|
|
501
513
|
plugin.run
|
502
514
|
expect(plugin[:virtualization][:system]).to eq("lxd")
|
503
515
|
expect(plugin[:virtualization][:role]).to eq("host")
|
504
516
|
end
|
517
|
+
|
518
|
+
it "sets lxd host if /var/snap/lxd/common/lxd/devlxd exists" do
|
519
|
+
expect(File).to receive(:exist?).with("/var/snap/lxd/common/lxd/devlxd").and_return(true)
|
520
|
+
|
521
|
+
plugin.run
|
522
|
+
expect(plugin[:virtualization][:system]).to eq("lxd")
|
523
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
524
|
+
end
|
505
525
|
end
|
506
526
|
|
507
527
|
describe "when we are checking for lxc" do
|
@@ -20,8 +20,8 @@ require_relative "../../spec_helper.rb"
|
|
20
20
|
|
21
21
|
def it_doesnt_fail
|
22
22
|
it "doesnt fail" do
|
23
|
-
allow(
|
24
|
-
expect(
|
23
|
+
allow(@plugin.logger).to receive(:warn)
|
24
|
+
expect(@plugin.logger).not_to receive(:trace).with(/^Plugin network threw exception/)
|
25
25
|
@plugin.run
|
26
26
|
end
|
27
27
|
end
|
@@ -32,8 +32,8 @@ def it_populates_ipaddress_attributes
|
|
32
32
|
|
33
33
|
it "populates ipaddress, macaddress and ip6address" do
|
34
34
|
begin
|
35
|
-
allow(
|
36
|
-
expect(
|
35
|
+
allow(@plugin.logger).to receive(:warn)
|
36
|
+
expect(@plugin.logger).not_to receive(:trace).with(/^Plugin network threw exception/)
|
37
37
|
@plugin.run
|
38
38
|
%w{ ipaddress macaddress ip6address }.each do |attribute|
|
39
39
|
expect(@plugin).to have_key(attribute)
|
@@ -367,8 +367,8 @@ describe Ohai::System, "Network Plugin" do
|
|
367
367
|
end
|
368
368
|
|
369
369
|
it "informs about this setup" do
|
370
|
-
expect(
|
371
|
-
allow(
|
370
|
+
expect(@plugin.logger).to receive(:trace).with(/ipaddress and ip6address are set from different interfaces/)
|
371
|
+
allow(@plugin.logger).to receive(:trace)
|
372
372
|
@plugin.run
|
373
373
|
end
|
374
374
|
end
|
@@ -396,8 +396,8 @@ describe Ohai::System, "Network Plugin" do
|
|
396
396
|
end
|
397
397
|
|
398
398
|
it "informs about this setup" do
|
399
|
-
expect(
|
400
|
-
allow(
|
399
|
+
expect(@plugin.logger).to receive(:trace).with(/ipaddress and ip6address are set from different interfaces/)
|
400
|
+
allow(@plugin.logger).to receive(:trace)
|
401
401
|
@plugin.run
|
402
402
|
end
|
403
403
|
end
|
@@ -413,7 +413,7 @@ describe Ohai::System, "Network Plugin" do
|
|
413
413
|
it_populates_ipaddress_attributes
|
414
414
|
|
415
415
|
it "picks {ip,ip6,mac}address" do
|
416
|
-
allow(
|
416
|
+
allow(@plugin.logger).to receive(:warn)
|
417
417
|
@plugin.run
|
418
418
|
expect(@plugin["ipaddress"]).to eq("192.168.99.11")
|
419
419
|
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
|
@@ -421,9 +421,9 @@ describe Ohai::System, "Network Plugin" do
|
|
421
421
|
end
|
422
422
|
|
423
423
|
it "warns about this conflict" do
|
424
|
-
expect(
|
425
|
-
expect(
|
426
|
-
allow(
|
424
|
+
expect(@plugin.logger).to receive(:trace).with(/\[inet\] no ipaddress\/mask on eth1/).once
|
425
|
+
expect(@plugin.logger).to receive(:trace).with(/\[inet6\] no ipaddress\/mask on eth1/).once
|
426
|
+
allow(@plugin.logger).to receive(:trace)
|
427
427
|
@plugin.run
|
428
428
|
end
|
429
429
|
end
|
@@ -435,7 +435,7 @@ describe Ohai::System, "Network Plugin" do
|
|
435
435
|
end
|
436
436
|
|
437
437
|
it "picks {ip,ip6,mac}address" do
|
438
|
-
allow(
|
438
|
+
allow(@plugin.logger).to receive(:warn)
|
439
439
|
@plugin.run
|
440
440
|
expect(@plugin["ipaddress"]).to eq("192.168.66.33")
|
441
441
|
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
@@ -452,7 +452,7 @@ describe Ohai::System, "Network Plugin" do
|
|
452
452
|
it_doesnt_fail
|
453
453
|
|
454
454
|
it "doesn't detect {ip,ip6,mac}address" do
|
455
|
-
allow(
|
455
|
+
allow(@plugin.logger).to receive(:warn)
|
456
456
|
@plugin.run
|
457
457
|
expect(@plugin["ipaddress"]).to be_nil
|
458
458
|
expect(@plugin["macaddress"]).to be_nil
|
@@ -460,11 +460,11 @@ describe Ohai::System, "Network Plugin" do
|
|
460
460
|
end
|
461
461
|
|
462
462
|
it "warns about this conflict" do
|
463
|
-
expect(
|
464
|
-
expect(
|
465
|
-
expect(
|
466
|
-
expect(
|
467
|
-
expect(
|
463
|
+
expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
|
464
|
+
expect(@plugin.logger).to receive(:warn).with(/\[inet\] no ip address on eth0/).once
|
465
|
+
expect(@plugin.logger).to receive(:trace).with(/unable to detect ip6address/).once
|
466
|
+
expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/).twice # for each family
|
467
|
+
expect(@plugin.logger).to receive(:warn).with(/\[inet6\] no ip address on eth0/).once
|
468
468
|
@plugin.run
|
469
469
|
end
|
470
470
|
end
|
@@ -475,15 +475,15 @@ describe Ohai::System, "Network Plugin" do
|
|
475
475
|
@plugin["network"]["default_interface"] = nil
|
476
476
|
@plugin["network"]["default_inet6_gateway"] = nil
|
477
477
|
@plugin["network"]["default_inet6_interface"] = nil
|
478
|
-
@plugin["network"]["interfaces"].
|
479
|
-
|
478
|
+
@plugin["network"]["interfaces"].each_value do |val|
|
479
|
+
val["addresses"].delete_if { |k, kv| %w{inet inet6}.include? kv["family"] }
|
480
480
|
end
|
481
481
|
end
|
482
482
|
|
483
483
|
it_doesnt_fail
|
484
484
|
|
485
485
|
it "doesn't detect {ip,ip6,mac}address" do
|
486
|
-
allow(
|
486
|
+
allow(@plugin.logger).to receive(:warn)
|
487
487
|
@plugin.run
|
488
488
|
expect(@plugin["ipaddress"]).to be_nil
|
489
489
|
expect(@plugin["macaddress"]).to be_nil
|
@@ -491,9 +491,9 @@ describe Ohai::System, "Network Plugin" do
|
|
491
491
|
end
|
492
492
|
|
493
493
|
it "should warn about it" do
|
494
|
-
expect(
|
495
|
-
expect(
|
496
|
-
expect(
|
494
|
+
expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
|
495
|
+
expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/).twice # for each family
|
496
|
+
expect(@plugin.logger).to receive(:trace).with(/unable to detect ip6address/).once
|
497
497
|
@plugin.run
|
498
498
|
end
|
499
499
|
end
|
@@ -643,9 +643,9 @@ describe Ohai::System, "Network Plugin" do
|
|
643
643
|
it_populates_ipaddress_attributes
|
644
644
|
|
645
645
|
it "picks {ip,mac,ip6}address from the first interface" do
|
646
|
-
expect(
|
647
|
-
expect(
|
648
|
-
allow(
|
646
|
+
expect(@plugin.logger).to receive(:trace).with(/\[inet\] no default interface/).once
|
647
|
+
expect(@plugin.logger).to receive(:trace).with(/\[inet6\] no default interface/).once
|
648
|
+
allow(@plugin.logger).to receive(:trace)
|
649
649
|
@plugin.run
|
650
650
|
expect(@plugin["ipaddress"]).to eq("192.168.99.11")
|
651
651
|
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
|
@@ -660,15 +660,15 @@ describe Ohai::System, "Network Plugin" do
|
|
660
660
|
@plugin["network"]["default_inet6_gateway"] = nil
|
661
661
|
@plugin["network"]["default_inet6_interface"] = nil
|
662
662
|
# just changing scopes to lInK for eth0 addresses
|
663
|
-
@plugin["network"]["interfaces"]["eth0"]["addresses"].
|
663
|
+
@plugin["network"]["interfaces"]["eth0"]["addresses"].each_value { |v| v[:scope] = "lInK" if %w{inet inet6}.include? v["family"] }
|
664
664
|
end
|
665
665
|
|
666
666
|
it_populates_ipaddress_attributes
|
667
667
|
|
668
668
|
it "prefers global scope addressses to set {ip,mac,ip6}address" do
|
669
|
-
expect(
|
670
|
-
expect(
|
671
|
-
allow(
|
669
|
+
expect(@plugin.logger).to receive(:trace).with(/\[inet\] no default interface/).once
|
670
|
+
expect(@plugin.logger).to receive(:trace).with(/\[inet6\] no default interface/).once
|
671
|
+
allow(@plugin.logger).to receive(:trace)
|
672
672
|
@plugin.run
|
673
673
|
expect(@plugin["ipaddress"]).to eq("192.168.99.11")
|
674
674
|
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
|
@@ -781,37 +781,37 @@ describe Ohai::System, "Network Plugin" do
|
|
781
781
|
before do
|
782
782
|
@plugin["network"]["default_gateway"] = nil
|
783
783
|
@plugin["network"]["default_interface"] = nil
|
784
|
-
@plugin["network"]["interfaces"].
|
785
|
-
|
784
|
+
@plugin["network"]["interfaces"].each_value do |val|
|
785
|
+
val["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
|
786
786
|
end
|
787
787
|
end
|
788
788
|
|
789
789
|
it_doesnt_fail
|
790
790
|
|
791
791
|
it "can't detect ipaddress" do
|
792
|
-
allow(
|
792
|
+
allow(@plugin.logger).to receive(:warn)
|
793
793
|
@plugin.run
|
794
794
|
expect(@plugin["ipaddress"]).to be_nil
|
795
795
|
end
|
796
796
|
|
797
797
|
it "warns about not being able to set {ip,mac}address (ipv4)" do
|
798
|
-
expect(
|
799
|
-
expect(
|
800
|
-
expect(
|
801
|
-
expect(
|
798
|
+
expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
|
799
|
+
expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/) # for ipv4
|
800
|
+
expect(@plugin.logger).to receive(:trace).with(/setting macaddress to/) # for ipv6
|
801
|
+
expect(@plugin.logger).to receive(:trace).with(/\[inet6\] Using default interface eth0 and default gateway/) # for ipv6
|
802
802
|
@plugin.run
|
803
803
|
end
|
804
804
|
|
805
805
|
it "sets {ip6,mac}address" do
|
806
|
-
allow(
|
806
|
+
allow(@plugin.logger).to receive(:warn)
|
807
807
|
@plugin.run
|
808
808
|
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
|
809
809
|
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
810
810
|
end
|
811
811
|
|
812
812
|
it "informs about macaddress being set using the ipv6 setup" do
|
813
|
-
expect(
|
814
|
-
allow(
|
813
|
+
expect(@plugin.logger).to receive(:trace).with(/setting macaddress to '00:16:3E:2F:36:79'/)
|
814
|
+
allow(@plugin.logger).to receive(:trace)
|
815
815
|
@plugin.run
|
816
816
|
end
|
817
817
|
end
|
@@ -829,21 +829,21 @@ describe Ohai::System, "Network Plugin" do
|
|
829
829
|
it_doesnt_fail
|
830
830
|
|
831
831
|
it "can't detect ipaddress" do
|
832
|
-
allow(
|
832
|
+
allow(@plugin.logger).to receive(:warn)
|
833
833
|
@plugin.run
|
834
834
|
expect(@plugin["ipaddress"]).to eq("127.0.0.1")
|
835
835
|
end
|
836
836
|
|
837
837
|
it "sets {ip6,mac}address" do
|
838
|
-
allow(
|
838
|
+
allow(@plugin.logger).to receive(:warn)
|
839
839
|
@plugin.run
|
840
840
|
expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
|
841
841
|
expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
|
842
842
|
end
|
843
843
|
|
844
844
|
it "informs about macaddress being set using the ipv6 setup" do
|
845
|
-
expect(
|
846
|
-
allow(
|
845
|
+
expect(@plugin.logger).to receive(:trace).with(/setting macaddress to '00:16:3E:2F:36:79'/)
|
846
|
+
allow(@plugin.logger).to receive(:trace)
|
847
847
|
@plugin.run
|
848
848
|
end
|
849
849
|
end
|
@@ -928,9 +928,9 @@ describe Ohai::System, "Network Plugin" do
|
|
928
928
|
before do
|
929
929
|
@plugin["network"]["default_gateway"] = nil
|
930
930
|
@plugin["network"]["default_interface"] = nil
|
931
|
-
@plugin["network"]["interfaces"].
|
932
|
-
if
|
933
|
-
|
931
|
+
@plugin["network"]["interfaces"].each_value do |val|
|
932
|
+
if val.has_key? "addresses"
|
933
|
+
val["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
|
934
934
|
end
|
935
935
|
end
|
936
936
|
@plugin["ip6address"] = "3ffe:8888:9999::1"
|
@@ -950,24 +950,24 @@ describe Ohai::System, "Network Plugin" do
|
|
950
950
|
it_doesnt_fail
|
951
951
|
|
952
952
|
it "can't detect ipaddress (ipv4)" do
|
953
|
-
allow(
|
953
|
+
allow(@plugin.logger).to receive(:warn)
|
954
954
|
@plugin.run
|
955
955
|
expect(@plugin["ipaddress"]).to be_nil
|
956
956
|
end
|
957
957
|
|
958
958
|
it "takes the macaddress from ipv6" do
|
959
|
-
allow(
|
959
|
+
allow(@plugin.logger).to receive(:warn)
|
960
960
|
@plugin.run
|
961
961
|
expect(@plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
|
962
962
|
end
|
963
963
|
|
964
964
|
it "warns about not being able to set ipaddress" do
|
965
|
-
expect(
|
965
|
+
expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
|
966
966
|
@plugin.run
|
967
967
|
end
|
968
968
|
|
969
969
|
it "doesn't overwrite ip6address" do
|
970
|
-
allow(
|
970
|
+
allow(@plugin.logger).to receive(:warn)
|
971
971
|
@plugin.run
|
972
972
|
expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
|
973
973
|
end
|
@@ -1013,9 +1013,9 @@ describe Ohai::System, "Network Plugin" do
|
|
1013
1013
|
before do
|
1014
1014
|
@plugin["network"]["default_gateway"] = nil
|
1015
1015
|
@plugin["network"]["default_interface"] = nil
|
1016
|
-
@plugin["network"]["interfaces"].
|
1017
|
-
if
|
1018
|
-
|
1016
|
+
@plugin["network"]["interfaces"].each_value do |val|
|
1017
|
+
if val.has_key? "addresses"
|
1018
|
+
val["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
|
1019
1019
|
end
|
1020
1020
|
end
|
1021
1021
|
@plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
|
@@ -1025,13 +1025,13 @@ describe Ohai::System, "Network Plugin" do
|
|
1025
1025
|
it_doesnt_fail
|
1026
1026
|
|
1027
1027
|
it "can't set ipaddress" do
|
1028
|
-
allow(
|
1028
|
+
allow(@plugin.logger).to receive(:warn)
|
1029
1029
|
@plugin.run
|
1030
1030
|
expect(@plugin["ipaddress"]).to be_nil
|
1031
1031
|
end
|
1032
1032
|
|
1033
1033
|
it "doesn't overwrite {ip6,mac}address" do
|
1034
|
-
allow(
|
1034
|
+
allow(@plugin.logger).to receive(:warn)
|
1035
1035
|
@plugin.run
|
1036
1036
|
expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
|
1037
1037
|
expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
|
@@ -40,35 +40,16 @@ describe Ohai::System, "plugin openstack" do
|
|
40
40
|
allow(plugin).to receive(:can_socket_connect?).
|
41
41
|
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80).
|
42
42
|
and_return(false)
|
43
|
-
plugin[:dmi] =
|
43
|
+
plugin[:dmi] = { :system => { :all_records => [ { :Manufacturer => "OpenStack Foundation" } ] } }
|
44
44
|
plugin.run
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
{ :system => { :all_records => [ { :Manufacturer => "OpenStack Foundation" } ] } }
|
50
|
-
end
|
51
|
-
|
52
|
-
it "sets openstack attribute" do
|
53
|
-
expect(plugin[:openstack][:provider]).to eq("openstack")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "doesn't set metadata attributes" do
|
57
|
-
expect(plugin[:openstack][:instance_id]).to be_nil
|
58
|
-
end
|
47
|
+
it "sets openstack attribute" do
|
48
|
+
expect(plugin[:openstack][:provider]).to eq("openstack")
|
59
49
|
end
|
60
|
-
context "with Red Hat openstack metadata" do
|
61
|
-
let(:dmi_data) do
|
62
|
-
{ :system => { :manufacturer => "Red Hat", :product_name => "OpenStack Compute" } }
|
63
|
-
end
|
64
|
-
|
65
|
-
it "sets openstack attribute" do
|
66
|
-
expect(plugin[:openstack][:provider]).to eq("openstack")
|
67
|
-
end
|
68
50
|
|
69
|
-
|
70
|
-
|
71
|
-
end
|
51
|
+
it "doesn't set metadata attributes" do
|
52
|
+
expect(plugin[:openstack][:instance_id]).to be_nil
|
72
53
|
end
|
73
54
|
end
|
74
55
|
end
|
@@ -149,8 +149,8 @@ OUT
|
|
149
149
|
with("xenstore-ls vm-data/provider_data").
|
150
150
|
and_raise(Ohai::Exceptions::Exec)
|
151
151
|
|
152
|
-
expect(
|
153
|
-
to receive(:
|
152
|
+
expect(plugin.logger).
|
153
|
+
to receive(:trace).
|
154
154
|
with("Plugin Rackspace: Unable to find xenstore-ls, cannot capture " \
|
155
155
|
"region information for Rackspace cloud")
|
156
156
|
|
@@ -172,8 +172,8 @@ OUT
|
|
172
172
|
with("xenstore-read name").
|
173
173
|
and_raise(Ohai::Exceptions::Exec)
|
174
174
|
|
175
|
-
expect(
|
176
|
-
to receive(:
|
175
|
+
expect(plugin.logger).
|
176
|
+
to receive(:trace).
|
177
177
|
with("Plugin Rackspace: Unable to find xenstore-read, cannot capture " \
|
178
178
|
"instance ID information for Rackspace cloud")
|
179
179
|
|
@@ -276,8 +276,8 @@ OUT
|
|
276
276
|
with("xenstore-ls vm-data/networking").
|
277
277
|
and_raise(Ohai::Exceptions::Exec)
|
278
278
|
|
279
|
-
expect(
|
280
|
-
to receive(:
|
279
|
+
expect(plugin.logger).
|
280
|
+
to receive(:trace).
|
281
281
|
with("Plugin Rackspace: Unable to capture custom private networking " \
|
282
282
|
"information for Rackspace cloud")
|
283
283
|
|