ohai 13.12.6 → 14.0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -12
  3. data/README.md +7 -12
  4. data/Rakefile +16 -23
  5. data/docs/man/man1/ohai.1 +97 -0
  6. data/lib/ohai/application.rb +9 -4
  7. data/lib/ohai/common/dmi.rb +4 -16
  8. data/lib/ohai/config.rb +5 -1
  9. data/lib/ohai/dsl.rb +0 -1
  10. data/lib/ohai/dsl/plugin.rb +12 -16
  11. data/lib/ohai/dsl/plugin/versionvii.rb +17 -5
  12. data/lib/ohai/hints.rb +2 -2
  13. data/lib/ohai/loader.rb +21 -70
  14. data/lib/ohai/log.rb +1 -1
  15. data/lib/ohai/mixin/azure_metadata.rb +4 -4
  16. data/lib/ohai/mixin/command.rb +3 -3
  17. data/lib/ohai/mixin/dmi_decode.rb +0 -2
  18. data/lib/ohai/mixin/do_metadata.rb +1 -1
  19. data/lib/ohai/mixin/ec2_metadata.rb +8 -8
  20. data/lib/ohai/mixin/gce_metadata.rb +1 -5
  21. data/lib/ohai/mixin/http_helper.rb +3 -3
  22. data/lib/ohai/mixin/scaleway_metadata.rb +46 -0
  23. data/lib/ohai/mixin/softlayer_metadata.rb +3 -3
  24. data/lib/ohai/plugins/aix/filesystem.rb +1 -1
  25. data/lib/ohai/plugins/aix/memory.rb +1 -1
  26. data/lib/ohai/plugins/aix/network.rb +2 -2
  27. data/lib/ohai/plugins/aix/virtualization.rb +1 -1
  28. data/lib/ohai/plugins/azure.rb +5 -5
  29. data/lib/ohai/plugins/bsd/virtualization.rb +11 -11
  30. data/lib/ohai/plugins/c.rb +8 -8
  31. data/lib/ohai/plugins/chef.rb +2 -1
  32. data/lib/ohai/plugins/cloud.rb +0 -3
  33. data/lib/ohai/plugins/darwin/cpu.rb +2 -2
  34. data/lib/ohai/plugins/darwin/filesystem.rb +0 -2
  35. data/lib/ohai/plugins/darwin/hardware.rb +9 -3
  36. data/lib/ohai/plugins/darwin/network.rb +2 -2
  37. data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
  38. data/lib/ohai/plugins/darwin/virtualization.rb +10 -0
  39. data/lib/ohai/plugins/digital_ocean.rb +4 -4
  40. data/lib/ohai/plugins/dmi.rb +15 -14
  41. data/lib/ohai/plugins/docker.rb +57 -0
  42. data/lib/ohai/plugins/ec2.rb +11 -11
  43. data/lib/ohai/plugins/elixir.rb +1 -1
  44. data/lib/ohai/plugins/erlang.rb +2 -2
  45. data/lib/ohai/plugins/eucalyptus.rb +5 -5
  46. data/lib/ohai/plugins/gce.rb +2 -2
  47. data/lib/ohai/plugins/go.rb +1 -1
  48. data/lib/ohai/plugins/groovy.rb +1 -1
  49. data/lib/ohai/plugins/haskell.rb +4 -4
  50. data/lib/ohai/plugins/hostname.rb +6 -6
  51. data/lib/ohai/plugins/init_package.rb +1 -1
  52. data/lib/ohai/plugins/java.rb +1 -1
  53. data/lib/ohai/plugins/kernel.rb +109 -40
  54. data/lib/ohai/plugins/libvirt.rb +113 -0
  55. data/lib/ohai/plugins/linode.rb +4 -4
  56. data/lib/ohai/plugins/linux/block_device.rb +4 -4
  57. data/lib/ohai/plugins/linux/cpu.rb +3 -3
  58. data/lib/ohai/plugins/linux/filesystem.rb +4 -6
  59. data/lib/ohai/plugins/linux/lsb.rb +3 -3
  60. data/lib/ohai/plugins/linux/lspci.rb +2 -1
  61. data/lib/ohai/plugins/linux/machineid.rb +4 -4
  62. data/lib/ohai/plugins/linux/network.rb +16 -16
  63. data/lib/ohai/plugins/linux/platform.rb +4 -10
  64. data/lib/ohai/plugins/linux/sessions.rb +2 -1
  65. data/lib/ohai/plugins/linux/virtualization.rb +53 -31
  66. data/lib/ohai/plugins/lua.rb +1 -1
  67. data/lib/ohai/plugins/mono.rb +2 -2
  68. data/lib/ohai/plugins/network.rb +11 -11
  69. data/lib/ohai/plugins/nodejs.rb +1 -1
  70. data/lib/ohai/plugins/ohai.rb +0 -2
  71. data/lib/ohai/plugins/openstack.rb +7 -10
  72. data/lib/ohai/plugins/packages.rb +1 -1
  73. data/lib/ohai/plugins/passwd.rb +1 -0
  74. data/lib/ohai/plugins/perl.rb +1 -1
  75. data/lib/ohai/plugins/php.rb +1 -1
  76. data/lib/ohai/plugins/powershell.rb +1 -1
  77. data/lib/ohai/plugins/python.rb +1 -1
  78. data/lib/ohai/plugins/rackspace.rb +5 -5
  79. data/lib/ohai/plugins/root_group.rb +6 -9
  80. data/lib/ohai/plugins/ruby.rb +2 -2
  81. data/lib/ohai/plugins/rust.rb +1 -1
  82. data/lib/ohai/plugins/scala.rb +1 -1
  83. data/lib/ohai/plugins/scaleway.rb +56 -0
  84. data/lib/ohai/plugins/shard.rb +1 -0
  85. data/lib/ohai/plugins/softlayer.rb +2 -2
  86. data/lib/ohai/plugins/solaris2/cpu.rb +1 -1
  87. data/lib/ohai/plugins/solaris2/dmi.rb +13 -13
  88. data/lib/ohai/plugins/solaris2/network.rb +6 -6
  89. data/lib/ohai/plugins/solaris2/platform.rb +2 -2
  90. data/lib/ohai/plugins/ssh_host_key.rb +7 -7
  91. data/lib/ohai/plugins/uptime.rb +2 -7
  92. data/lib/ohai/plugins/virtualbox.rb +1 -1
  93. data/lib/ohai/plugins/vmware.rb +2 -2
  94. data/lib/ohai/plugins/windows/cpu.rb +2 -16
  95. data/lib/ohai/plugins/windows/network.rb +4 -2
  96. data/lib/ohai/plugins/zpools.rb +3 -3
  97. data/lib/ohai/provides_map.rb +1 -1
  98. data/lib/ohai/runner.rb +11 -14
  99. data/lib/ohai/system.rb +8 -71
  100. data/lib/ohai/util/file_helper.rb +2 -2
  101. data/lib/ohai/util/win32/group_helper.rb +0 -2
  102. data/lib/ohai/version.rb +1 -1
  103. data/ohai.gemspec +6 -5
  104. data/spec/functional/plugins/root_group_spec.rb +2 -2
  105. data/spec/functional/plugins/windows/uptime_spec.rb +0 -29
  106. data/spec/unit/dsl/plugin_spec.rb +14 -46
  107. data/spec/unit/loader_spec.rb +8 -70
  108. data/spec/unit/mixin/azure_metadata_spec.rb +9 -4
  109. data/spec/unit/mixin/command_spec.rb +11 -8
  110. data/spec/unit/mixin/ec2_metadata_spec.rb +5 -0
  111. data/spec/unit/mixin/softlayer_metadata_spec.rb +6 -1
  112. data/spec/unit/plugins/aix/filesystem_spec.rb +10 -10
  113. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  114. data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
  115. data/spec/unit/plugins/cloud_spec.rb +0 -12
  116. data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
  117. data/spec/unit/plugins/darwin/filesystem_spec.rb +1 -6
  118. data/spec/unit/plugins/darwin/hardware_spec.rb +1 -1
  119. data/spec/unit/plugins/darwin/virtualization_spec.rb +8 -0
  120. data/spec/unit/plugins/dmi_spec.rb +17 -25
  121. data/spec/unit/plugins/docker_spec.rb +100 -0
  122. data/spec/unit/plugins/fail_spec.rb +3 -58
  123. data/spec/unit/plugins/haskell_spec.rb +1 -1
  124. data/spec/unit/plugins/init_package_spec.rb +1 -1
  125. data/spec/unit/plugins/kernel_spec.rb +0 -52
  126. data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
  127. data/spec/unit/plugins/linux/filesystem_spec.rb +2 -7
  128. data/spec/unit/plugins/linux/lsb_spec.rb +5 -5
  129. data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
  130. data/spec/unit/plugins/linux/machineid_spec.rb +5 -5
  131. data/spec/unit/plugins/linux/network_spec.rb +16 -16
  132. data/spec/unit/plugins/linux/platform_spec.rb +1 -17
  133. data/spec/unit/plugins/linux/virtualization_spec.rb +21 -1
  134. data/spec/unit/plugins/network_spec.rb +58 -58
  135. data/spec/unit/plugins/openstack_spec.rb +5 -24
  136. data/spec/unit/plugins/rackspace_spec.rb +6 -6
  137. data/spec/unit/plugins/root_group_spec.rb +1 -1
  138. data/spec/unit/plugins/ruby_spec.rb +1 -1
  139. data/spec/unit/plugins/rust_spec.rb +1 -1
  140. data/spec/unit/plugins/scala_spec.rb +1 -1
  141. data/spec/unit/plugins/scaleway_spec.rb +91 -0
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
  143. data/spec/unit/plugins/solaris2/platform_spec.rb +2 -2
  144. data/spec/unit/plugins/ssh_host_keys_spec.rb +8 -8
  145. data/spec/unit/plugins/sysconf_spec.rb +1 -0
  146. data/spec/unit/plugins/windows/kernel_spec.rb +79 -0
  147. data/spec/unit/plugins/windows/uptime_spec.rb +8 -58
  148. data/spec/unit/provides_map_spec.rb +4 -4
  149. data/spec/unit/runner_spec.rb +15 -54
  150. data/spec/unit/system_spec.rb +35 -348
  151. data/spec/unit/util/file_helper_spec.rb +2 -0
  152. metadata +28 -28
  153. data/lib/ohai/dsl/plugin/versionvi.rb +0 -61
  154. data/lib/ohai/plugins/bsd/filesystem2.rb +0 -121
  155. data/lib/ohai/plugins/ip_scopes.rb +0 -67
  156. data/lib/ohai/plugins/virtualization.rb +0 -83
  157. data/spec/data/plugins/messages.rb +0 -8
  158. data/spec/data/plugins/v6message.rb +0 -2
  159. data/spec/unit/plugins/bsd/filesystem2_spec.rb +0 -126
  160. 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("suse")
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 "setx lxd host if /var/lib/lxd/devlxd exists" do
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(Ohai::Log).to receive(:warn)
24
- expect(Ohai::Log).not_to receive(:debug).with(/^Plugin network threw exception/)
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(Ohai::Log).to receive(:warn)
36
- expect(Ohai::Log).not_to receive(:debug).with(/^Plugin network threw exception/)
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(Ohai::Log).to receive(:debug).with(/ipaddress and ip6address are set from different interfaces/)
371
- allow(Ohai::Log).to receive(:debug)
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(Ohai::Log).to receive(:debug).with(/ipaddress and ip6address are set from different interfaces/)
400
- allow(Ohai::Log).to receive(:debug)
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:debug).with(/\[inet\] no ipaddress\/mask on eth1/).once
425
- expect(Ohai::Log).to receive(:debug).with(/\[inet6\] no ipaddress\/mask on eth1/).once
426
- allow(Ohai::Log).to receive(:debug)
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:warn).with(/unable to detect ipaddress/).once
464
- expect(Ohai::Log).to receive(:warn).with(/\[inet\] no ip address on eth0/).once
465
- expect(Ohai::Log).to receive(:debug).with(/unable to detect ip6address/).once
466
- expect(Ohai::Log).to receive(:debug).with(/unable to detect macaddress/).twice # for each family
467
- expect(Ohai::Log).to receive(:warn).with(/\[inet6\] no ip address on eth0/).once
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"].each do |i, iv|
479
- iv["addresses"].delete_if { |k, kv| %w{inet inet6}.include? kv["family"] }
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:warn).with(/unable to detect ipaddress/).once
495
- expect(Ohai::Log).to receive(:debug).with(/unable to detect macaddress/).twice # for each family
496
- expect(Ohai::Log).to receive(:debug).with(/unable to detect ip6address/).once
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(Ohai::Log).to receive(:debug).with(/\[inet\] no default interface/).once
647
- expect(Ohai::Log).to receive(:debug).with(/\[inet6\] no default interface/).once
648
- allow(Ohai::Log).to receive(:debug)
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"].each { |k, v| v[:scope] = "lInK" if %w{inet inet6}.include? v["family"] }
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(Ohai::Log).to receive(:debug).with(/\[inet\] no default interface/).once
670
- expect(Ohai::Log).to receive(:debug).with(/\[inet6\] no default interface/).once
671
- allow(Ohai::Log).to receive(:debug)
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"].each do |i, iv|
785
- iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:warn).with(/unable to detect ipaddress/).once
799
- expect(Ohai::Log).to receive(:debug).with(/unable to detect macaddress/) # for ipv4
800
- expect(Ohai::Log).to receive(:debug).with(/setting macaddress to/) # for ipv6
801
- expect(Ohai::Log).to receive(:debug).with(/\[inet6\] Using default interface eth0 and default gateway/) # for ipv6
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:debug).with(/setting macaddress to '00:16:3E:2F:36:79'/)
814
- allow(Ohai::Log).to receive(:debug)
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:debug).with(/setting macaddress to '00:16:3E:2F:36:79'/)
846
- allow(Ohai::Log).to receive(:debug)
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"].each do |i, iv|
932
- if iv.has_key? "addresses"
933
- iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:warn).with(/unable to detect ipaddress/).once
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(Ohai::Log).to receive(:warn)
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"].each do |i, iv|
1017
- if iv.has_key? "addresses"
1018
- iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
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(Ohai::Log).to receive(:warn)
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(Ohai::Log).to receive(:warn)
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] = dmi_data
43
+ plugin[:dmi] = { :system => { :all_records => [ { :Manufacturer => "OpenStack Foundation" } ] } }
44
44
  plugin.run
45
45
  end
46
46
 
47
- context "with normal openstack metadata" do
48
- let(:dmi_data) do
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
- it "doesn't set metadata attributes" do
70
- expect(plugin[:openstack][:instance_id]).to be_nil
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(Ohai::Log).
153
- to receive(:debug).
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(Ohai::Log).
176
- to receive(:debug).
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(Ohai::Log).
280
- to receive(:debug).
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