ohai 7.0.0.rc.1 → 7.0.0.rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ohai/plugins/cloud.rb +2 -0
- data/lib/ohai/plugins/cloud_v2.rb +289 -0
- data/lib/ohai/plugins/freebsd/os.rb +33 -0
- data/lib/ohai/plugins/java.rb +1 -1
- data/lib/ohai/plugins/linux/virtualization.rb +28 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/cloud_spec.rb +2 -0
- data/spec/unit/plugins/cloud_v2_spec.rb +292 -0
- data/spec/unit/plugins/freebsd/os_spec.rb +33 -0
- data/spec/unit/plugins/java_spec.rb +9 -9
- data/spec/unit/plugins/linux/virtualization_spec.rb +80 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 533f13f1b7eb1ff6e7dd001f5ca234c6332db38c
|
4
|
+
data.tar.gz: 440b071fec79b90937919a22f1182e717a41234e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54ed83d812f3c567ba2da77867eedfe269d8914a200cac7922d6c7ff05a05e2ee95a27d5af6f06a26f94052bbf244ae3494f2bd682b6b746aa4f2cd1dc259c3f
|
7
|
+
data.tar.gz: b66322b8b5d3acf70e43f3efb39ae8a25da7b56cc3be84f5d2d46802908fb13bf908a9227852e51cbc7ffd876184d7e382eaf5f5d3600157e07cdcd37f6fea2b
|
data/lib/ohai/plugins/cloud.rb
CHANGED
@@ -207,7 +207,9 @@ Ohai.plugin(:Cloud) do
|
|
207
207
|
def get_azure_values
|
208
208
|
cloud[:vm_name] = azure["vm_name"]
|
209
209
|
cloud[:public_ips] << azure['public_ip']
|
210
|
+
cloud[:public_ipv4] = azure['public_ip']
|
210
211
|
cloud[:public_fqdn] = azure['public_fqdn']
|
212
|
+
cloud[:public_hostname] = azure['public_fqdn']
|
211
213
|
cloud[:public_ssh_port] = azure['public_ssh_port'] if azure['public_ssh_port']
|
212
214
|
cloud[:public_winrm_port] = azure['public_winrm_port'] if azure['public_winrm_port']
|
213
215
|
cloud[:provider] = "azure"
|
@@ -0,0 +1,289 @@
|
|
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
|
+
Ohai.plugin(:CloudV2) do
|
18
|
+
provides "cloud_v2"
|
19
|
+
|
20
|
+
depends "ec2"
|
21
|
+
depends "gce"
|
22
|
+
depends "rackspace"
|
23
|
+
depends "eucalyptus"
|
24
|
+
depends "linode"
|
25
|
+
depends "openstack"
|
26
|
+
depends "azure"
|
27
|
+
|
28
|
+
# Class to help enforce the interface exposed to node[:cloud] (OHAI-542)
|
29
|
+
#
|
30
|
+
# cloud[:provider] - (String) the cloud provider the VM is running on.
|
31
|
+
#
|
32
|
+
# cloud[:public_hostname] - (String) a fully qualified hostname
|
33
|
+
# cloud[:local_hostname] - (String) a hostname resolvable on the internal (private) network
|
34
|
+
#
|
35
|
+
# cloud[:public_ipv4_addrs] - (Array) a list of all publicly accessible IPv4 addresses
|
36
|
+
# cloud[:local_ipv4_addrs] - (Array) a list of all private IPv4 addresses
|
37
|
+
# cloud[:public_ipv4] - (String) the first public IPv4 address detected
|
38
|
+
# cloud[:local_ipv4] - (String) the first private IPv4 address detected
|
39
|
+
#
|
40
|
+
# cloud[:public_ipv6_addrs] - (Array) a list of all publicly accessible IPv6 addresses
|
41
|
+
# cloud[:local_ipv6_addrs] - (Array) a list of all private IPv6 addresses
|
42
|
+
# cloud[:public_ipv6] - (String) the first public IPv6 address detected
|
43
|
+
# cloud[:local_ipv6] - (String) the first private IPv6 address detected
|
44
|
+
#
|
45
|
+
class CloudAttrs
|
46
|
+
attr_writer :provider, :public_hostname, :local_hostname
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
@cloud = Mash.new
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_ipv4_addr(ip, accessibility)
|
53
|
+
return if ip.nil? # just skip if ip is nil
|
54
|
+
ipaddr = validate_ip_addr(ip, :ipv4)
|
55
|
+
|
56
|
+
case accessibility
|
57
|
+
when :public
|
58
|
+
@cloud[:public_ipv4_addrs] ||= Array.new
|
59
|
+
@cloud[:public_ipv4_addrs] << ipaddr.to_s
|
60
|
+
when :private
|
61
|
+
@cloud[:local_ipv4_addrs] ||= Array.new
|
62
|
+
@cloud[:local_ipv4_addrs] << ipaddr.to_s
|
63
|
+
else
|
64
|
+
raise "ERROR: in valid accessibility param of '#{accessibility}'. must be :public or :private."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_ipv6_addr(ip, accessibility)
|
69
|
+
return if ip.nil? # just skip if ip is nil
|
70
|
+
ipaddr = validate_ip_addr(ip, :ipv6)
|
71
|
+
|
72
|
+
raise "ERROR: invalid ipv6 address of '#{ip}' detected. " unless ipaddr.ipv6?
|
73
|
+
case accessibility
|
74
|
+
when :public
|
75
|
+
@cloud[:public_ipv6_addrs] ||= Array.new
|
76
|
+
@cloud[:public_ipv6_addrs] << ipaddr.to_s
|
77
|
+
when :private
|
78
|
+
@cloud[:local_ipv6_addrs] ||= Array.new
|
79
|
+
@cloud[:local_ipv6_addrs] << ipaddr.to_s
|
80
|
+
else
|
81
|
+
raise "ERROR: in valid accessibility param of '#{accessibility}'. must be :public or :private."
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def cloud_mash
|
86
|
+
@cloud[:provider] = @provider if @provider
|
87
|
+
|
88
|
+
@cloud[:public_hostname] = @public_hostname if @public_hostname
|
89
|
+
@cloud[:local_hostname] = @local_hostname if @local_hostname
|
90
|
+
|
91
|
+
@cloud[:public_ipv4] = @cloud[:public_ipv4_addrs][0] if @cloud[:public_ipv4_addrs]
|
92
|
+
@cloud[:local_ipv4] = @cloud[:local_ipv4_addrs][0] if @cloud[:local_ipv4_addrs]
|
93
|
+
|
94
|
+
@cloud[:public_ipv6] = @cloud[:public_ipv6_addrs][0] if @cloud[:public_ipv6_addrs]
|
95
|
+
@cloud[:local_ipv6] = @cloud[:local_ipv6_addrs][0] if @cloud[:local_ipv6_addrs]
|
96
|
+
|
97
|
+
# if empty, return nil
|
98
|
+
(@cloud.empty?) ? nil : @cloud
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def validate_ip_addr(ip, address_family = :ipv4)
|
104
|
+
ipaddr = ""
|
105
|
+
begin
|
106
|
+
ipaddr = IPAddr.new(ip)
|
107
|
+
raise ArgumentError, "not valid #{address_family} address" unless (address_family == :ipv4) ? ipaddr.ipv4? : ipaddr.ipv6?
|
108
|
+
rescue ArgumentError => e
|
109
|
+
raise "ERROR: the ohai 'cloud' plugin failed with an IP address of '#{ip}' : #{e.message}"
|
110
|
+
end
|
111
|
+
ipaddr
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
#---------------------------------------
|
117
|
+
# Google Compute Engine (gce)
|
118
|
+
#--------------------------------------
|
119
|
+
|
120
|
+
def on_gce?
|
121
|
+
gce != nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def get_gce_values
|
125
|
+
public_ips = gce['instance']['networkInterfaces'].collect do |interface|
|
126
|
+
if interface.has_key?('accessConfigs')
|
127
|
+
interface['accessConfigs'].collect{|ac| ac['externalIp']}
|
128
|
+
end
|
129
|
+
end.flatten.compact
|
130
|
+
|
131
|
+
private_ips = gce['instance']['networkInterfaces'].collect do |interface|
|
132
|
+
interface['ip']
|
133
|
+
end.compact
|
134
|
+
|
135
|
+
public_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :public) }
|
136
|
+
private_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :private) }
|
137
|
+
@cloud_attr_obj.local_hostname = gce['instance']['hostname']
|
138
|
+
@cloud_attr_obj.provider = "gce"
|
139
|
+
end
|
140
|
+
|
141
|
+
# ----------------------------------------
|
142
|
+
# ec2
|
143
|
+
# ----------------------------------------
|
144
|
+
|
145
|
+
# Is current cloud ec2?
|
146
|
+
#
|
147
|
+
# === Return
|
148
|
+
# true:: If ec2 Hash is defined
|
149
|
+
# false:: Otherwise
|
150
|
+
def on_ec2?
|
151
|
+
ec2 != nil
|
152
|
+
end
|
153
|
+
|
154
|
+
# Fill cloud hash with ec2 values
|
155
|
+
def get_ec2_values
|
156
|
+
@cloud_attr_obj.add_ipv4_addr(ec2['public_ipv4'], :public)
|
157
|
+
@cloud_attr_obj.add_ipv4_addr(ec2['local_ipv4'], :private)
|
158
|
+
@cloud_attr_obj.public_hostname = ec2['public_hostname']
|
159
|
+
@cloud_attr_obj.local_hostname = ec2['local_hostname']
|
160
|
+
@cloud_attr_obj.provider = "ec2"
|
161
|
+
end
|
162
|
+
|
163
|
+
# ----------------------------------------
|
164
|
+
# rackspace
|
165
|
+
# ----------------------------------------
|
166
|
+
|
167
|
+
# Is current cloud rackspace?
|
168
|
+
#
|
169
|
+
# === Return
|
170
|
+
# true:: If rackspace Hash is defined
|
171
|
+
# false:: Otherwise
|
172
|
+
def on_rackspace?
|
173
|
+
rackspace != nil
|
174
|
+
end
|
175
|
+
|
176
|
+
# Fill cloud hash with rackspace values
|
177
|
+
def get_rackspace_values
|
178
|
+
@cloud_attr_obj.add_ipv4_addr(rackspace['public_ipv4'], :public)
|
179
|
+
@cloud_attr_obj.add_ipv4_addr(rackspace['local_ipv4'], :private)
|
180
|
+
@cloud_attr_obj.add_ipv6_addr(rackspace['public_ipv6'], :public)
|
181
|
+
@cloud_attr_obj.add_ipv6_addr(rackspace['local_ipv6'], :private)
|
182
|
+
@cloud_attr_obj.public_hostname = rackspace['public_hostname']
|
183
|
+
@cloud_attr_obj.local_hostname = rackspace['local_hostname']
|
184
|
+
@cloud_attr_obj.provider = "rackspace"
|
185
|
+
end
|
186
|
+
|
187
|
+
# ----------------------------------------
|
188
|
+
# linode
|
189
|
+
# ----------------------------------------
|
190
|
+
|
191
|
+
# Is current cloud linode?
|
192
|
+
#
|
193
|
+
# === Return
|
194
|
+
# true:: If linode Hash is defined
|
195
|
+
# false:: Otherwise
|
196
|
+
def on_linode?
|
197
|
+
linode != nil
|
198
|
+
end
|
199
|
+
|
200
|
+
# Fill cloud hash with linode values
|
201
|
+
def get_linode_values
|
202
|
+
@cloud_attr_obj.add_ipv4_addr(linode['public_ip'], :public)
|
203
|
+
@cloud_attr_obj.add_ipv4_addr(linode['private_ip'], :private)
|
204
|
+
@cloud_attr_obj.public_hostname = linode['public_hostname']
|
205
|
+
@cloud_attr_obj.local_hostname = linode['local_hostname']
|
206
|
+
@cloud_attr_obj.provider = "linode"
|
207
|
+
end
|
208
|
+
|
209
|
+
# ----------------------------------------
|
210
|
+
# eucalyptus
|
211
|
+
# ----------------------------------------
|
212
|
+
|
213
|
+
# Is current cloud eucalyptus?
|
214
|
+
#
|
215
|
+
# === Return
|
216
|
+
# true:: If eucalyptus Hash is defined
|
217
|
+
# false:: Otherwise
|
218
|
+
def on_eucalyptus?
|
219
|
+
eucalyptus != nil
|
220
|
+
end
|
221
|
+
|
222
|
+
def get_eucalyptus_values
|
223
|
+
@cloud_attr_obj.add_ipv4_addr(eucalyptus['public_ipv4'], :public)
|
224
|
+
@cloud_attr_obj.add_ipv4_addr(eucalyptus['local_ipv4'], :private)
|
225
|
+
@cloud_attr_obj.public_hostname = eucalyptus['public_hostname']
|
226
|
+
@cloud_attr_obj.local_hostname = eucalyptus['local_hostname']
|
227
|
+
@cloud_attr_obj.provider = "eucalyptus"
|
228
|
+
end
|
229
|
+
|
230
|
+
# ----------------------------------------
|
231
|
+
# openstack
|
232
|
+
# ----------------------------------------
|
233
|
+
|
234
|
+
# Is current cloud openstack-based?
|
235
|
+
#
|
236
|
+
# === Return
|
237
|
+
# true:: If openstack Hash is defined
|
238
|
+
# false:: Otherwise
|
239
|
+
def on_openstack?
|
240
|
+
openstack != nil
|
241
|
+
end
|
242
|
+
|
243
|
+
# Fill cloud hash with openstack values
|
244
|
+
def get_openstack_values
|
245
|
+
@cloud_attr_obj.add_ipv4_addr(openstack['public_ipv4'], :public)
|
246
|
+
@cloud_attr_obj.add_ipv4_addr(openstack['local_ipv4'], :private)
|
247
|
+
@cloud_attr_obj.public_hostname = openstack['public_hostname']
|
248
|
+
@cloud_attr_obj.local_hostname = openstack['local_hostname']
|
249
|
+
@cloud_attr_obj.provider = "openstack"
|
250
|
+
end
|
251
|
+
|
252
|
+
# ----------------------------------------
|
253
|
+
# azure
|
254
|
+
# ----------------------------------------
|
255
|
+
|
256
|
+
# Is current cloud azure?
|
257
|
+
#
|
258
|
+
# === Return
|
259
|
+
# true:: If azure Hash is defined
|
260
|
+
# false:: Otherwise
|
261
|
+
def on_azure?
|
262
|
+
azure != nil
|
263
|
+
end
|
264
|
+
|
265
|
+
# Fill cloud hash with azure values
|
266
|
+
def get_azure_values
|
267
|
+
@cloud_attr_obj.add_ipv4_addr(azure['public_ip'], :public)
|
268
|
+
@cloud_attr_obj.add_ipv4_addr(azure['private_ip'], :private)
|
269
|
+
@cloud_attr_obj.public_hostname = azure['public_fqdn']
|
270
|
+
@cloud_attr_obj.provider = "azure"
|
271
|
+
end
|
272
|
+
|
273
|
+
collect_data do
|
274
|
+
require "ipaddr"
|
275
|
+
|
276
|
+
@cloud_attr_obj = CloudAttrs.new()
|
277
|
+
|
278
|
+
get_gce_values if on_gce?
|
279
|
+
get_ec2_values if on_ec2?
|
280
|
+
get_rackspace_values if on_rackspace?
|
281
|
+
get_linode_values if on_linode?
|
282
|
+
get_eucalyptus_values if on_eucalyptus?
|
283
|
+
get_openstack_values if on_openstack?
|
284
|
+
get_azure_values if on_azure?
|
285
|
+
|
286
|
+
# set node[:cloud] hash here
|
287
|
+
cloud_v2 @cloud_attr_obj.cloud_mash
|
288
|
+
end
|
289
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Authors:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Richard Manyanza (<liseki@nyikacraftsmen.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# Copyright:: Copyright (c) 2014 Richard Manyanza.
|
6
|
+
# License:: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ohai/mixin/os'
|
22
|
+
|
23
|
+
Ohai.plugin(:OS) do
|
24
|
+
provides "os", "os_version"
|
25
|
+
|
26
|
+
collect_data(:freebsd) do
|
27
|
+
os collect_os
|
28
|
+
|
29
|
+
# This is __FreeBSD_version. See sys/param.h or
|
30
|
+
# http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
|
31
|
+
os_version shell_out("sysctl -n kern.osreldate").stdout.split($/)[0]
|
32
|
+
end
|
33
|
+
end
|
data/lib/ohai/plugins/java.rb
CHANGED
@@ -126,5 +126,33 @@ Ohai.plugin(:Virtualization) do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
129
|
+
|
130
|
+
# Detect LXC/Docker
|
131
|
+
#
|
132
|
+
# /proc/self/cgroup will look like this inside a docker container:
|
133
|
+
# <index #>:<subsystem>:/lxc/<hexadecimal container id>
|
134
|
+
#
|
135
|
+
# /proc/self/cgroup could have a name including alpha/digit/dashes
|
136
|
+
# <index #>:<subsystem>:/lxc/<named container id>
|
137
|
+
#
|
138
|
+
# /proc/self/cgroup could have a non-lxc cgroup name indicating other uses
|
139
|
+
# of cgroups. This is probably not LXC/Docker.
|
140
|
+
# <index #>:<subsystem>:/Charlie
|
141
|
+
#
|
142
|
+
# A host which supports cgroups, and has capacity to host lxc containers,
|
143
|
+
# will show the subsystems and root (/) namespace.
|
144
|
+
# <index #>:<subsystem>:/
|
145
|
+
#
|
146
|
+
# Full notes, https://tickets.opscode.com/browse/OHAI-551
|
147
|
+
# Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
|
148
|
+
if File.exists?("/proc/self/cgroup")
|
149
|
+
if File.read("/proc/self/cgroup") =~ %r{^\d+:.+:/lxc/.+$}
|
150
|
+
virtualization[:system] = "lxc"
|
151
|
+
virtualization[:role] = "guest"
|
152
|
+
elsif File.read("/proc/self/cgroup") =~ %r{\d:.+:/$}
|
153
|
+
virtualization[:system] = "lxc"
|
154
|
+
virtualization[:role] = "host"
|
155
|
+
end
|
156
|
+
end
|
129
157
|
end
|
130
158
|
end
|
data/lib/ohai/version.rb
CHANGED
@@ -165,6 +165,7 @@ describe Ohai::System, "plugin cloud" do
|
|
165
165
|
@plugin[:azure]['public_ip'] = "174.129.150.8"
|
166
166
|
@plugin.run
|
167
167
|
@plugin[:cloud][:public_ips][0].should == @plugin[:azure]['public_ip']
|
168
|
+
@plugin[:cloud][:public_ipv4].should == @plugin[:azure]['public_ip']
|
168
169
|
end
|
169
170
|
|
170
171
|
it "populates cloud vm_name" do
|
@@ -177,6 +178,7 @@ describe Ohai::System, "plugin cloud" do
|
|
177
178
|
@plugin[:azure]['public_fqdn'] = "linux-vm-svc.cloudapp.net"
|
178
179
|
@plugin.run
|
179
180
|
@plugin[:cloud][:public_fqdn].should == @plugin[:azure]['public_fqdn']
|
181
|
+
@plugin[:cloud][:public_hostname].should == @plugin[:azure]['public_fqdn']
|
180
182
|
end
|
181
183
|
|
182
184
|
it "populates cloud public_ssh_port" do
|
@@ -0,0 +1,292 @@
|
|
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
|
+
@cloud_attr_obj.cloud_mash.should == cloud_node
|
51
|
+
end
|
52
|
+
|
53
|
+
it "throws exception with a bad ipv4 address" do
|
54
|
+
@cloud_attr_obj = ::CloudAttrs.new()
|
55
|
+
lambda { @cloud_attr_obj.add_ipv6_addr("somebogusstring", :public) }.should raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
it "throws exception with a bad ipv6 address" do
|
59
|
+
@cloud_attr_obj = ::CloudAttrs.new()
|
60
|
+
lambda { @cloud_attr_obj.add_ipv6_addr("FEED:B0B:DEAD:BEEF", :public) }.should raise_error
|
61
|
+
end
|
62
|
+
|
63
|
+
it "throws exception with ipv6 address passed to ipv4" do
|
64
|
+
@cloud_attr_obj = ::CloudAttrs.new()
|
65
|
+
lambda { @cloud_attr_obj.add_ipv4_addr("3ffe:506:2::1", :public) }.should raise_error
|
66
|
+
end
|
67
|
+
|
68
|
+
it "throws exception with ipv4 address passed to ipv6" do
|
69
|
+
@cloud_attr_obj = ::CloudAttrs.new()
|
70
|
+
lambda { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.should raise_error
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
describe Ohai::System, "plugin cloud" do
|
77
|
+
before(:each) do
|
78
|
+
@plugin = get_plugin("cloud_v2")
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "with no cloud mashes" do
|
82
|
+
it "doesn't populate the cloud data" do
|
83
|
+
@plugin[:ec2] = nil
|
84
|
+
@plugin[:rackspace] = nil
|
85
|
+
@plugin[:eucalyptus] = nil
|
86
|
+
@plugin[:linode] = nil
|
87
|
+
@plugin[:azure] = nil
|
88
|
+
@plugin[:gce] = nil
|
89
|
+
@plugin.run
|
90
|
+
@plugin[:cloud_v2].should 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
|
+
@plugin[:cloud_v2][:public_ipv4_addrs][0].should == @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
|
+
@plugin[:cloud_v2][:local_ipv4_addrs][0].should == @plugin[:ec2]['local_ipv4']
|
109
|
+
end
|
110
|
+
|
111
|
+
it "populates cloud provider" do
|
112
|
+
@plugin.run
|
113
|
+
@plugin[:cloud_v2][:provider].should == "ec2"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "with GCE mash" do
|
118
|
+
before do
|
119
|
+
@plugin[:gce] = Mash.new()
|
120
|
+
@plugin[:gce]['instance'] = Mash.new()
|
121
|
+
@plugin[:gce]['instance']['networkInterfaces'] = [
|
122
|
+
{
|
123
|
+
"accessConfigs" => [ {"externalIp" => "8.35.198.173", "type"=>"ONE_TO_ONE_NAT"} ],
|
124
|
+
"ip" => "10.240.0.102",
|
125
|
+
"network"=> "projects/foo/networks/default"
|
126
|
+
}
|
127
|
+
]
|
128
|
+
end
|
129
|
+
|
130
|
+
it "populates cloud public ip" do
|
131
|
+
@plugin.run
|
132
|
+
@plugin[:cloud_v2][:public_ipv4_addrs][0].should == "8.35.198.173"
|
133
|
+
end
|
134
|
+
|
135
|
+
it "populates cloud private ip" do
|
136
|
+
@plugin.run
|
137
|
+
@plugin[:cloud_v2][:local_ipv4_addrs][0].should == "10.240.0.102"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "populates cloud provider" do
|
141
|
+
@plugin.run
|
142
|
+
@plugin[:cloud_v2][:provider].should == "gce"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "with rackspace" do
|
147
|
+
before do
|
148
|
+
@plugin[:rackspace] = Mash.new()
|
149
|
+
end
|
150
|
+
|
151
|
+
it "populates cloud public ip" do
|
152
|
+
@plugin[:rackspace][:public_ipv4] = "174.129.150.8"
|
153
|
+
@plugin.run
|
154
|
+
@plugin[:cloud_v2][:public_ipv4].should == @plugin[:rackspace][:public_ipv4]
|
155
|
+
end
|
156
|
+
|
157
|
+
it "populates cloud public ipv6" do
|
158
|
+
@plugin[:rackspace][:public_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
|
159
|
+
@plugin.run
|
160
|
+
@plugin[:cloud_v2][:public_ipv6].should == @plugin[:rackspace][:public_ipv6]
|
161
|
+
end
|
162
|
+
|
163
|
+
it "populates cloud private ip" do
|
164
|
+
@plugin[:rackspace][:local_ipv4] = "10.252.42.149"
|
165
|
+
@plugin.run
|
166
|
+
@plugin[:cloud_v2][:local_ipv4].should == @plugin[:rackspace][:local_ipv4]
|
167
|
+
end
|
168
|
+
|
169
|
+
it "populates cloud private ipv6" do
|
170
|
+
@plugin[:rackspace][:local_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
|
171
|
+
@plugin.run
|
172
|
+
@plugin[:cloud_v2][:local_ipv6].should == @plugin[:rackspace][:local_ipv6]
|
173
|
+
end
|
174
|
+
|
175
|
+
it "populates first cloud public ip" do
|
176
|
+
@plugin[:rackspace][:public_ipv4] = "174.129.150.8"
|
177
|
+
@plugin.run
|
178
|
+
@plugin[:cloud_v2][:public_ipv4_addrs].first.should == @plugin[:rackspace][:public_ipv4]
|
179
|
+
end
|
180
|
+
|
181
|
+
it "populates first cloud public ip" do
|
182
|
+
@plugin[:rackspace][:local_ipv4] = "174.129.150.8"
|
183
|
+
@plugin.run
|
184
|
+
@plugin[:cloud_v2][:local_ipv4_addrs].first.should == @plugin[:rackspace][:local_ipv4]
|
185
|
+
end
|
186
|
+
|
187
|
+
it "populates cloud provider" do
|
188
|
+
@plugin.run
|
189
|
+
@plugin[:cloud_v2][:provider].should == "rackspace"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "with linode mash" do
|
194
|
+
before do
|
195
|
+
@plugin[:linode] = Mash.new()
|
196
|
+
end
|
197
|
+
|
198
|
+
it "populates cloud public ip" do
|
199
|
+
@plugin[:linode]['public_ip'] = "174.129.150.8"
|
200
|
+
@plugin.run
|
201
|
+
@plugin[:cloud_v2][:public_ipv4_addrs][0].should == @plugin[:linode][:public_ip]
|
202
|
+
end
|
203
|
+
|
204
|
+
it "populates cloud private ip" do
|
205
|
+
@plugin[:linode]['private_ip'] = "10.252.42.149"
|
206
|
+
@plugin.run
|
207
|
+
@plugin[:cloud_v2][:local_ipv4_addrs][0].should == @plugin[:linode][:private_ip]
|
208
|
+
end
|
209
|
+
|
210
|
+
it "populates first cloud public ip" do
|
211
|
+
@plugin[:linode]['public_ip'] = "174.129.150.8"
|
212
|
+
@plugin.run
|
213
|
+
@plugin[:cloud_v2][:public_ipv4_addrs].first.should == @plugin[:linode][:public_ip]
|
214
|
+
end
|
215
|
+
|
216
|
+
it "populates cloud provider" do
|
217
|
+
@plugin.run
|
218
|
+
@plugin[:cloud_v2][:provider].should == "linode"
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "with eucalyptus mash" do
|
223
|
+
before do
|
224
|
+
@plugin[:eucalyptus] = Mash.new()
|
225
|
+
end
|
226
|
+
|
227
|
+
it "populates cloud public ip" do
|
228
|
+
@plugin[:eucalyptus]['public_ipv4'] = "174.129.150.8"
|
229
|
+
@plugin.run
|
230
|
+
@plugin[:cloud_v2][:public_ipv4_addrs][0].should == @plugin[:eucalyptus]['public_ipv4']
|
231
|
+
end
|
232
|
+
|
233
|
+
it "populates cloud private ip" do
|
234
|
+
@plugin[:eucalyptus]['local_ipv4'] = "10.252.42.149"
|
235
|
+
@plugin.run
|
236
|
+
@plugin[:cloud_v2][:local_ipv4_addrs][0].should == @plugin[:eucalyptus]['local_ipv4']
|
237
|
+
end
|
238
|
+
|
239
|
+
it "populates cloud provider" do
|
240
|
+
@plugin.run
|
241
|
+
@plugin[:cloud_v2][:provider].should == "eucalyptus"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe "with Azure mash" do
|
246
|
+
before do
|
247
|
+
@plugin[:azure] = Mash.new()
|
248
|
+
end
|
249
|
+
|
250
|
+
it "populates cloud public ip" do
|
251
|
+
@plugin[:azure]['public_ip'] = "174.129.150.8"
|
252
|
+
@plugin.run
|
253
|
+
@plugin[:cloud_v2][:public_ipv4_addrs][0].should == @plugin[:azure]['public_ip']
|
254
|
+
end
|
255
|
+
|
256
|
+
it "doesn't populates cloud vm_name" do
|
257
|
+
@plugin[:azure]['vm_name'] = "linux-vm"
|
258
|
+
@plugin.run
|
259
|
+
@plugin[:cloud_v2][:vm_name].should_not == @plugin[:azure]['vm_name']
|
260
|
+
end
|
261
|
+
|
262
|
+
it "populates cloud public_hostname" do
|
263
|
+
@plugin[:azure]['public_fqdn'] = "linux-vm-svc.cloudapp.net"
|
264
|
+
@plugin.run
|
265
|
+
@plugin[:cloud_v2][:public_hostname].should == @plugin[:azure]['public_fqdn']
|
266
|
+
end
|
267
|
+
|
268
|
+
it "doesn't populate cloud public_ssh_port" do
|
269
|
+
@plugin[:azure]['public_ssh_port'] = "22"
|
270
|
+
@plugin.run
|
271
|
+
@plugin[:cloud_v2][:public_ssh_port].should be_nil
|
272
|
+
end
|
273
|
+
|
274
|
+
it "should not populate cloud public_ssh_port when winrm is used" do
|
275
|
+
@plugin[:azure]['public_winrm_port'] = "5985"
|
276
|
+
@plugin.run
|
277
|
+
@plugin[:cloud_v2][:public_ssh_port].should be_nil
|
278
|
+
end
|
279
|
+
|
280
|
+
it "populates cloud public_winrm_port" do
|
281
|
+
@plugin[:azure]['public_winrm_port'] = "5985"
|
282
|
+
@plugin.run
|
283
|
+
@plugin[:cloud_v2][:public_winrm_port].should be_nil
|
284
|
+
end
|
285
|
+
|
286
|
+
it "populates cloud provider" do
|
287
|
+
@plugin.run
|
288
|
+
@plugin[:cloud_v2][:provider].should == "azure"
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Richard Manyanza (<liseki@nyikacraftsmen.com>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Richard Manyanza.
|
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
|
+
|
20
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
21
|
+
|
22
|
+
describe Ohai::System, "FreeBSD plugin os" do
|
23
|
+
before(:each) do
|
24
|
+
@plugin = get_plugin("freebsd/os")
|
25
|
+
@plugin.stub(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
|
26
|
+
@plugin.stub(:collect_os).and_return(:freebsd)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should set os_version to __FreeBSD_version" do
|
30
|
+
@plugin.run
|
31
|
+
@plugin[:os_version].should == "902001"
|
32
|
+
end
|
33
|
+
end
|
@@ -28,11 +28,11 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do
|
|
28
28
|
shared_examples_for "when the JRE is installed" do
|
29
29
|
before do
|
30
30
|
@stderr = "java version \"1.5.0_16\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)\nJava HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)"
|
31
|
-
@plugin.stub(:shell_out).with("java -version").and_return(mock_shell_out(0, "", @stderr))
|
31
|
+
@plugin.stub(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
|
32
32
|
end
|
33
33
|
|
34
|
-
it "should run java -version" do
|
35
|
-
@plugin.should_receive(:shell_out).with("java -version").and_return(mock_shell_out(0, "", @stderr))
|
34
|
+
it "should run java -mx64m -version" do
|
35
|
+
@plugin.should_receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
|
36
36
|
@plugin.run
|
37
37
|
end
|
38
38
|
|
@@ -63,7 +63,7 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do
|
|
63
63
|
|
64
64
|
it "should not set the languages[:java] tree up if java command fails" do
|
65
65
|
@stderr = "Some error output here"
|
66
|
-
@plugin.stub(:shell_out).with("java -version").and_return(mock_shell_out(1, "", @stderr))
|
66
|
+
@plugin.stub(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(1, "", @stderr))
|
67
67
|
@plugin.run
|
68
68
|
@plugin[:languages].should_not have_key(:java)
|
69
69
|
end
|
@@ -73,11 +73,11 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do
|
|
73
73
|
|
74
74
|
before(:each) do
|
75
75
|
@stderr = "java version \"1.6.0_22\"\nJava(TM) 2 Runtime Environment (build 1.6.0_22-b04)\nJava HotSpot(TM) Server VM (build 17.1-b03, mixed mode)"
|
76
|
-
@plugin.stub(:shell_out).with("java -version").and_return(mock_shell_out(0, "", @stderr))
|
76
|
+
@plugin.stub(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
|
77
77
|
end
|
78
78
|
|
79
|
-
it "should run java -version" do
|
80
|
-
@plugin.should_receive(:shell_out).with("java -version").and_return(mock_shell_out(0, "", @stderr))
|
79
|
+
it "should run java -mx64m -version" do
|
80
|
+
@plugin.should_receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
|
81
81
|
@plugin.run
|
82
82
|
end
|
83
83
|
|
@@ -108,7 +108,7 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do
|
|
108
108
|
|
109
109
|
it "should not set the languages[:java] tree up if java command fails" do
|
110
110
|
@stderr = "Some error output here"
|
111
|
-
@plugin.stub(:shell_out).with("java -version").and_return(mock_shell_out(0, "", @stderr))
|
111
|
+
@plugin.stub(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
|
112
112
|
@plugin.run
|
113
113
|
@plugin[:languages].should_not have_key(:java)
|
114
114
|
end
|
@@ -159,7 +159,7 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do
|
|
159
159
|
end
|
160
160
|
|
161
161
|
it "does not attempt to get java info" do
|
162
|
-
@plugin.should_not_receive(:shell_out).with("java -version")
|
162
|
+
@plugin.should_not_receive(:shell_out).with("java -mx64m -version")
|
163
163
|
@plugin.run
|
164
164
|
@plugin[:languages].should_not have_key(:java)
|
165
165
|
end
|
@@ -32,6 +32,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
32
32
|
File.stub(:exists?).with("/proc/self/status").and_return(false)
|
33
33
|
File.stub(:exists?).with("/proc/bc/0").and_return(false)
|
34
34
|
File.stub(:exists?).with("/proc/vz").and_return(false)
|
35
|
+
File.stub(:exists?).with("/proc/self/cgroup").and_return(false)
|
35
36
|
end
|
36
37
|
|
37
38
|
describe "when we are checking for xen" do
|
@@ -262,6 +263,85 @@ VBOX
|
|
262
263
|
end
|
263
264
|
end
|
264
265
|
|
266
|
+
describe "when we are checking for lxc" do
|
267
|
+
it "should set lxc guest if /proc/self/cgroup exist and there are /lxc/<hexadecimal> mounts" do
|
268
|
+
self_cgroup=<<-CGROUP
|
269
|
+
8:blkio:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
270
|
+
7:net_cls:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
271
|
+
6:freezer:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
272
|
+
5:devices:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
273
|
+
4:memory:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
274
|
+
3:cpuacct:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
275
|
+
2:cpu:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
276
|
+
1:cpuset:/
|
277
|
+
CGROUP
|
278
|
+
File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
279
|
+
File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
280
|
+
@plugin.run
|
281
|
+
@plugin[:virtualization][:system].should == "lxc"
|
282
|
+
@plugin[:virtualization][:role].should == "guest"
|
283
|
+
end
|
284
|
+
|
285
|
+
it "should set lxc guest if /proc/self/cgroup exist and there are /lxc/<name> mounts" do
|
286
|
+
self_cgroup=<<-CGROUP
|
287
|
+
8:blkio:/lxc/vanilla
|
288
|
+
7:net_cls:/lxc/vanilla
|
289
|
+
6:freezer:/lxc/vanilla
|
290
|
+
5:devices:/lxc/vanilla
|
291
|
+
4:memory:/lxc/vanilla
|
292
|
+
3:cpuacct:/lxc/vanilla
|
293
|
+
2:cpu:/lxc/vanilla
|
294
|
+
1:cpuset:/lxc/vanilla
|
295
|
+
CGROUP
|
296
|
+
File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
297
|
+
File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
298
|
+
@plugin.run
|
299
|
+
@plugin[:virtualization][:system].should == "lxc"
|
300
|
+
@plugin[:virtualization][:role].should == "guest"
|
301
|
+
end
|
302
|
+
|
303
|
+
it "should set not set anyting if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do
|
304
|
+
self_cgroup=<<-CGROUP
|
305
|
+
8:blkio:/Charlie
|
306
|
+
7:net_cls:/Charlie
|
307
|
+
6:freezer:/Charlie
|
308
|
+
5:devices:/Charlie
|
309
|
+
4:memory:/Charlie
|
310
|
+
3:cpuacct:/Charlie
|
311
|
+
2:cpu:/Charlie
|
312
|
+
1:cpuset:/Charlie
|
313
|
+
CGROUP
|
314
|
+
File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
315
|
+
File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
316
|
+
@plugin.run
|
317
|
+
@plugin[:virtualization].should == {}
|
318
|
+
end
|
319
|
+
|
320
|
+
it "should set lxc host if /proc/self/cgroup only has / mounts" do
|
321
|
+
self_cgroup=<<-CGROUP
|
322
|
+
8:blkio:/
|
323
|
+
7:net_cls:/
|
324
|
+
6:freezer:/
|
325
|
+
5:devices:/
|
326
|
+
4:memory:/
|
327
|
+
3:cpuacct:/
|
328
|
+
2:cpu:/
|
329
|
+
1:cpuset:/
|
330
|
+
CGROUP
|
331
|
+
File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
332
|
+
File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
333
|
+
@plugin.run
|
334
|
+
@plugin[:virtualization][:system].should == "lxc"
|
335
|
+
@plugin[:virtualization][:role].should == "host"
|
336
|
+
end
|
337
|
+
|
338
|
+
it "should not set virtualization if /proc/self/cgroup isn't there" do
|
339
|
+
File.should_receive(:exists?).with("/proc/self/cgroup").and_return(false)
|
340
|
+
@plugin.run
|
341
|
+
@plugin[:virtualization].should == {}
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
265
345
|
it "should not set virtualization if no tests match" do
|
266
346
|
@plugin.run
|
267
347
|
@plugin[:virtualization].should == {}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.0.rc.
|
4
|
+
version: 7.0.0.rc.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -250,6 +250,7 @@ files:
|
|
250
250
|
- lib/ohai/plugins/c.rb
|
251
251
|
- lib/ohai/plugins/chef.rb
|
252
252
|
- lib/ohai/plugins/cloud.rb
|
253
|
+
- lib/ohai/plugins/cloud_v2.rb
|
253
254
|
- lib/ohai/plugins/command.rb
|
254
255
|
- lib/ohai/plugins/darwin/cpu.rb
|
255
256
|
- lib/ohai/plugins/darwin/filesystem.rb
|
@@ -264,6 +265,7 @@ files:
|
|
264
265
|
- lib/ohai/plugins/freebsd/filesystem.rb
|
265
266
|
- lib/ohai/plugins/freebsd/memory.rb
|
266
267
|
- lib/ohai/plugins/freebsd/network.rb
|
268
|
+
- lib/ohai/plugins/freebsd/os.rb
|
267
269
|
- lib/ohai/plugins/freebsd/platform.rb
|
268
270
|
- lib/ohai/plugins/freebsd/virtualization.rb
|
269
271
|
- lib/ohai/plugins/gce.rb
|
@@ -382,6 +384,7 @@ files:
|
|
382
384
|
- spec/unit/plugins/c_spec.rb
|
383
385
|
- spec/unit/plugins/chef_spec.rb
|
384
386
|
- spec/unit/plugins/cloud_spec.rb
|
387
|
+
- spec/unit/plugins/cloud_v2_spec.rb
|
385
388
|
- spec/unit/plugins/darwin/cpu_spec.rb
|
386
389
|
- spec/unit/plugins/darwin/hostname_spec.rb
|
387
390
|
- spec/unit/plugins/darwin/kernel_spec.rb
|
@@ -396,6 +399,7 @@ files:
|
|
396
399
|
- spec/unit/plugins/fail_spec.rb
|
397
400
|
- spec/unit/plugins/freebsd/hostname_spec.rb
|
398
401
|
- spec/unit/plugins/freebsd/kernel_spec.rb
|
402
|
+
- spec/unit/plugins/freebsd/os_spec.rb
|
399
403
|
- spec/unit/plugins/freebsd/platform_spec.rb
|
400
404
|
- spec/unit/plugins/freebsd/virtualization_spec.rb
|
401
405
|
- spec/unit/plugins/gce_spec.rb
|