ohai 8.26.1 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +3 -4
  3. data/Rakefile +14 -0
  4. data/lib/ohai/application.rb +1 -0
  5. data/lib/ohai/config.rb +2 -88
  6. data/lib/ohai/dsl/plugin.rb +0 -4
  7. data/lib/ohai/exception.rb +0 -1
  8. data/lib/ohai/loader.rb +11 -2
  9. data/lib/ohai/log.rb +3 -1
  10. data/lib/ohai/mixin/command.rb +1 -318
  11. data/lib/ohai/mixin/do_metadata.rb +47 -0
  12. data/lib/ohai/mixin/ec2_metadata.rb +2 -29
  13. data/lib/ohai/mixin/gce_metadata.rb +0 -37
  14. data/lib/ohai/mixin/http_helper.rb +56 -0
  15. data/lib/ohai/mixin/network_constants.rb +0 -5
  16. data/lib/ohai/plugins/cloud.rb +144 -157
  17. data/lib/ohai/plugins/darwin/filesystem.rb +68 -22
  18. data/lib/ohai/plugins/digital_ocean.rb +24 -42
  19. data/lib/ohai/plugins/dmi.rb +81 -77
  20. data/lib/ohai/plugins/ec2.rb +33 -60
  21. data/lib/ohai/plugins/gce.rb +3 -1
  22. data/lib/ohai/plugins/hostname.rb +1 -16
  23. data/lib/ohai/plugins/linux/filesystem.rb +130 -81
  24. data/lib/ohai/plugins/linux/mdadm.rb +3 -45
  25. data/lib/ohai/plugins/linux/network.rb +1 -26
  26. data/lib/ohai/plugins/linux/platform.rb +4 -2
  27. data/lib/ohai/plugins/linux/virtualization.rb +1 -5
  28. data/lib/ohai/plugins/scala.rb +1 -13
  29. data/lib/ohai/plugins/solaris2/network.rb +1 -2
  30. data/lib/ohai/plugins/uptime.rb +0 -9
  31. data/lib/ohai/plugins/windows/cpu.rb +2 -1
  32. data/lib/ohai/plugins/windows/network.rb +1 -1
  33. data/lib/ohai/runner.rb +0 -5
  34. data/lib/ohai/system.rb +38 -8
  35. data/lib/ohai/version.rb +2 -2
  36. data/ohai.gemspec +1 -1
  37. data/spec/functional/application_spec.rb +0 -40
  38. data/spec/functional/plugins/powershell_spec.rb +1 -1
  39. data/spec/functional/plugins/root_group_spec.rb +1 -1
  40. data/spec/functional/plugins/windows/uptime_spec.rb +1 -1
  41. data/spec/ohai_spec.rb +1 -1
  42. data/spec/support/integration_helper.rb +17 -0
  43. data/spec/support/platform_helpers.rb +17 -0
  44. data/spec/unit/application_spec.rb +0 -1
  45. data/spec/unit/config_spec.rb +0 -111
  46. data/spec/unit/dsl/plugin_spec.rb +1 -1
  47. data/spec/unit/hints_spec.rb +1 -1
  48. data/spec/unit/loader_spec.rb +26 -1
  49. data/spec/unit/mixin/command_spec.rb +1 -69
  50. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  51. data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
  52. data/spec/unit/plugin_config_spec.rb +0 -1
  53. data/spec/unit/plugins/abort_spec.rb +1 -1
  54. data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
  55. data/spec/unit/plugins/aix/filesystem_spec.rb +2 -1
  56. data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
  57. data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
  58. data/spec/unit/plugins/aix/memory_spec.rb +1 -1
  59. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  60. data/spec/unit/plugins/aix/os_spec.rb +1 -1
  61. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  62. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  63. data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
  64. data/spec/unit/plugins/azure_spec.rb +1 -1
  65. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  66. data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
  67. data/spec/unit/plugins/c_spec.rb +1 -1
  68. data/spec/unit/plugins/chef_spec.rb +1 -2
  69. data/spec/unit/plugins/cloud_spec.rb +210 -50
  70. data/spec/unit/plugins/darwin/cpu_spec.rb +1 -1
  71. data/spec/unit/plugins/darwin/filesystem_spec.rb +62 -13
  72. data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
  73. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
  74. data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
  75. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  76. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  77. data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
  78. data/spec/unit/plugins/darwin/system_profiler_spec.rb +2 -9
  79. data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
  80. data/spec/unit/plugins/digital_ocean_spec.rb +39 -110
  81. data/spec/unit/plugins/dmi_spec.rb +1 -1
  82. data/spec/unit/plugins/ec2_spec.rb +10 -62
  83. data/spec/unit/plugins/elixir_spec.rb +1 -1
  84. data/spec/unit/plugins/erlang_spec.rb +1 -1
  85. data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
  86. data/spec/unit/plugins/fail_spec.rb +1 -1
  87. data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
  88. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
  89. data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
  90. data/spec/unit/plugins/freebsd/os_spec.rb +1 -1
  91. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
  92. data/spec/unit/plugins/gce_spec.rb +1 -1
  93. data/spec/unit/plugins/go_spec.rb +1 -1
  94. data/spec/unit/plugins/groovy_spec.rb +1 -1
  95. data/spec/unit/plugins/haskell_spec.rb +1 -1
  96. data/spec/unit/plugins/hostname_spec.rb +16 -41
  97. data/spec/unit/plugins/init_package_spec.rb +1 -1
  98. data/spec/unit/plugins/ip_scopes_spec.rb +18 -6
  99. data/spec/unit/plugins/java_spec.rb +1 -1
  100. data/spec/unit/plugins/joyent_spec.rb +17 -1
  101. data/spec/unit/plugins/kernel_spec.rb +1 -1
  102. data/spec/unit/plugins/linode_spec.rb +1 -1
  103. data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
  104. data/spec/unit/plugins/linux/cpu_spec.rb +1 -2
  105. data/spec/unit/plugins/linux/filesystem_spec.rb +207 -201
  106. data/spec/unit/plugins/linux/fips_spec.rb +1 -1
  107. data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
  108. data/spec/unit/plugins/linux/hostnamectl_spec.rb +1 -1
  109. data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
  110. data/spec/unit/plugins/linux/lsb_spec.rb +1 -1
  111. data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
  112. data/spec/unit/plugins/linux/mdadm_spec.rb +2 -68
  113. data/spec/unit/plugins/linux/memory_spec.rb +1 -1
  114. data/spec/unit/plugins/linux/network_spec.rb +3 -44
  115. data/spec/unit/plugins/linux/platform_spec.rb +4 -4
  116. data/spec/unit/plugins/linux/sessions_spec.rb +1 -1
  117. data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
  118. data/spec/unit/plugins/linux/virtualization_spec.rb +1 -28
  119. data/spec/unit/plugins/lua_spec.rb +1 -1
  120. data/spec/unit/plugins/mono_spec.rb +1 -1
  121. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
  122. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
  123. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  124. data/spec/unit/plugins/network_spec.rb +1 -1
  125. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  126. data/spec/unit/plugins/ohai_spec.rb +1 -1
  127. data/spec/unit/plugins/ohai_time_spec.rb +1 -1
  128. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
  129. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
  130. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
  131. data/spec/unit/plugins/openstack_spec.rb +2 -3
  132. data/spec/unit/plugins/os_spec.rb +1 -1
  133. data/spec/unit/plugins/packages_spec.rb +1 -1
  134. data/spec/unit/plugins/passwd_spec.rb +17 -1
  135. data/spec/unit/plugins/perl_spec.rb +1 -1
  136. data/spec/unit/plugins/php_spec.rb +1 -1
  137. data/spec/unit/plugins/platform_spec.rb +1 -1
  138. data/spec/unit/plugins/powershell_spec.rb +1 -1
  139. data/spec/unit/plugins/python_spec.rb +1 -1
  140. data/spec/unit/plugins/rackspace_spec.rb +1 -2
  141. data/spec/unit/plugins/root_group_spec.rb +2 -2
  142. data/spec/unit/plugins/ruby_spec.rb +1 -1
  143. data/spec/unit/plugins/rust_spec.rb +1 -1
  144. data/spec/unit/plugins/scala_spec.rb +3 -37
  145. data/spec/unit/plugins/shard_spec.rb +1 -1
  146. data/spec/unit/plugins/shells_spec.rb +1 -1
  147. data/spec/unit/plugins/softlayer_spec.rb +1 -1
  148. data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
  149. data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
  150. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  151. data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
  152. data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
  153. data/spec/unit/plugins/solaris2/network_spec.rb +7 -4
  154. data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
  155. data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
  156. data/spec/unit/plugins/solaris2/zpools_spec.rb +1 -1
  157. data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
  158. data/spec/unit/plugins/sysconf_spec.rb +1 -1
  159. data/spec/unit/plugins/timezone_spec.rb +1 -1
  160. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  161. data/spec/unit/plugins/vmware_spec.rb +2 -1
  162. data/spec/unit/plugins/windows/cpu_spec.rb +9 -2
  163. data/spec/unit/plugins/windows/fips_spec.rb +1 -1
  164. data/spec/unit/plugins/windows/memory_spec.rb +1 -1
  165. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  166. data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
  167. data/spec/unit/provides_map_spec.rb +1 -1
  168. data/spec/unit/runner_spec.rb +1 -1
  169. data/spec/unit/system_spec.rb +68 -76
  170. data/spec/unit/util/file_helper_spec.rb +1 -1
  171. data/spec/unit/util/ip_helper_spec.rb +1 -1
  172. metadata +6 -20
  173. data/lib/ohai/plugins/cloud_v2.rb +0 -315
  174. data/lib/ohai/plugins/darwin/filesystem2.rb +0 -107
  175. data/lib/ohai/plugins/linux/filesystem2.rb +0 -223
  176. data/lib/ohai/plugins/linux/lspci.rb +0 -76
  177. data/lib/ohai/plugins/network_listeners.rb +0 -60
  178. data/lib/ohai/plugins/sigar/cpu.rb +0 -44
  179. data/lib/ohai/plugins/sigar/filesystem.rb +0 -50
  180. data/lib/ohai/plugins/sigar/memory.rb +0 -39
  181. data/lib/ohai/plugins/sigar/network.rb +0 -168
  182. data/lib/ohai/plugins/sigar/network_route.rb +0 -64
  183. data/lib/ohai/plugins/sigar/platform.rb +0 -30
  184. data/spec/unit/plugins/cloud_v2_spec.rb +0 -389
  185. data/spec/unit/plugins/darwin/filesystem2_spec.rb +0 -139
  186. data/spec/unit/plugins/linux/filesystem2_spec.rb +0 -437
  187. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  188. data/spec/unit/plugins/sigar/network_route_spec.rb +0 -148
@@ -1,30 +0,0 @@
1
- #
2
- # Author:: Doug MacEachern <dougm@vmware.com>
3
- # Copyright:: Copyright (c) 2010 VMware, 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
- Ohai.plugin(:Platform) do
20
- provides "platform", "platform_version", "platform_family"
21
-
22
- collect_data(:hpux) do
23
- require "sigar"
24
- sys = Sigar.new.sys_info
25
-
26
- platform sys.name.downcase
27
- platform_version sys.version
28
- platform_family platform
29
- end
30
- end
@@ -1,389 +0,0 @@
1
- #
2
- # Author:: Cary Penniman (<cary@rightscale.com>)
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
19
- require "ipaddr"
20
-
21
- describe "CloudAttrs object" do
22
- before(:each) do
23
- @plugin = get_plugin("cloud_v2")
24
- end
25
-
26
- let(:cloud_node) do
27
- { "public_ipv4_addrs" => ["1.2.3.1"],
28
- "local_ipv4_addrs" => ["1.2.4.1"],
29
- "public_ipv6_addrs" => ["3ffe:505:2::1"],
30
- "local_ipv6_addrs" => ["3ffe:506:2::1"],
31
- "public_ipv4" => "1.2.3.1",
32
- "local_ipv4" => "1.2.4.1",
33
- "public_ipv6" => "3ffe:505:2::1",
34
- "local_ipv6" => "3ffe:506:2::1",
35
- "public_hostname" => "myhost.somewhere.com",
36
- "local_hostname" => "my-localhost",
37
- "provider" => "my_awesome_cloud",
38
- }
39
- end
40
-
41
- it "populates cloud mash" do
42
- @cloud_attr_obj = ::CloudAttrs.new()
43
- @cloud_attr_obj.add_ipv4_addr("1.2.3.1", :public)
44
- @cloud_attr_obj.add_ipv4_addr("1.2.4.1", :private)
45
- @cloud_attr_obj.add_ipv6_addr("3ffe:505:2::1", :public)
46
- @cloud_attr_obj.add_ipv6_addr("3ffe:506:2::1", :private)
47
- @cloud_attr_obj.public_hostname = "myhost.somewhere.com"
48
- @cloud_attr_obj.local_hostname = "my-localhost"
49
- @cloud_attr_obj.provider = "my_awesome_cloud"
50
- expect(@cloud_attr_obj.cloud_mash).to eq(cloud_node)
51
- end
52
-
53
- it "throws exception with a bad ipv4 address" do
54
- @cloud_attr_obj = ::CloudAttrs.new()
55
- expect { @cloud_attr_obj.add_ipv6_addr("somebogusstring", :public) }.to raise_error(RuntimeError)
56
- end
57
-
58
- it "throws exception with a bad ipv6 address" do
59
- @cloud_attr_obj = ::CloudAttrs.new()
60
- expect { @cloud_attr_obj.add_ipv6_addr("FEED:B0B:DEAD:BEEF", :public) }.to raise_error(RuntimeError)
61
- end
62
-
63
- it "throws exception with ipv6 address passed to ipv4" do
64
- @cloud_attr_obj = ::CloudAttrs.new()
65
- expect { @cloud_attr_obj.add_ipv4_addr("3ffe:506:2::1", :public) }.to raise_error(RuntimeError)
66
- end
67
-
68
- it "throws exception with ipv4 address passed to ipv6" do
69
- @cloud_attr_obj = ::CloudAttrs.new()
70
- expect { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.to raise_error(RuntimeError)
71
- end
72
-
73
- end
74
-
75
- describe Ohai::System, "plugin cloud" do
76
- before(:each) do
77
- @plugin = get_plugin("cloud_v2")
78
- end
79
-
80
- describe "with no cloud mashes" do
81
- it "doesn't populate the cloud data" do
82
- @plugin[:ec2] = nil
83
- @plugin[:rackspace] = nil
84
- @plugin[:eucalyptus] = nil
85
- @plugin[:linode] = nil
86
- @plugin[:azure] = nil
87
- @plugin[:gce] = nil
88
- @plugin[:digital_ocean] = nil
89
- @plugin.run
90
- expect(@plugin[:cloud_v2]).to be_nil
91
- end
92
- end
93
-
94
- describe "with EC2 mash" do
95
- before do
96
- @plugin[:ec2] = Mash.new()
97
- end
98
-
99
- it "populates cloud public ip" do
100
- @plugin[:ec2]["public_ipv4"] = "174.129.150.8"
101
- @plugin.run
102
- expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:ec2]["public_ipv4"])
103
- end
104
-
105
- it "populates cloud private ip" do
106
- @plugin[:ec2]["local_ipv4"] = "10.252.42.149"
107
- @plugin.run
108
- expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:ec2]["local_ipv4"])
109
- end
110
-
111
- it "populates cloud provider" do
112
- @plugin.run
113
- expect(@plugin[:cloud_v2][:provider]).to eq("ec2")
114
- end
115
- end
116
-
117
- describe "with GCE mash" do
118
- describe "with a public IP" do
119
- before do
120
- @plugin[:gce] = Mash.new()
121
- @plugin[:gce]["instance"] = Mash.new()
122
- @plugin[:gce]["instance"]["networkInterfaces"] = [
123
- {
124
- "accessConfigs" => [ { "externalIp" => "8.35.198.173", "type" => "ONE_TO_ONE_NAT" } ],
125
- "ip" => "10.240.0.102",
126
- "network" => "projects/foo/networks/default",
127
- },
128
- ]
129
- end
130
-
131
- it "populates cloud public ip" do
132
- @plugin.run
133
- expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq("8.35.198.173")
134
- end
135
-
136
- it "populates cloud private ip" do
137
- @plugin.run
138
- expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq("10.240.0.102")
139
- end
140
-
141
- it "populates cloud provider" do
142
- @plugin.run
143
- expect(@plugin[:cloud_v2][:provider]).to eq("gce")
144
- end
145
- end
146
-
147
- describe "with no public IP" do
148
- before do
149
- @plugin[:gce] = Mash.new()
150
- @plugin[:gce]["instance"] = Mash.new()
151
- @plugin[:gce]["instance"]["networkInterfaces"] = [
152
- {
153
- "accessConfigs" => [ { "externalIp" => "", "type" => "ONE_TO_ONE_NAT" } ],
154
- "ip" => "10.240.0.102",
155
- "network" => "projects/foo/networks/default",
156
- },
157
- ]
158
- end
159
-
160
- it "does not populate cloud public ip" do
161
- @plugin.run
162
- expect(@plugin[:cloud_v2][:public_ipv4_addrs]).to be_nil
163
- end
164
-
165
- it "populates cloud private ip" do
166
- @plugin.run
167
- expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq("10.240.0.102")
168
- end
169
-
170
- it "populates cloud provider" do
171
- @plugin.run
172
- expect(@plugin[:cloud_v2][:provider]).to eq("gce")
173
- end
174
- end
175
- end
176
-
177
- describe "with rackspace" do
178
- before do
179
- @plugin[:rackspace] = Mash.new()
180
- end
181
-
182
- it "populates cloud public ip" do
183
- @plugin[:rackspace][:public_ipv4] = "174.129.150.8"
184
- @plugin.run
185
- expect(@plugin[:cloud_v2][:public_ipv4]).to eq(@plugin[:rackspace][:public_ipv4])
186
- end
187
-
188
- it "populates cloud public ipv6" do
189
- @plugin[:rackspace][:public_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
190
- @plugin.run
191
- expect(@plugin[:cloud_v2][:public_ipv6]).to eq(@plugin[:rackspace][:public_ipv6])
192
- end
193
-
194
- it "populates cloud private ip" do
195
- @plugin[:rackspace][:local_ipv4] = "10.252.42.149"
196
- @plugin.run
197
- expect(@plugin[:cloud_v2][:local_ipv4]).to eq(@plugin[:rackspace][:local_ipv4])
198
- end
199
-
200
- it "populates cloud private ipv6" do
201
- @plugin[:rackspace][:local_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
202
- @plugin.run
203
- expect(@plugin[:cloud_v2][:local_ipv6]).to eq(@plugin[:rackspace][:local_ipv6])
204
- end
205
-
206
- it "populates first cloud public ip" do
207
- @plugin[:rackspace][:public_ipv4] = "174.129.150.8"
208
- @plugin.run
209
- expect(@plugin[:cloud_v2][:public_ipv4_addrs].first).to eq(@plugin[:rackspace][:public_ipv4])
210
- end
211
-
212
- it "populates first cloud public ip" do
213
- @plugin[:rackspace][:local_ipv4] = "174.129.150.8"
214
- @plugin.run
215
- expect(@plugin[:cloud_v2][:local_ipv4_addrs].first).to eq(@plugin[:rackspace][:local_ipv4])
216
- end
217
-
218
- it "populates cloud provider" do
219
- @plugin.run
220
- expect(@plugin[:cloud_v2][:provider]).to eq("rackspace")
221
- end
222
- end
223
-
224
- describe "with linode mash" do
225
- before do
226
- @plugin[:linode] = Mash.new()
227
- end
228
-
229
- it "populates cloud public ip" do
230
- @plugin[:linode]["public_ip"] = "174.129.150.8"
231
- @plugin.run
232
- expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:linode][:public_ip])
233
- end
234
-
235
- it "populates cloud private ip" do
236
- @plugin[:linode]["private_ip"] = "10.252.42.149"
237
- @plugin.run
238
- expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:linode][:private_ip])
239
- end
240
-
241
- it "populates first cloud public ip" do
242
- @plugin[:linode]["public_ip"] = "174.129.150.8"
243
- @plugin.run
244
- expect(@plugin[:cloud_v2][:public_ipv4_addrs].first).to eq(@plugin[:linode][:public_ip])
245
- end
246
-
247
- it "populates cloud provider" do
248
- @plugin.run
249
- expect(@plugin[:cloud_v2][:provider]).to eq("linode")
250
- end
251
- end
252
-
253
- describe "with eucalyptus mash" do
254
- before do
255
- @plugin[:eucalyptus] = Mash.new()
256
- end
257
-
258
- it "populates cloud public ip" do
259
- @plugin[:eucalyptus]["public_ipv4"] = "174.129.150.8"
260
- @plugin.run
261
- expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]["public_ipv4"])
262
- end
263
-
264
- it "populates cloud private ip" do
265
- @plugin[:eucalyptus]["local_ipv4"] = "10.252.42.149"
266
- @plugin.run
267
- expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]["local_ipv4"])
268
- end
269
-
270
- it "populates cloud provider" do
271
- @plugin.run
272
- expect(@plugin[:cloud_v2][:provider]).to eq("eucalyptus")
273
- end
274
- end
275
-
276
- describe "with Azure mash" do
277
- before do
278
- @plugin[:azure] = Mash.new()
279
- end
280
-
281
- it "populates cloud public ip" do
282
- @plugin[:azure]["public_ip"] = "174.129.150.8"
283
- @plugin.run
284
- expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:azure]["public_ip"])
285
- end
286
-
287
- it "doesn't populates cloud vm_name" do
288
- @plugin[:azure]["vm_name"] = "linux-vm"
289
- @plugin.run
290
- expect(@plugin[:cloud_v2][:vm_name]).not_to eq(@plugin[:azure]["vm_name"])
291
- end
292
-
293
- it "populates cloud public_hostname" do
294
- @plugin[:azure]["public_fqdn"] = "linux-vm-svc.cloudapp.net"
295
- @plugin.run
296
- expect(@plugin[:cloud_v2][:public_hostname]).to eq(@plugin[:azure]["public_fqdn"])
297
- end
298
-
299
- it "doesn't populate cloud public_ssh_port" do
300
- @plugin[:azure]["public_ssh_port"] = "22"
301
- @plugin.run
302
- expect(@plugin[:cloud_v2][:public_ssh_port]).to be_nil
303
- end
304
-
305
- it "should not populate cloud public_ssh_port when winrm is used" do
306
- @plugin[:azure]["public_winrm_port"] = "5985"
307
- @plugin.run
308
- expect(@plugin[:cloud_v2][:public_ssh_port]).to be_nil
309
- end
310
-
311
- it "populates cloud public_winrm_port" do
312
- @plugin[:azure]["public_winrm_port"] = "5985"
313
- @plugin.run
314
- expect(@plugin[:cloud_v2][:public_winrm_port]).to be_nil
315
- end
316
-
317
- it "populates cloud provider" do
318
- @plugin.run
319
- expect(@plugin[:cloud_v2][:provider]).to eq("azure")
320
- end
321
- end
322
-
323
- describe "with digital_ocean mash" do
324
- before do
325
- @plugin[:digital_ocean] = Mash.new
326
- @plugin[:digital_ocean][:name] = "public.example.com"
327
- @plugin[:digital_ocean][:networks] = Mash.new
328
- @plugin[:digital_ocean][:networks][:v4] = [{ "ip_address" => "1.2.3.4", "type" => "public" },
329
- { "ip_address" => "5.6.7.8", "type" => "private" }]
330
- @plugin[:digital_ocean][:networks][:v6] = [{ "ip_address" => "fe80::4240:95ff:fe47:6eee", "type" => "public" },
331
- { "ip_address" => "fdf8:f53b:82e4::53", "type" => "private" }]
332
- end
333
-
334
- before(:each) do
335
- @plugin.run
336
- end
337
-
338
- it "populates cloud public hostname" do
339
- expect(@plugin[:cloud_v2][:public_hostname]).to eq("public.example.com")
340
- end
341
-
342
- it "populates cloud local hostname" do
343
- expect(@plugin[:cloud_v2][:local_hostname]).to be_nil
344
- end
345
-
346
- it "populates cloud public_ipv4_addrs" do
347
- expect(@plugin[:cloud_v2][:public_ipv4_addrs]).to eq(@plugin[:digital_ocean][:networks][:v4].select { |ip| ip["type"] == "public" }
348
- .map { |ip| ip["ip_address"] })
349
-
350
- end
351
-
352
- it "populates cloud local_ipv4_addrs" do
353
- expect(@plugin[:cloud_v2][:local_ipv4_addrs]).to eq(@plugin[:digital_ocean][:networks][:v4].select { |ip| ip["type"] == "private" }
354
- .map { |ip| ip["ip_address"] })
355
-
356
- end
357
-
358
- it "populates cloud public_ipv4" do
359
- expect(@plugin[:cloud_v2][:public_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find { |ip| ip["type"] == "public" }["ip_address"])
360
- end
361
-
362
- it "populates cloud local_ipv4" do
363
- expect(@plugin[:cloud_v2][:local_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find { |ip| ip["type"] == "private" }["ip_address"])
364
- end
365
-
366
- it "populates cloud public_ipv6_addrs" do
367
- expect(@plugin[:cloud_v2][:public_ipv6_addrs]).to eq(@plugin[:digital_ocean][:networks][:v6].select { |ip| ip["type"] == "public" }
368
- .map { |ip| ip["ip_address"] })
369
- end
370
-
371
- it "populates cloud local_ipv6_addrs" do
372
- expect(@plugin[:cloud_v2][:local_ipv6_addrs]).to eq(@plugin[:digital_ocean][:networks][:v6].select { |ip| ip["type"] == "private" }
373
- .map { |ip| ip["ip_address"] })
374
- end
375
-
376
- it "populates cloud public_ipv6" do
377
- expect(@plugin[:cloud_v2][:public_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find { |ip| ip["type"] == "public" }["ip_address"])
378
- end
379
-
380
- it "populates cloud local_ipv6" do
381
- expect(@plugin[:cloud_v2][:local_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find { |ip| ip["type"] == "private" }["ip_address"])
382
- end
383
-
384
- it "populates cloud provider" do
385
- expect(@plugin[:cloud_v2][:provider]).to eq("digital_ocean")
386
- end
387
- end
388
-
389
- end
@@ -1,139 +0,0 @@
1
- #
2
- # Author:: Phil Dibowitz (<phil@ipom.com>)
3
- # Copyright:: Copyright (c) 2015 Facebook, 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
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
20
-
21
- describe Ohai::System, "darwin filesystem2 plugin" do
22
- let (:plugin) { get_plugin("darwin/filesystem2") }
23
- before(:each) do
24
- allow(plugin).to receive(:collect_os).and_return(:darwin)
25
-
26
- allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", ""))
27
- allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
28
- end
29
-
30
- describe "when gathering filesystem usage data from df" do
31
- before(:each) do
32
- @stdout = <<-DF
33
- Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
34
- /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
35
- devfs 385 385 0 100% 666 0 100% /dev
36
- map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
37
- map -hosts 0 0 0 100% 0 0 100% /net
38
- map -static 0 0 0 100% 0 0 100% /mobile_symbol
39
- deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
40
- DF
41
- allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, ""))
42
- end
43
-
44
- it "should run df -i" do
45
- expect(plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, ""))
46
- plugin.run
47
- end
48
-
49
- it "should set size to value from df -i" do
50
- plugin.run
51
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_size]).to eq("244277768")
52
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_used]).to eq("156848224")
53
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_available]).to eq("87173544")
54
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:percent_used]).to eq("65%")
55
- end
56
-
57
- it "should set device and mount to value from df -i" do
58
- plugin.run
59
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/")
60
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:device]).to eq("/dev/disk0s2")
61
- end
62
-
63
- it "should set inode info to value from df -i" do
64
- plugin.run
65
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:total_inodes]).to eq("61069440")
66
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:inodes_used]).to eq("39276054")
67
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:inodes_available]).to eq("21793386")
68
- end
69
- end
70
-
71
- describe "when gathering mounted filesystem data from mount" do
72
- before(:each) do
73
- @stdout = <<-MOUNT
74
- /dev/disk0s2 on / (hfs, local, journaled)
75
- devfs on /dev (devfs, local, nobrowse)
76
- map /etc/auto.direct on /mnt/vol (autofs, automounted, nobrowse)
77
- map -hosts on /net (autofs, nosuid, automounted, nobrowse)
78
- map -static on /mobile_symbol (autofs, automounted, nobrowse)
79
- deweyfs@osxfuse0 on /mnt/dewey (osxfusefs, synchronous, nobrowse)
80
- MOUNT
81
- allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
82
- end
83
-
84
- it "should run mount" do
85
- expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
86
- plugin.run
87
- end
88
-
89
- it "should set values from mount" do
90
- plugin.run
91
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/")
92
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:fs_type]).to eq("hfs")
93
- expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount_options]).to eq(%w{local journaled})
94
- end
95
- end
96
-
97
- describe "when gathering filesystem data with devices mounted more than once" do
98
- before(:each) do
99
- @dfstdout = <<-DF
100
- Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
101
- /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
102
- devfs 385 385 0 100% 666 0 100% /dev
103
- map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
104
- map -hosts 0 0 0 100% 0 0 100% /net
105
- map -static 0 0 0 100% 0 0 100% /mobile_symbol
106
- deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
107
- /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /another/mountpoint
108
- DF
109
- allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, ""))
110
- end
111
-
112
- it "should provide a devices view with all mountpoints" do
113
- plugin.run
114
- expect(plugin[:filesystem2]["by_device"]["/dev/disk0s2"][:mounts]).to eq(["/", "/another/mountpoint"])
115
- end
116
- end
117
-
118
- describe "when gathering filesystem data with double-mounts" do
119
- before(:each) do
120
- @dfstdout = <<-DF
121
- Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
122
- /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
123
- devfs 385 385 0 100% 666 0 100% /dev
124
- map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
125
- map -hosts 0 0 0 100% 0 0 100% /net
126
- map -static 0 0 0 100% 0 0 100% /mobile_symbol
127
- deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
128
- /dev/disk0s3 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt
129
- /dev/disk0s4 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt
130
- DF
131
- allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, ""))
132
- end
133
-
134
- it "should provide a mounts view with all devices" do
135
- plugin.run
136
- expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/disk0s3", "/dev/disk0s4"])
137
- end
138
- end
139
- end