ohai 8.8.1 → 8.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/README.md +1 -1
  4. data/Rakefile +6 -0
  5. data/bin/ohai +2 -2
  6. data/lib/ohai.rb +4 -4
  7. data/lib/ohai/config.rb +2 -2
  8. data/lib/ohai/dsl.rb +2 -2
  9. data/lib/ohai/dsl/plugin.rb +3 -3
  10. data/lib/ohai/dsl/plugin/versionvi.rb +3 -3
  11. data/lib/ohai/dsl/plugin/versionvii.rb +2 -2
  12. data/lib/ohai/exception.rb +2 -2
  13. data/lib/ohai/hints.rb +2 -2
  14. data/lib/ohai/loader.rb +1 -1
  15. data/lib/ohai/log.rb +2 -2
  16. data/lib/ohai/mixin/command.rb +2 -2
  17. data/lib/ohai/mixin/constant_helper.rb +2 -2
  18. data/lib/ohai/mixin/dmi_decode.rb +1 -1
  19. data/lib/ohai/mixin/ec2_metadata.rb +3 -3
  20. data/lib/ohai/mixin/network_constants.rb +4 -4
  21. data/lib/ohai/mixin/os.rb +2 -2
  22. data/lib/ohai/mixin/seconds_to_human.rb +4 -4
  23. data/lib/ohai/mixin/string.rb +4 -4
  24. data/lib/ohai/plugin_config.rb +1 -1
  25. data/lib/ohai/plugins/aix/cpu.rb +35 -29
  26. data/lib/ohai/plugins/aix/filesystem.rb +58 -40
  27. data/lib/ohai/plugins/aix/kernel.rb +3 -2
  28. data/lib/ohai/plugins/aix/memory.rb +4 -3
  29. data/lib/ohai/plugins/aix/network.rb +6 -4
  30. data/lib/ohai/plugins/aix/os.rb +30 -0
  31. data/lib/ohai/plugins/aix/platform.rb +3 -2
  32. data/lib/ohai/plugins/aix/uptime.rb +3 -2
  33. data/lib/ohai/plugins/aix/virtualization.rb +115 -5
  34. data/lib/ohai/plugins/azure.rb +1 -1
  35. data/lib/ohai/plugins/bsd/filesystem.rb +1 -1
  36. data/lib/ohai/plugins/command.rb +4 -4
  37. data/lib/ohai/plugins/darwin/cpu.rb +5 -3
  38. data/lib/ohai/plugins/darwin/filesystem.rb +4 -4
  39. data/lib/ohai/plugins/darwin/filesystem2.rb +4 -4
  40. data/lib/ohai/plugins/darwin/memory.rb +6 -5
  41. data/lib/ohai/plugins/darwin/network.rb +2 -2
  42. data/lib/ohai/plugins/darwin/platform.rb +2 -2
  43. data/lib/ohai/plugins/darwin/system_profiler.rb +2 -2
  44. data/lib/ohai/plugins/dragonflybsd/os.rb +2 -2
  45. data/lib/ohai/plugins/ec2.rb +3 -3
  46. data/lib/ohai/plugins/erlang.rb +3 -3
  47. data/lib/ohai/plugins/eucalyptus.rb +3 -3
  48. data/lib/ohai/plugins/freebsd/cpu.rb +8 -4
  49. data/lib/ohai/plugins/freebsd/os.rb +2 -2
  50. data/lib/ohai/plugins/hostname.rb +12 -4
  51. data/lib/ohai/plugins/init_package.rb +2 -8
  52. data/lib/ohai/plugins/java.rb +2 -2
  53. data/lib/ohai/plugins/kernel.rb +5 -4
  54. data/lib/ohai/plugins/keys.rb +3 -3
  55. data/lib/ohai/plugins/languages.rb +4 -4
  56. data/lib/ohai/plugins/linux/block_device.rb +3 -3
  57. data/lib/ohai/plugins/linux/cpu.rb +2 -2
  58. data/lib/ohai/plugins/linux/filesystem.rb +2 -2
  59. data/lib/ohai/plugins/linux/filesystem2.rb +3 -3
  60. data/lib/ohai/plugins/linux/lsb.rb +2 -2
  61. data/lib/ohai/plugins/linux/memory.rb +2 -2
  62. data/lib/ohai/plugins/linux/network.rb +141 -59
  63. data/lib/ohai/plugins/linux/platform.rb +6 -1
  64. data/lib/ohai/plugins/linux/virtualization.rb +1 -1
  65. data/lib/ohai/plugins/network.rb +49 -42
  66. data/lib/ohai/plugins/ohai_time.rb +4 -4
  67. data/lib/ohai/plugins/openstack.rb +2 -2
  68. data/lib/ohai/plugins/os.rb +2 -2
  69. data/lib/ohai/plugins/packages.rb +122 -0
  70. data/lib/ohai/plugins/perl.rb +5 -5
  71. data/lib/ohai/plugins/platform.rb +2 -2
  72. data/lib/ohai/plugins/powershell.rb +2 -2
  73. data/lib/ohai/plugins/ps.rb +2 -2
  74. data/lib/ohai/plugins/python.rb +1 -1
  75. data/lib/ohai/plugins/rackspace.rb +13 -0
  76. data/lib/ohai/plugins/ruby.rb +6 -6
  77. data/lib/ohai/plugins/sigar/network_route.rb +1 -1
  78. data/lib/ohai/plugins/solaris2/filesystem.rb +1 -1
  79. data/lib/ohai/plugins/solaris2/network.rb +1 -1
  80. data/lib/ohai/plugins/solaris2/platform.rb +1 -1
  81. data/lib/ohai/plugins/solaris2/virtualization.rb +5 -5
  82. data/lib/ohai/plugins/solaris2/zpools.rb +2 -2
  83. data/lib/ohai/plugins/ssh_host_key.rb +2 -2
  84. data/lib/ohai/plugins/uptime.rb +4 -4
  85. data/lib/ohai/plugins/virtualbox.rb +1 -1
  86. data/lib/ohai/plugins/virtualization.rb +7 -7
  87. data/lib/ohai/plugins/vmware.rb +1 -1
  88. data/lib/ohai/plugins/windows/filesystem.rb +1 -1
  89. data/lib/ohai/plugins/windows/network.rb +1 -1
  90. data/lib/ohai/plugins/windows/platform.rb +1 -1
  91. data/lib/ohai/plugins/windows/virtualization.rb +1 -1
  92. data/lib/ohai/provides_map.rb +3 -3
  93. data/lib/ohai/runner.rb +2 -2
  94. data/lib/ohai/system.rb +2 -2
  95. data/lib/ohai/util/file_helper.rb +1 -1
  96. data/lib/ohai/util/win32.rb +1 -1
  97. data/lib/ohai/util/win32/group_helper.rb +1 -1
  98. data/lib/ohai/version.rb +3 -3
  99. data/spec/data/plugins/dpkg-query.output +1087 -0
  100. data/spec/data/plugins/lslpp.output +49 -0
  101. data/spec/data/plugins/pkginfo.output +50 -0
  102. data/spec/data/plugins/pkglist.output +24 -0
  103. data/spec/data/plugins/rpmquery.output +388 -0
  104. data/spec/functional/application_spec.rb +1 -1
  105. data/spec/functional/loader_spec.rb +1 -1
  106. data/spec/functional/plugins/powershell_spec.rb +1 -1
  107. data/spec/functional/plugins/root_group_spec.rb +2 -2
  108. data/spec/ohai_spec.rb +6 -6
  109. data/spec/unit/application_spec.rb +1 -1
  110. data/spec/unit/config_spec.rb +1 -1
  111. data/spec/unit/dsl/plugin_spec.rb +2 -2
  112. data/spec/unit/hints_spec.rb +2 -2
  113. data/spec/unit/loader_spec.rb +2 -2
  114. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  115. data/spec/unit/plugin_config_spec.rb +1 -1
  116. data/spec/unit/plugins/aix/cpu_spec.rb +68 -40
  117. data/spec/unit/plugins/aix/filesystem_spec.rb +152 -50
  118. data/spec/unit/plugins/aix/hostname_spec.rb +5 -3
  119. data/spec/unit/plugins/aix/kernel_spec.rb +2 -1
  120. data/spec/unit/plugins/aix/memory_spec.rb +7 -5
  121. data/spec/unit/plugins/aix/network_spec.rb +17 -1
  122. data/spec/unit/plugins/aix/os_spec.rb +35 -0
  123. data/spec/unit/plugins/aix/platform_spec.rb +5 -4
  124. data/spec/unit/plugins/aix/uptime_spec.rb +2 -1
  125. data/spec/unit/plugins/aix/virtualization_spec.rb +269 -3
  126. data/spec/unit/plugins/azure_spec.rb +1 -1
  127. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  128. data/spec/unit/plugins/bsd/virtualization_spec.rb +2 -2
  129. data/spec/unit/plugins/chef_spec.rb +8 -8
  130. data/spec/unit/plugins/darwin/cpu_spec.rb +8 -3
  131. data/spec/unit/plugins/darwin/hostname_spec.rb +2 -2
  132. data/spec/unit/plugins/darwin/kernel_spec.rb +4 -4
  133. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  134. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  135. data/spec/unit/plugins/darwin/platform_spec.rb +6 -6
  136. data/spec/unit/plugins/darwin/system_profiler_output.rb +0 -1
  137. data/spec/unit/plugins/darwin/system_profiler_spec.rb +4 -4
  138. data/spec/unit/plugins/ec2_spec.rb +3 -3
  139. data/spec/unit/plugins/erlang_spec.rb +3 -3
  140. data/spec/unit/plugins/eucalyptus_spec.rb +2 -2
  141. data/spec/unit/plugins/fail_spec.rb +6 -6
  142. data/spec/unit/plugins/freebsd/cpu_spec.rb +19 -4
  143. data/spec/unit/plugins/freebsd/hostname_spec.rb +2 -2
  144. data/spec/unit/plugins/freebsd/kernel_spec.rb +4 -4
  145. data/spec/unit/plugins/freebsd/platform_spec.rb +7 -7
  146. data/spec/unit/plugins/hostname_spec.rb +2 -2
  147. data/spec/unit/plugins/init_package_spec.rb +12 -2
  148. data/spec/unit/plugins/java_spec.rb +5 -5
  149. data/spec/unit/plugins/kernel_spec.rb +4 -2
  150. data/spec/unit/plugins/linux/block_device_spec.rb +75 -0
  151. data/spec/unit/plugins/linux/cpu_spec.rb +2 -2
  152. data/spec/unit/plugins/linux/filesystem2_spec.rb +14 -14
  153. data/spec/unit/plugins/linux/filesystem_spec.rb +1 -1
  154. data/spec/unit/plugins/linux/hostname_spec.rb +2 -2
  155. data/spec/unit/plugins/linux/kernel_spec.rb +5 -5
  156. data/spec/unit/plugins/linux/lsb_spec.rb +17 -17
  157. data/spec/unit/plugins/linux/network_spec.rb +80 -11
  158. data/spec/unit/plugins/linux/platform_spec.rb +20 -1
  159. data/spec/unit/plugins/linux/uptime_spec.rb +8 -8
  160. data/spec/unit/plugins/linux/virtualization_spec.rb +1 -1
  161. data/spec/unit/plugins/lua_spec.rb +2 -2
  162. data/spec/unit/plugins/netbsd/hostname_spec.rb +2 -2
  163. data/spec/unit/plugins/netbsd/kernel_spec.rb +2 -2
  164. data/spec/unit/plugins/netbsd/platform_spec.rb +2 -2
  165. data/spec/unit/plugins/network_spec.rb +110 -37
  166. data/spec/unit/plugins/nodejs_spec.rb +2 -2
  167. data/spec/unit/plugins/ohai_spec.rb +5 -5
  168. data/spec/unit/plugins/ohai_time_spec.rb +8 -8
  169. data/spec/unit/plugins/openbsd/hostname_spec.rb +2 -2
  170. data/spec/unit/plugins/openbsd/kernel_spec.rb +4 -4
  171. data/spec/unit/plugins/openbsd/platform_spec.rb +6 -6
  172. data/spec/unit/plugins/openstack_spec.rb +2 -2
  173. data/spec/unit/plugins/os_spec.rb +11 -11
  174. data/spec/unit/plugins/packages_spec.rb +241 -0
  175. data/spec/unit/plugins/perl_spec.rb +3 -3
  176. data/spec/unit/plugins/php_spec.rb +2 -2
  177. data/spec/unit/plugins/platform_spec.rb +2 -2
  178. data/spec/unit/plugins/python_spec.rb +3 -3
  179. data/spec/unit/plugins/rackspace_spec.rb +7 -0
  180. data/spec/unit/plugins/ruby_spec.rb +3 -3
  181. data/spec/unit/plugins/sigar/network_route_spec.rb +1 -1
  182. data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
  183. data/spec/unit/plugins/solaris2/filesystem.rb +1 -1
  184. data/spec/unit/plugins/solaris2/network_spec.rb +3 -3
  185. data/spec/unit/plugins/solaris2/platform_spec.rb +5 -5
  186. data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
  187. data/spec/unit/plugins/ssh_host_keys_spec.rb +2 -2
  188. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  189. data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
  190. data/spec/unit/provides_map_spec.rb +2 -2
  191. data/spec/unit/runner_spec.rb +2 -2
  192. data/spec/unit/system_spec.rb +3 -3
  193. data/spec/unit/util/file_helper_spec.rb +1 -1
  194. metadata +13 -3
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2015 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,6 +26,7 @@ describe Ohai::System, "Linux plugin platform" do
26
26
  let(:have_redhat_release) { false }
27
27
  let(:have_gentoo_release) { false }
28
28
  let(:have_exherbo_release) { false }
29
+ let(:have_alpine_release) { false }
29
30
  let(:have_suse_release) { false }
30
31
  let(:have_arch_release) { false }
31
32
  let(:have_system_release) { false }
@@ -45,6 +46,7 @@ describe Ohai::System, "Linux plugin platform" do
45
46
  allow(File).to receive(:exist?).with("/etc/redhat-release").and_return(have_redhat_release)
46
47
  allow(File).to receive(:exist?).with("/etc/gentoo-release").and_return(have_gentoo_release)
47
48
  allow(File).to receive(:exist?).with("/etc/exherbo-release").and_return(have_exherbo_release)
49
+ allow(File).to receive(:exist?).with("/etc/alpine-release").and_return(have_alpine_release)
48
50
  allow(File).to receive(:exist?).with("/etc/SuSE-release").and_return(have_suse_release)
49
51
  allow(File).to receive(:exist?).with("/etc/arch-release").and_return(have_arch_release)
50
52
  allow(File).to receive(:exist?).with("/etc/system-release").and_return(have_system_release)
@@ -223,6 +225,23 @@ describe Ohai::System, "Linux plugin platform" do
223
225
  end
224
226
  end
225
227
 
228
+ describe "on alpine" do
229
+
230
+ let(:have_alpine_release) { true }
231
+
232
+ before(:each) do
233
+ @plugin.lsb = nil
234
+ end
235
+
236
+ it "should set platform and platform_family to alpine" do
237
+ expect(File).to receive(:read).with("/etc/alpine-release").and_return("3.2.3")
238
+ @plugin.run
239
+ expect(@plugin[:platform]).to eq("alpine")
240
+ expect(@plugin[:platform_family]).to eq("alpine")
241
+ expect(@plugin[:platform_version]).to eq('3.2.3')
242
+ end
243
+ end
244
+
226
245
  describe "on exherbo" do
227
246
 
228
247
  let(:have_exherbo_release) { true }
@@ -1,14 +1,14 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
- #
9
+ #
10
10
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
14
14
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,22 +26,22 @@ describe Ohai::System, "Linux plugin uptime" do
26
26
  @double_file = double("/proc/uptime", { :gets => "18423 989" })
27
27
  allow(File).to receive(:open).with("/proc/uptime").and_return(@double_file)
28
28
  end
29
-
29
+
30
30
  it "should set uptime_seconds to uptime" do
31
31
  @plugin.run
32
32
  expect(@plugin[:uptime_seconds]).to eq(18423)
33
33
  end
34
-
34
+
35
35
  it "should set uptime to a human readable date" do
36
36
  @plugin.run
37
37
  expect(@plugin[:uptime]).to eq("5 hours 07 minutes 03 seconds")
38
38
  end
39
-
39
+
40
40
  it "should set idletime_seconds to uptime" do
41
41
  @plugin.run
42
42
  expect(@plugin[:idletime_seconds]).to eq(989)
43
43
  end
44
-
44
+
45
45
  it "should set idletime to a human readable date" do
46
46
  @plugin.run
47
47
  expect(@plugin[:idletime]).to eq("16 minutes 29 seconds")
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Thom May (<thom@clearairturbulence.org>)
3
- # Copyright:: Copyright (c) 2009 Opscode, Inc.
3
+ # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # Author:: Doug MacEachern <dougm@vmware.com>
3
- # Author:: Theodore Nordsieck (<theo@opscode.com>)
3
+ # Author:: Theodore Nordsieck (<theo@chef.io>)
4
4
  # Copyright:: Copyright (c) 2009 VMware, Inc.
5
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
5
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
6
6
  # License:: Apache License, Version 2.0
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,8 +26,8 @@ def it_doesnt_fail
26
26
  end
27
27
  end
28
28
 
29
+ # basic sanity check that is called in all describes below
29
30
  def it_populates_ipaddress_attributes
30
-
31
31
  source = caller[0]
32
32
 
33
33
  it "populates ipaddress, macaddress and ip6address" do
@@ -43,11 +43,11 @@ def it_populates_ipaddress_attributes
43
43
  raise
44
44
  end
45
45
  end
46
-
47
46
  end
48
47
 
49
48
  describe Ohai::System, "Network Plugin" do
50
49
 
50
+ # output of network plugins on particular platforms to mock plugin runs
51
51
  basic_data = {
52
52
  "freebsd" => {
53
53
  "network" => {
@@ -57,7 +57,9 @@ describe Ohai::System, "Network Plugin" do
57
57
  "number" => "0",
58
58
  "flags" => ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"],
59
59
  "addresses" => {
60
- "00:00:24:c9:5e:b8" => {"family" => "lladdr"},
60
+ "00:00:24:c9:5e:b8" => {
61
+ "family" => "lladdr"
62
+ },
61
63
  "fe80::200:24ff:fec9:5eb8" => {
62
64
  "family" => "inet6",
63
65
  "zoneid" => "vr0",
@@ -80,7 +82,9 @@ describe Ohai::System, "Network Plugin" do
80
82
  "number" => "1",
81
83
  "flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"],
82
84
  "addresses" => {
83
- "00:00:24:c9:5e:b9" => {"family" => "lladdr"},
85
+ "00:00:24:c9:5e:b9" => {
86
+ "family" => "lladdr"
87
+ },
84
88
  "fe80::200:24ff:fec9:5eb9" => {
85
89
  "family" => "inet6",
86
90
  "zoneid" => "vr1",
@@ -94,7 +98,9 @@ describe Ohai::System, "Network Plugin" do
94
98
  "number" => "2",
95
99
  "flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"],
96
100
  "addresses" => {
97
- "00:00:24:c9:5e:ba" => {"family" => "lladdr"},
101
+ "00:00:24:c9:5e:ba" => {
102
+ "family" => "lladdr"
103
+ },
98
104
  "fe80::200:24ff:fec9:5eba" => {
99
105
  "family" => "inet6",
100
106
  "zoneid" => "vr2",
@@ -108,7 +114,9 @@ describe Ohai::System, "Network Plugin" do
108
114
  "number" => "3",
109
115
  "flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"],
110
116
  "addresses" => {
111
- "00:00:24:c9:5e:bb" => {"family" => "lladdr"},
117
+ "00:00:24:c9:5e:bb" => {
118
+ "family" => "lladdr"
119
+ },
112
120
  "fe80::200:24ff:fec9:5ebb" => {
113
121
  "family" => "inet6",
114
122
  "zoneid" => "vr3",
@@ -128,8 +136,14 @@ describe Ohai::System, "Network Plugin" do
128
136
  "number" => "0",
129
137
  "flags" => ["UP", "LOOPBACK", "RUNNING", "MULTICAST"],
130
138
  "addresses" => {
131
- "127.0.0.1" => {"family" => "inet", "netmask" => "255.0.0.0"},
132
- "::1" => {"family" => "inet6", "prefixlen" => "128"},
139
+ "127.0.0.1" => {
140
+ "family" => "inet",
141
+ "netmask" => "255.0.0.0"
142
+ },
143
+ "::1" => {
144
+ "family" => "inet6",
145
+ "prefixlen" => "128"
146
+ },
133
147
  "fe80::1" => {
134
148
  "family" => "inet6",
135
149
  "zoneid" => "lo0",
@@ -143,13 +157,18 @@ describe Ohai::System, "Network Plugin" do
143
157
  "number" => "0",
144
158
  "flags" => ["LEARNING", "DISCOVER", "AUTOEDGE", "AUTOPTP"],
145
159
  "addresses" => {
146
- "02:20:6f:d2:c4:00" => {"family"=>"lladdr"},
160
+ "02:20:6f:d2:c4:00" => {
161
+ "family"=>"lladdr"
162
+ },
147
163
  "192.168.2.1" => {
148
164
  "family" => "inet",
149
165
  "netmask" => "255.255.255.0",
150
166
  "broadcast" => "192.168.2.255"
151
167
  },
152
- "2001:470:d:cb4::1" => {"family" => "inet6", "prefixlen" => "64"},
168
+ "2001:470:d:cb4::1" => {
169
+ "family" => "inet6",
170
+ "prefixlen" => "64"
171
+ },
153
172
  "fe80::cafe:babe:dead:beef" => {
154
173
  "family" => "inet6",
155
174
  "zoneid" => "bridge0",
@@ -183,12 +202,14 @@ describe Ohai::System, "Network Plugin" do
183
202
  }
184
203
  },
185
204
  "default_gateway" => "76.91.0.1",
186
- "default_interface" => "vr0"
205
+ "default_interface" => "vr0",
206
+ "default_inet6_gateway" => "2001:470:d:cb4::2",
207
+ "default_inet6_interface" => "bridge0"
187
208
  }
188
209
  },
189
210
  "linux" => {
190
211
  "network" => {
191
- # pp Hash[node['network']] from shef to get the network data
212
+ # pp Hash[node['network']] from chef-shell to get the network data
192
213
  # have just removed the neighbour and route entries by hand
193
214
  "interfaces" => {
194
215
  "lo" => {
@@ -207,7 +228,8 @@ describe Ohai::System, "Network Plugin" do
207
228
  }
208
229
  },
209
230
  "mtu" => "16436",
210
- "encapsulation" => "Loopback"
231
+ "encapsulation" => "Loopback",
232
+ "state" => "unknown"
211
233
  },
212
234
  "eth0" => {
213
235
  "flags" => ["BROADCAST", "MULTICAST", "UP"],
@@ -218,7 +240,9 @@ describe Ohai::System, "Network Plugin" do
218
240
  "prefixlen" => "64",
219
241
  "family" => "inet6"
220
242
  },
221
- "00:16:3E:2F:36:79" => {"family" => "lladdr"},
243
+ "00:16:3E:2F:36:79" => {
244
+ "family" => "lladdr"
245
+ },
222
246
  "192.168.66.33" => {
223
247
  "scope" => "Global",
224
248
  "netmask" => "255.255.255.0",
@@ -229,7 +253,8 @@ describe Ohai::System, "Network Plugin" do
229
253
  "3ffe:1111:2222::33" => {
230
254
  "prefixlen" => "48",
231
255
  "family" => "inet6",
232
- "scope" => "Global"
256
+ "scope" => "Global",
257
+ "state" => "up"
233
258
  }
234
259
  },
235
260
  "mtu" => "1500",
@@ -245,7 +270,9 @@ describe Ohai::System, "Network Plugin" do
245
270
  "prefixlen" => "64",
246
271
  "family" => "inet6"
247
272
  },
248
- "00:16:3E:2F:36:80" => {"family" => "lladdr"},
273
+ "00:16:3E:2F:36:80" => {
274
+ "family" => "lladdr"
275
+ },
249
276
  "192.168.99.11" => {
250
277
  "scope" => "Global",
251
278
  "netmask" => "255.255.255.0",
@@ -301,14 +328,14 @@ describe Ohai::System, "Network Plugin" do
301
328
  }
302
329
  }
303
330
 
304
- describe "with linux" do
331
+ describe "on linux" do
305
332
  before(:each) do
306
333
  @plugin = get_plugin("network")
307
334
  @plugin["network"] = basic_data["linux"]["network"]
308
335
  end
309
336
 
310
337
  describe "when the linux::network plugin hasn't set any of {ip,ip6,mac}address attributes" do
311
- describe "simple setup" do
338
+ describe "simple network setup" do
312
339
  it_populates_ipaddress_attributes
313
340
 
314
341
  it "detects {ip,ip6,mac}address" do
@@ -363,10 +390,9 @@ describe Ohai::System, "Network Plugin" do
363
390
  expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
364
391
  end
365
392
 
366
- it "doesn't set macaddress, ipv4 setup is valid and has precedence over ipv6" do
367
- expect(Ohai::Log).not_to receive(:warn).with(/^unable to detect macaddress/)
393
+ it "sets macaddress to the ipv6 interface because it hadn't set one for ipv4 first" do
368
394
  @plugin.run
369
- expect(@plugin["macaddress"]).to be_nil
395
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
370
396
  end
371
397
 
372
398
  it "informs about this setup" do
@@ -393,10 +419,11 @@ describe Ohai::System, "Network Plugin" do
393
419
  expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
394
420
  expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
395
421
  end
396
-
422
+
397
423
  it "warns about this conflict" do
398
424
  expect(Ohai::Log).to receive(:debug).with(/^\[inet\] no ipaddress\/mask on eth1/).once
399
425
  expect(Ohai::Log).to receive(:debug).with(/^\[inet6\] no ipaddress\/mask on eth1/).once
426
+ allow(Ohai::Log).to receive(:debug)
400
427
  @plugin.run
401
428
  end
402
429
  end
@@ -434,9 +461,9 @@ describe Ohai::System, "Network Plugin" do
434
461
 
435
462
  it "warns about this conflict" do
436
463
  expect(Ohai::Log).to receive(:warn).with(/^unable to detect ipaddress/).once
437
- expect(Ohai::Log).to receive(:warn).with(/^unable to detect macaddress/).once
438
464
  expect(Ohai::Log).to receive(:warn).with(/^\[inet\] no ip address on eth0/).once
439
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
440
467
  expect(Ohai::Log).to receive(:warn).with(/^\[inet6\] no ip address on eth0/).once
441
468
  @plugin.run
442
469
  end
@@ -465,7 +492,7 @@ describe Ohai::System, "Network Plugin" do
465
492
 
466
493
  it "should warn about it" do
467
494
  expect(Ohai::Log).to receive(:warn).with(/^unable to detect ipaddress/).once
468
- expect(Ohai::Log).to receive(:warn).with(/^unable to detect macaddress/).once
495
+ expect(Ohai::Log).to receive(:debug).with(/^unable to detect macaddress/).twice # for each family
469
496
  expect(Ohai::Log).to receive(:debug).with(/^unable to detect ip6address/).once
470
497
  @plugin.run
471
498
  end
@@ -769,7 +796,9 @@ describe Ohai::System, "Network Plugin" do
769
796
 
770
797
  it "warns about not being able to set {ip,mac}address (ipv4)" do
771
798
  expect(Ohai::Log).to receive(:warn).with(/^unable to detect ipaddress/).once
772
- expect(Ohai::Log).to receive(:warn).with(/^unable to detect macaddress/).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
773
802
  @plugin.run
774
803
  end
775
804
 
@@ -781,14 +810,46 @@ describe Ohai::System, "Network Plugin" do
781
810
  end
782
811
 
783
812
  it "informs about macaddress being set using the ipv6 setup" do
784
- expect(Ohai::Log).to receive(:debug).with(/^macaddress set to 00:16:3E:2F:36:79 from the ipv6 setup/).once
813
+ expect(Ohai::Log).to receive(:debug).with(/^setting macaddress to '00:16:3E:2F:36:79'/)
785
814
  allow(Ohai::Log).to receive(:debug)
786
815
  @plugin.run
787
816
  end
788
817
  end
789
818
 
819
+ describe "ipv6 only with ipv4 loopback" do
820
+ before do
821
+ @plugin["network"]["default_gateway"] = nil
822
+ @plugin["network"]["default_interface"] = nil
823
+ @plugin["network"]["interfaces"].each do |i,iv|
824
+ next if i == 'lo'
825
+ iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
826
+ end
827
+ end
828
+
829
+ it_doesnt_fail
830
+
831
+ it "can't detect ipaddress" do
832
+ allow(Ohai::Log).to receive(:warn)
833
+ @plugin.run
834
+ expect(@plugin["ipaddress"]).to eq("127.0.0.1")
835
+ end
836
+
837
+ it "sets {ip6,mac}address" do
838
+ allow(Ohai::Log).to receive(:warn)
839
+ @plugin.run
840
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
841
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
842
+ end
843
+
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)
847
+ @plugin.run
848
+ end
849
+ end
790
850
  end
791
851
 
852
+ # specs using network plugin data for each mocked OS (freebsd,linux,windows)
792
853
  basic_data.keys.sort.each do |os|
793
854
  describe "the #{os}::network has already set some of the {ip,mac,ip6}address attributes" do
794
855
  before(:each) do
@@ -801,13 +862,16 @@ describe Ohai::System, "Network Plugin" do
801
862
  @plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
802
863
  @expected_results = {
803
864
  "freebsd" => {
804
- "ip6address" => "::1"
865
+ "ip6address" => "2001:470:d:cb4::1",
866
+ "macaddress" => "02:20:6f:d2:c4:00"
805
867
  },
806
868
  "linux" => {
807
- "ip6address" => "3ffe:1111:2222::33"
869
+ "ip6address" => "3ffe:1111:2222::33",
870
+ "macaddress" => "00:16:3E:2F:36:79"
808
871
  },
809
872
  "windows" => {
810
- "ip6address" => "fe80::698d:3e37:7950:b28c"
873
+ "ip6address" => "fe80::698d:3e37:7950:b28c",
874
+ "macaddress" => "00:AA:BB:CC:DD:EE"
811
875
  }
812
876
  }
813
877
  end
@@ -870,6 +934,17 @@ describe Ohai::System, "Network Plugin" do
870
934
  end
871
935
  end
872
936
  @plugin["ip6address"] = "3ffe:8888:9999::1"
937
+ @expected_results = {
938
+ "freebsd" => {
939
+ "macaddress" => "02:20:6f:d2:c4:00"
940
+ },
941
+ "linux" => {
942
+ "macaddress" => "00:16:3E:2F:36:79"
943
+ },
944
+ "windows" => {
945
+ "macaddress" => "52:54:44:66:66:02"
946
+ }
947
+ }
873
948
  end
874
949
 
875
950
  it_doesnt_fail
@@ -880,15 +955,14 @@ describe Ohai::System, "Network Plugin" do
880
955
  expect(@plugin["ipaddress"]).to be_nil
881
956
  end
882
957
 
883
- it "can't detect macaddress either" do
958
+ it "takes the macaddress from ipv6" do
884
959
  allow(Ohai::Log).to receive(:warn)
885
960
  @plugin.run
886
- expect(@plugin["macaddress"]).to be_nil
961
+ expect(@plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
887
962
  end
888
963
 
889
- it "warns about not being able to set {ip,mac}address" do
964
+ it "warns about not being able to set ipaddress" do
890
965
  expect(Ohai::Log).to receive(:warn).with(/^unable to detect ipaddress/).once
891
- expect(Ohai::Log).to receive(:warn).with(/^unable to detect macaddress/).once
892
966
  @plugin.run
893
967
  end
894
968
 
@@ -923,10 +997,10 @@ describe Ohai::System, "Network Plugin" do
923
997
 
924
998
  it_populates_ipaddress_attributes
925
999
 
926
- it "detects ipaddress and overwrite macaddress" do
1000
+ it "detects ipaddress and does not overwrite macaddress" do
927
1001
  @plugin.run
928
1002
  expect(@plugin["ipaddress"]).to eq(@expected_results[os]["ipaddress"])
929
- expect(@plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
1003
+ expect(@plugin["macaddress"]).to eq(@plugin["macaddress"])
930
1004
  end
931
1005
 
932
1006
  it "doesn't overwrite ip6address" do
@@ -990,10 +1064,9 @@ describe Ohai::System, "Network Plugin" do
990
1064
 
991
1065
  it_doesnt_fail
992
1066
 
993
- it "doesn't overwrite {ip,mac,ip6}address" do
1067
+ it "doesn't overwrite {ip,ip6}address" do
994
1068
  @plugin.run
995
1069
  expect(@plugin["ipaddress"]).to eq("10.11.12.13")
996
- expect(@plugin["macaddress"]).to eq(nil)
997
1070
  expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
998
1071
  end
999
1072
  end