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
@@ -1,83 +0,0 @@
1
- #
2
- # Author:: Benjamin Black (<bb@chef.io>)
3
- # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
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
- # Note: despite the name this is really a libvirt plugin.
20
- # perhaps we'd be better off renaming it? -tsmith
21
-
22
- Ohai.plugin(:VirtualizationInfo) do
23
- %w{ uri capabilities nodeinfo domains networks storage }.each do |info|
24
- provides "virtualization/#{info}"
25
- end
26
-
27
- collect_data do
28
- unless virtualization.nil? || !(virtualization[:role].eql?("host"))
29
- begin
30
- require "libvirt" # this is the ruby-libvirt gem not the libvirt gem
31
-
32
- emu = (virtualization[:system].eql?("kvm") ? "qemu" : virtualization[:system])
33
- virtualization[:libvirt_version] = Libvirt.version(emu)[0].to_s
34
-
35
- virtconn = Libvirt.open_read_only("#{emu}:///system")
36
-
37
- virtualization[:uri] = virtconn.uri
38
- virtualization[:capabilities] = Mash.new
39
-
40
- virtualization[:nodeinfo] = Mash.new
41
- ni = virtconn.node_get_info
42
- %w{cores cpus memory mhz model nodes sockets threads}.each { |a| virtualization[:nodeinfo][a] = ni.send(a) }
43
-
44
- virtualization[:domains] = Mash.new
45
- virtconn.list_domains.each do |d|
46
- dv = virtconn.lookup_domain_by_id d
47
- virtualization[:domains][dv.name] = Mash.new
48
- virtualization[:domains][dv.name][:id] = d
49
- %w{os_type uuid}.each { |a| virtualization[:domains][dv.name][a] = dv.send(a) }
50
- %w{cpu_time max_mem memory nr_virt_cpu state}.each { |a| virtualization[:domains][dv.name][a] = dv.info.send(a) }
51
-
52
- end
53
-
54
- virtualization[:networks] = Mash.new
55
- virtconn.list_networks.each do |n|
56
- nv = virtconn.lookup_network_by_name n
57
- virtualization[:networks][n] = Mash.new
58
- %w{bridge_name uuid}.each { |a| virtualization[:networks][n][a] = nv.send(a) }
59
- end
60
-
61
- virtualization[:storage] = Mash.new
62
- virtconn.list_storage_pools.each do |pool|
63
- sp = virtconn.lookup_storage_pool_by_name pool
64
- virtualization[:storage][pool] = Mash.new
65
- %w{autostart uuid}.each { |a| virtualization[:storage][pool][a] = sp.send(a) }
66
- %w{allocation available capacity state}.each { |a| virtualization[:storage][pool][a] = sp.info.send(a) }
67
-
68
- virtualization[:storage][pool][:volumes] = Mash.new
69
- sp.list_volumes.each do |v|
70
- virtualization[:storage][pool][:volumes][v] = Mash.new
71
- sv = sp.lookup_volume_by_name v
72
- %w{key name path}.each { |a| virtualization[:storage][pool][:volumes][v][a] = sv.send(a) }
73
- %w{allocation capacity type}.each { |a| virtualization[:storage][pool][:volumes][v][a] = sv.info.send(a) }
74
- end
75
- end
76
-
77
- virtconn.close
78
- rescue LoadError => e
79
- Ohai::Log.debug("Plugin Virtualization: Can't load gem: #{e}. Cannot continue.")
80
- end
81
- end
82
- end
83
- end
@@ -1,8 +0,0 @@
1
- require_plugin 'v6message'
2
- require_plugin 'v7message'
3
-
4
- provides 'messages'
5
-
6
- messages Mash.new
7
- messages[:v6message] = v6message
8
- messages[:v7message] = v7message
@@ -1,2 +0,0 @@
1
- provides 'v6message'
2
- v6message "update me!"
@@ -1,126 +0,0 @@
1
- #
2
- # Author:: Matthew Kent (<mkent@magoazul.com>)
3
- # Author:: Tim Smith (<tsmith@chef.io>)
4
- # Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- require_relative "../../../spec_helper.rb"
21
-
22
- describe Ohai::System, "BSD filesystem2 plugin" do
23
- let(:plugin) { get_plugin("bsd/filesystem2") }
24
- before(:each) do
25
- allow(plugin).to receive(:collect_os).and_return(:freebsd)
26
-
27
- allow(plugin).to receive(:shell_out).with("df").and_return(mock_shell_out(0, "", ""))
28
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
29
- allow(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, "", ""))
30
- end
31
-
32
- describe "when gathering filesystem usage data from df" do
33
- before(:each) do
34
- @stdout = <<-DF
35
- Filesystem 1K-blocks Used Avail Capacity Mounted on
36
- /dev/ada0p2 9637788 3313504 5553264 37% /
37
- devfs 1 1 0 100% /dev
38
- DF
39
- allow(plugin).to receive(:shell_out).with("df").and_return(mock_shell_out(0, @stdout, ""))
40
-
41
- @inode_stdout = <<-DFi
42
- Filesystem 512-blocks Used Avail Capacity iused ifree %iused Mounted on
43
- /dev/ada0p2 15411832 5109256 9069632 36% 252576 790750 24% /
44
- devfs 2 2 0 100% 0 0 100% /dev
45
- DFi
46
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
47
- end
48
-
49
- it "should run df and df -iP" do
50
- expect(plugin).to receive(:shell_out).ordered.with("df").and_return(mock_shell_out(0, @stdout, ""))
51
- expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
52
- plugin.run
53
- end
54
-
55
- it "should set kb_size to value from df" do
56
- plugin.run
57
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_size]).to eq("9637788")
58
- end
59
-
60
- it "should set kb_used to value from df" do
61
- plugin.run
62
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_used]).to eq("3313504")
63
- end
64
-
65
- it "should set kb_available to value from df" do
66
- plugin.run
67
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_available]).to eq("5553264")
68
- end
69
-
70
- it "should set percent_used to value from df" do
71
- plugin.run
72
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:percent_used]).to eq("37%")
73
- end
74
-
75
- it "should set mount to value from df" do
76
- plugin.run
77
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount]).to eq("/")
78
- end
79
-
80
- it "should set total_inodes to value from df -iP" do
81
- plugin.run
82
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:total_inodes]).to eq("1043326")
83
- end
84
-
85
- it "should set inodes_used to value from df -iP" do
86
- plugin.run
87
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:inodes_used]).to eq("252576")
88
- end
89
-
90
- it "should set inodes_available to value from df -iP" do
91
- plugin.run
92
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:inodes_available]).to eq("790750")
93
- end
94
- end
95
-
96
- describe "when gathering mounted filesystem data from mount" do
97
- before(:each) do
98
- @stdout = <<-MOUNT
99
- /dev/ada0p2 on / (ufs, local, journaled soft-updates)
100
- devfs on /dev (devfs, local, multilabel)
101
- MOUNT
102
- allow(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, ""))
103
- end
104
-
105
- it "should run mount" do
106
- expect(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, ""))
107
- plugin.run
108
- end
109
-
110
- it "should set mount to value from mount" do
111
- plugin.run
112
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount]).to eq("/")
113
- end
114
-
115
- it "should set fs_type to value from mount" do
116
- plugin.run
117
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:fs_type]).to eq("ufs")
118
- end
119
-
120
- it "should set mount_options to an array of values from mount" do
121
- plugin.run
122
- expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount_options]).to eq(["local", "journaled soft-updates"])
123
- end
124
- end
125
-
126
- end
@@ -1,139 +0,0 @@
1
- #
2
- # License:: Apache License, Version 2.0
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- require_relative "../../spec_helper.rb"
18
- require "ipaddr_extensions"
19
-
20
- describe Ohai::System, "plugin ip_scopes" do
21
- let(:plugin) { get_plugin("ip_scopes") }
22
- let(:network) { Mash.new(:interfaces => interfaces) }
23
- let(:interfaces) do
24
- Hash[
25
- interface1, { :addresses => addresses1, :type => interface1_type },
26
- interface2, { :addresses => addresses2, :type => interface2_type },
27
- interface3, { :addresses => addresses3, :type => interface3_type }] end
28
- let(:interface1) { :eth0 }
29
- let(:interface2) { :eth1 }
30
- let(:interface3) { :eth2 }
31
- let(:addresses1) { {} }
32
- let(:addresses2) { {} }
33
- let(:addresses3) { {} }
34
- let(:interface1_type) { "eth" }
35
- let(:interface2_type) { "eth" }
36
- let(:interface3_type) { "eth" }
37
-
38
- before { plugin[:network] = network }
39
-
40
- if defined?(IPAddrExtensions)
41
- context "with ipaddr_extensions gem" do
42
- let(:ip1) { "10.0.0.1" }
43
- let(:ip2) { "1.2.3.4" }
44
- let(:ip3) { "fe80::8638:35ff:fe4e:dc74" }
45
-
46
- let(:addresses1) { Hash[ip1, {}] }
47
- let(:addresses2) { Hash[ip2, {}, ip3, {}] }
48
-
49
- it "adds ip_scope to each address's information hash" do
50
- plugin.run
51
- expect(plugin[:network][:interfaces][:eth0][:addresses]["10.0.0.1"][:ip_scope]).to eq("RFC1918 PRIVATE")
52
- expect(plugin[:network][:interfaces][:eth1][:addresses]["1.2.3.4"][:ip_scope]).to eq("GLOBAL UNICAST")
53
- expect(plugin[:network][:interfaces][:eth1][:addresses]["fe80::8638:35ff:fe4e:dc74"][:ip_scope]).to eq("LINK LOCAL UNICAST")
54
- end
55
-
56
- describe "privateaddress attribute" do
57
- before { plugin.run }
58
-
59
- context "when host has multiple RFC1918 ethernet addresses" do
60
- let(:ip1) { "10.0.0.1" }
61
- let(:ip2) { "192.168.1.1" }
62
- let(:interface1_type) { "eth" }
63
- let(:interface2_type) { "eth" }
64
-
65
- it "picks the last RFC1918 address" do
66
- expect(plugin[:privateaddress]).to eq("192.168.1.1")
67
- end
68
- end
69
-
70
- context "when host has virtual and ethernet RFC1918 addresses" do
71
- let(:ip1) { "10.0.0.1" }
72
- let(:ip2) { "192.168.1.1" }
73
- let(:interface1_type) { "eth" }
74
- let(:interface2_type) { "ppp" }
75
-
76
- it "picks the non-virtual address" do
77
- expect(plugin[:privateaddress]).to eq("10.0.0.1")
78
- end
79
- end
80
-
81
- context "when host has tunl" do
82
- let(:ip1) { "10.0.0.1" }
83
- let(:ip2) { "192.168.1.1" }
84
- let(:interface1_type) { "eth" }
85
- let(:interface2_type) { "tunl" }
86
-
87
- it "picks the non-virtual address" do
88
- expect(plugin[:privateaddress]).to eq("10.0.0.1")
89
- end
90
- end
91
-
92
- context "when host has docker" do
93
- let(:ip1) { "10.0.0.1" }
94
- let(:ip2) { "192.168.1.1" }
95
- let(:interface1_type) { "eth" }
96
- let(:interface2_type) { "docker" }
97
-
98
- it "picks the non-virtual address" do
99
- expect(plugin[:privateaddress]).to eq("10.0.0.1")
100
- end
101
- end
102
-
103
- context "when host only has virtual RFC1918 addresses" do
104
- let(:ip1) { "10.0.0.1" }
105
- let(:ip2) { "192.168.1.1" }
106
- let(:ip3) { "172.16.1.1" }
107
-
108
- let(:interface1_type) { "ppp" }
109
- let(:interface2_type) { "tunl" }
110
- let(:interface3_type) { "docker" }
111
-
112
- it "ignores them" do
113
- expect(plugin[:privateaddress]).to be nil
114
- end
115
- end
116
- end
117
- end
118
- end
119
-
120
- unless defined?(IPAddrExtensions)
121
- context "without the ipaddr_extensions gem" do
122
- let(:addresses1) { Hash["10.0.0.1", {}] }
123
-
124
- before do
125
- # standin for raising on `require 'ipaddr_extensions'`
126
- allow(plugin[:network][:interfaces]).to receive(:keys).and_raise(LoadError)
127
- plugin.run
128
- end
129
-
130
- it "does not add ip_scope to addresses" do
131
- expect(plugin[:network][:interfaces][:eth0][:addresses]["10.0.0.1"][:ip_scope]).to be nil
132
- end
133
-
134
- it "does not add a privateaddress attribute" do
135
- expect(plugin[:privateaddress]).to be nil
136
- end
137
- end
138
- end
139
- end