summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ohai/hints.rb2
-rw-r--r--lib/ohai/mixin/cloudstack_metadata.rb88
-rw-r--r--lib/ohai/mixin/ec2_metadata.rb5
-rw-r--r--lib/ohai/mixin/gce_metadata.rb2
-rw-r--r--lib/ohai/plugins/aix/kernel.rb16
-rw-r--r--lib/ohai/plugins/aix/network.rb18
-rw-r--r--lib/ohai/plugins/aix/uptime.rb4
-rw-r--r--lib/ohai/plugins/aix/virtualization.rb39
-rw-r--r--lib/ohai/plugins/cloud.rb32
-rw-r--r--lib/ohai/plugins/cloudstack.rb43
-rw-r--r--lib/ohai/plugins/darwin/cpu.rb4
-rw-r--r--lib/ohai/plugins/freebsd/cpu.rb2
-rw-r--r--lib/ohai/plugins/go.rb30
-rw-r--r--lib/ohai/plugins/hostname.rb2
-rw-r--r--lib/ohai/plugins/java.rb4
-rw-r--r--lib/ohai/plugins/linux/filesystem.rb24
-rw-r--r--lib/ohai/plugins/linux/network.rb11
-rw-r--r--lib/ohai/plugins/linux/platform.rb8
-rw-r--r--lib/ohai/plugins/linux/virtualization.rb4
-rw-r--r--lib/ohai/plugins/openstack.rb22
-rw-r--r--lib/ohai/plugins/passwd.rb6
-rw-r--r--lib/ohai/plugins/python.rb6
-rw-r--r--lib/ohai/plugins/rackspace.rb8
-rw-r--r--lib/ohai/plugins/solaris2/zpools.rb2
-rw-r--r--lib/ohai/system.rb2
-rw-r--r--lib/ohai/version.rb2
26 files changed, 346 insertions, 40 deletions
diff --git a/lib/ohai/hints.rb b/lib/ohai/hints.rb
index fc2af32d..c8b0bc1b 100644
--- a/lib/ohai/hints.rb
+++ b/lib/ohai/hints.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require 'ffi_yajl/json_gem'
+require 'ffi_yajl'
module Ohai
module Hints
diff --git a/lib/ohai/mixin/cloudstack_metadata.rb b/lib/ohai/mixin/cloudstack_metadata.rb
new file mode 100644
index 00000000..8ecb9daf
--- /dev/null
+++ b/lib/ohai/mixin/cloudstack_metadata.rb
@@ -0,0 +1,88 @@
+#
+# Author:: Olle Lundberg (<geek@nerd.sh>)
+# Copyright:: Copyright (c) 2014 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'ohai/mixin/ec2_metadata'
+require 'ohai/hints'
+require 'net/dhcp'
+require 'socket'
+
+
+module Ohai
+ module Mixin
+ module CloudstackMetadata
+ include Ohai::Mixin::Ec2Metadata
+
+ def self.discover_dhcp_server
+ response = ''
+ if Ohai::Hints.hint?('cloudstack')
+ begin
+ request = DHCP::Discover.new
+
+ listensock = UDPSocket.new
+ sendsock = UDPSocket.new
+
+ listensock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
+ sendsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
+
+ sendsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
+ sendaddr = "<broadcast>"
+ listenport = 68
+
+ listensock.bind('', listenport)
+ sendsock.connect(sendaddr, 67)
+
+ sendsock.send(request.pack, 0)
+
+ data = listensock.recvfrom_nonblock(1500)
+ rescue Exception => e
+ if (defined?(IO::WaitReadable) && e.instance_of?(IO::WaitReadable)) ||
+ (e.instance_of?(Errno::EAGAIN) || e.instance_of?(Errno::EWOULDBLOCK)) # This OR branch can be removed when ruby > 1.8.7
+ unless IO.select([listensock], nil, nil, 10)
+ # timeout reached
+ Ohai::Log.debug("Timeout reached awaiting response from DHCP server")
+ else
+ # try to read from the socket again
+ data = listensock.recvfrom_nonblock(1500)
+ end
+ else
+ Ohai::Log.debug("Exceptions encountered when trying to connect to dhcp server. #{e.message}")
+ end
+ ensure
+ sendsock.close
+ listensock.close
+ if data
+ response = [DHCP::Message.from_udp_payload(data[0]).siaddr].pack('N').unpack('C4').join('.')
+ end
+ end
+ end
+ response
+ end
+
+ CLOUDSTACK_METADATA_ADDR = self.discover_dhcp_server unless defined?(CLOUDSTACK_METADATA_ADDR)
+
+ def http_client
+ Net::HTTP.start(CLOUDSTACK_METADATA_ADDR).tap { |h| h.read_timeout = 600 }
+ end
+
+ def best_api_version
+ 'latest'
+ end
+
+ end
+ end
+end
+
diff --git a/lib/ohai/mixin/ec2_metadata.rb b/lib/ohai/mixin/ec2_metadata.rb
index d01d5cc1..8d775719 100644
--- a/lib/ohai/mixin/ec2_metadata.rb
+++ b/lib/ohai/mixin/ec2_metadata.rb
@@ -76,7 +76,10 @@ module Ohai
def best_api_version
response = http_client.get("/")
- unless response.code == '200'
+ if response.code == '404'
+ Ohai::Log.debug("Received HTTP 404 from metadata server while determining API version, assuming 'latest'")
+ return "latest"
+ elsif response.code != '200'
raise "Unable to determine EC2 metadata version (returned #{response.code} response)"
end
# Note: Sorting the list of versions may have unintended consequences in
diff --git a/lib/ohai/mixin/gce_metadata.rb b/lib/ohai/mixin/gce_metadata.rb
index 04334880..a3d57ade 100644
--- a/lib/ohai/mixin/gce_metadata.rb
+++ b/lib/ohai/mixin/gce_metadata.rb
@@ -51,7 +51,7 @@ module Ohai
end
def http_client
- Net::HTTP.start(GCE_METADATA_ADDR).tap {|h| h.read_timeout = 600}
+ Net::HTTP.start(GCE_METADATA_ADDR).tap {|h| h.read_timeout = 6}
end
def fetch_metadata(id='')
diff --git a/lib/ohai/plugins/aix/kernel.rb b/lib/ohai/plugins/aix/kernel.rb
index 91fb58cd..ed189057 100644
--- a/lib/ohai/plugins/aix/kernel.rb
+++ b/lib/ohai/plugins/aix/kernel.rb
@@ -26,6 +26,20 @@ Ohai.plugin(:Kernel) do
kernel[:release] = shell_out("uname -r").stdout.split($/)[0]
kernel[:version] = shell_out("uname -v").stdout.split($/)[0]
kernel[:machine] = shell_out("uname -p").stdout.split($/)[0]
- kernel[:modules] = Mash.new
+
+ modules = Mash.new
+ so = shell_out("genkex -d")
+ # Text address Size Data address Size File
+ #
+ # f1000000c0338000 77000 f1000000c0390000 1ec8c /usr/lib/drivers/cluster
+ # 6390000 20000 63a0000 ba8 /usr/lib/drivers/if_en
+ # f1000000c0318000 20000 f1000000c0320000 17138 /usr/lib/drivers/random
+ so.stdout.lines do |line|
+ if line =~ /\s*([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+([a-zA-Z0-9\/\._]+)/
+ modules[$5] = { :text => { :address => $1, :size => $2 }, :data => { :address => $3, :size => $4 } }
+ end
+ end
+
+ kernel[:modules] = modules
end
end
diff --git a/lib/ohai/plugins/aix/network.rb b/lib/ohai/plugins/aix/network.rb
index b6dbb22e..0a9b82e9 100644
--- a/lib/ohai/plugins/aix/network.rb
+++ b/lib/ohai/plugins/aix/network.rb
@@ -42,14 +42,16 @@ Ohai.plugin(:Network) do
iface = Mash.new
+ network Mash.new unless network
+ network[:interfaces] = Mash.new unless network[:interfaces]
+
# :default_interface, :default_gateway - route -n get 0
- so = shell_out("route -n get 0")
+ so = shell_out("netstat -rn |grep default")
so.stdout.lines.each do |line|
- case line
- when /gateway: (\S+)/
- network[:default_gateway] = $1
- when /interface: (\S+)/
- network[:default_interface] = $1
+ items = line.split(' ')
+ if items[0] == "default"
+ network[:default_gateway] = items[1]
+ network[:default_interface] = items[5]
end
end
@@ -90,10 +92,10 @@ Ohai.plugin(:Network) do
if line =~ /broadcast\s(\S+)\s/
iface[interface][:addresses][tmp_addr][:broadcast] = $1
end
- elsif line =~ /inet6 ([a-f0-9\:%]+)\/(\d+)/
+ elsif line =~ /inet6 ([a-f0-9\:]+)%?([\d]*)\/?(\d*)/
# TODO do we have more properties on inet6 in aix? broadcast
iface[interface][:addresses] = Mash.new unless iface[interface][:addresses]
- iface[interface][:addresses][$1] = { "family" => "inet6", "prefixlen" => $2 }
+ iface[interface][:addresses][$1] = { "family" => "inet6", "zone_index" => $2, "prefixlen" => $3 }
else
# load all key-values, example "tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1"
properties = line.split
diff --git a/lib/ohai/plugins/aix/uptime.rb b/lib/ohai/plugins/aix/uptime.rb
index 6c33cb7b..270a692f 100644
--- a/lib/ohai/plugins/aix/uptime.rb
+++ b/lib/ohai/plugins/aix/uptime.rb
@@ -27,10 +27,10 @@ Ohai.plugin(:Uptime) do
so = shell_out('who -b')
so.stdout.lines.each do |line|
if line =~ /.* boot (.+)/
- uptime_seconds Time.now.to_i - DateTime.parse($1).strftime('%s').to_i
+ uptime_seconds Time.now.to_i - DateTime.parse($1 + " #{Time.now.zone}").strftime('%s').to_i
uptime seconds_to_human(uptime_seconds)
break
end
end
end
-end
+end \ No newline at end of file
diff --git a/lib/ohai/plugins/aix/virtualization.rb b/lib/ohai/plugins/aix/virtualization.rb
new file mode 100644
index 00000000..ad625d9b
--- /dev/null
+++ b/lib/ohai/plugins/aix/virtualization.rb
@@ -0,0 +1,39 @@
+#
+# Author:: Julian C. Dunn (<jdunn@getchef.com>)
+# Copyright:: Copyright (c) 2014 Chef Software, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+Ohai.plugin(:Virtualization) do
+ provides "virtualization"
+
+ collect_data(:aix) do
+ virtualization Mash.new
+
+ so = shell_out("uname -L")
+ lpar_no = so.stdout.split($/)[0].split(/\s/)[0]
+ lpar_name = so.stdout.split($/)[0].split(/\s/)[1]
+
+ unless lpar_no.to_i == -1 || (lpar_no.to_i == 1 && lpar_name == "NULL")
+ virtualization[:lpar_no] = lpar_no
+ virtualization[:lpar_name] = lpar_name
+ end
+
+ so = shell_out("uname -W")
+ wpar_no = so.stdout.split($/)[0]
+ virtualization[:wpar_no] = wpar_no unless wpar_no.to_i == 0
+
+ end
+end \ No newline at end of file
diff --git a/lib/ohai/plugins/cloud.rb b/lib/ohai/plugins/cloud.rb
index d1c28562..ef81d641 100644
--- a/lib/ohai/plugins/cloud.rb
+++ b/lib/ohai/plugins/cloud.rb
@@ -24,6 +24,7 @@ Ohai.plugin(:Cloud) do
depends "linode"
depends "openstack"
depends "azure"
+ depends "cloudstack"
# Make top-level cloud hashes
#
@@ -215,6 +216,31 @@ Ohai.plugin(:Cloud) do
cloud[:provider] = "azure"
end
+ # ----------------------------------------
+ # cloudstack
+ # ----------------------------------------
+
+ # Is current cloud cloudstack-based?
+ #
+ # === Return
+ # true:: If cloudstack Hash is defined
+ # false:: Otherwise
+ def on_cloudstack?
+ cloudstack != nil
+ end
+
+ # Fill cloud hash with cloudstack values
+ def get_cloudstack_values
+ cloud[:public_ips] << cloudstack['public_ipv4']
+ cloud[:private_ips] << cloudstack['local_ipv4']
+ cloud[:public_ipv4] = cloudstack['public_ipv4']
+ cloud[:public_hostname] = cloudstack['public_hostname']
+ cloud[:local_ipv4] = cloudstack['local_ipv4']
+ cloud[:local_hostname] = cloudstack['local_hostname']
+ cloud[:vm_id] = cloudstack['vm_id']
+ cloud[:provider] = "cloudstack"
+ end
+
collect_data do
# setup gce cloud
if on_gce?
@@ -256,5 +282,11 @@ Ohai.plugin(:Cloud) do
create_objects
get_azure_values
end
+
+ # setup cloudstack cloud
+ if on_cloudstack?
+ create_objects
+ get_cloudstack_values
+ end
end
end
diff --git a/lib/ohai/plugins/cloudstack.rb b/lib/ohai/plugins/cloudstack.rb
new file mode 100644
index 00000000..cecd36c8
--- /dev/null
+++ b/lib/ohai/plugins/cloudstack.rb
@@ -0,0 +1,43 @@
+#
+# Author:: Olle Lundberg (<geek@nerd.sh>)
+# Copyright:: Copyright (c) 2014 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'ohai/mixin/cloudstack_metadata'
+
+Ohai.plugin(:Cloudstack) do
+ provides "cloudstack"
+
+ include Ohai::Mixin::CloudstackMetadata
+
+ collect_data do
+ # Adds cloudstack Mash
+ if hint?('cloudstack')
+ Ohai::Log.debug("found 'cloudstack' hint. Will try to connect to the metadata server")
+
+ if can_metadata_connect?(Ohai::Mixin::CloudstackMetadata::CLOUDSTACK_METADATA_ADDR, 80)
+ cloudstack Mash.new
+ Ohai::Log.debug("connecting to the 'cloudstack' metadata service")
+ fetch_metadata.each { |k, v| cloudstack[k] = v }
+ else
+ Ohai::Log.debug("unable to connect to the 'cloudstack' metadata service")
+ end
+ else
+ Ohai::Log.debug("unable to find 'cloudstack' hint. Won't connect to the metadata server.")
+ end
+ end
+end
+
+
diff --git a/lib/ohai/plugins/darwin/cpu.rb b/lib/ohai/plugins/darwin/cpu.rb
index 1c0b6180..ec8f095b 100644
--- a/lib/ohai/plugins/darwin/cpu.rb
+++ b/lib/ohai/plugins/darwin/cpu.rb
@@ -29,9 +29,9 @@ Ohai.plugin(:CPU) do
so = shell_out("sysctl -n hw.cpufrequency")
cpu[:mhz] = so.stdout.to_i / 1000000
so = shell_out("sysctl -n machdep.cpu.vendor")
- cpu[:vendor_id] = so.stdout
+ cpu[:vendor_id] = so.stdout.chomp
so = shell_out("sysctl -n machdep.cpu.brand_string")
- cpu[:model_name] = so.stdout
+ cpu[:model_name] = so.stdout.chomp
so = shell_out("sysctl -n machdep.cpu.model")
cpu[:model] = so.stdout.to_i
so = shell_out("sysctl -n machdep.cpu.family")
diff --git a/lib/ohai/plugins/freebsd/cpu.rb b/lib/ohai/plugins/freebsd/cpu.rb
index 8355ec02..88baf2b5 100644
--- a/lib/ohai/plugins/freebsd/cpu.rb
+++ b/lib/ohai/plugins/freebsd/cpu.rb
@@ -55,6 +55,6 @@ Ohai.plugin(:CPU) do
cpu cpuinfo
so = shell_out("sysctl -n hw.ncpu")
- cpu[:total] = so.stdout.split($/)[0]
+ cpu[:total] = so.stdout.split($/)[0].to_i
end
end
diff --git a/lib/ohai/plugins/go.rb b/lib/ohai/plugins/go.rb
new file mode 100644
index 00000000..44a97d6c
--- /dev/null
+++ b/lib/ohai/plugins/go.rb
@@ -0,0 +1,30 @@
+# Author:: Christian Vozar (<christian@rogueethic.com>)
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Ohai.plugin(:Go) do
+ provides "languages/go"
+ depends "languages"
+
+ collect_data do
+ output = nil
+ go = Mash.new
+ so = shell_out("go version")
+ if so.exitstatus == 0
+ output = so.stdout.split
+ go[:version] = output[2].slice!(2..16)
+ languages[:go] = go if go[:version]
+ end
+ end
+end
diff --git a/lib/ohai/plugins/hostname.rb b/lib/ohai/plugins/hostname.rb
index 303880ed..447b255d 100644
--- a/lib/ohai/plugins/hostname.rb
+++ b/lib/ohai/plugins/hostname.rb
@@ -67,7 +67,7 @@ Ohai.plugin(:Hostname) do
def collect_hostname
# Hostname is everything before the first dot
if machinename
- machinename =~ /(.+?)\./
+ machinename =~ /(\w+)\.?/
hostname $1
elsif fqdn
fqdn =~ /(.+?)\./
diff --git a/lib/ohai/plugins/java.rb b/lib/ohai/plugins/java.rb
index 9f71eb7f..3c83d7cc 100644
--- a/lib/ohai/plugins/java.rb
+++ b/lib/ohai/plugins/java.rb
@@ -28,9 +28,9 @@ Ohai.plugin(:Java) do
case line
when /java version \"([0-9\.\_]+)\"/
java[:version] = $1
- when /^(.+Runtime Environment.*) \((build )?(.+)\)$/
+ when /^(.+Runtime Environment.*) \((build)\s*(.+)\)$/
java[:runtime] = { "name" => $1, "build" => $3 }
- when /^(.+ (Client|Server) VM) \(build (.+)\)$/
+ when /^(.+ (Client|Server) VM) \(build\s*(.+)\)$/
java[:hotspot] = { "name" => $1, "build" => $3 }
end
end
diff --git a/lib/ohai/plugins/linux/filesystem.rb b/lib/ohai/plugins/linux/filesystem.rb
index b464b4b4..d01d5294 100644
--- a/lib/ohai/plugins/linux/filesystem.rb
+++ b/lib/ohai/plugins/linux/filesystem.rb
@@ -32,6 +32,14 @@ Ohai.plugin(:Filesystem) do
have_lsblk ? /^(\S+) (\S+)/ : /^(\S+): #{attr}="(\S+)"/
end
+ def find_device(name)
+ %w{/dev /dev/mapper}.each do |dir|
+ path = File.join(dir, name)
+ return path if File.exist?(path)
+ end
+ name
+ end
+
collect_data(:linux) do
fs = Mash.new
have_lsblk = File.executable?('/bin/lsblk')
@@ -82,7 +90,7 @@ Ohai.plugin(:Filesystem) do
end
end
- have_lsblk = File.exists?('/bin/lsblk')
+ have_lsblk = File.exist?('/bin/lsblk')
# Gather more filesystem types via libuuid, even devices that's aren't mounted
cmd = get_blk_cmd('TYPE', have_lsblk)
@@ -91,8 +99,10 @@ Ohai.plugin(:Filesystem) do
so.stdout.lines do |line|
if line =~ regex
filesystem = $1
+ type = $2
+ filesystem = find_device(filesystem) unless filesystem.start_with?('/')
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
- fs[filesystem][:fs_type] = $2
+ fs[filesystem][:fs_type] = type
end
end
@@ -103,8 +113,10 @@ Ohai.plugin(:Filesystem) do
so.stdout.lines do |line|
if line =~ regex
filesystem = $1
+ uuid = $2
+ filesystem = find_device(filesystem) unless filesystem.start_with?('/')
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
- fs[filesystem][:uuid] = $2
+ fs[filesystem][:uuid] = uuid
end
end
@@ -115,13 +127,15 @@ Ohai.plugin(:Filesystem) do
so.stdout.lines do |line|
if line =~ regex
filesystem = $1
+ label = $2
+ filesystem = find_device(filesystem) unless filesystem.start_with?('/')
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
- fs[filesystem][:label] = $2
+ fs[filesystem][:label] = label
end
end
# Grab any missing mount information from /proc/mounts
- if File.exists?('/proc/mounts')
+ if File.exist?('/proc/mounts')
mounts = ''
# Due to https://tickets.opscode.com/browse/OHAI-196
# we have to non-block read dev files. Ew.
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb
index 3d80a057..c6fa8859 100644
--- a/lib/ohai/plugins/linux/network.rb
+++ b/lib/ohai/plugins/linux/network.rb
@@ -1,5 +1,6 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Chris Read <chris.read@gmail.com>
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
@@ -161,10 +162,16 @@ Ohai.plugin(:Network) do
net_counters[tmp_int][:tx][:queuelen] = $1
end
- if line =~ /vlan id (\d+)/
- tmp_id = $1
+ if line =~ /vlan id (\d+)/ or line =~ /vlan protocol ([\w\.]+) id (\d+)/
+ if $2
+ tmp_prot = $1
+ tmp_id = $2
+ else
+ tmp_id = $1
+ end
iface[tmp_int][:vlan] = Mash.new unless iface[tmp_int][:vlan]
iface[tmp_int][:vlan][:id] = tmp_id
+ iface[tmp_int][:vlan][:protocol] = tmp_prot if tmp_prot
vlan_flags = line.scan(/(REORDER_HDR|GVRP|LOOSE_BINDING)/)
if vlan_flags.length > 0
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb
index 90347a45..ed5f3499 100644
--- a/lib/ohai/plugins/linux/platform.rb
+++ b/lib/ohai/plugins/linux/platform.rb
@@ -55,6 +55,10 @@ Ohai.plugin(:Platform) do
end
platform_version File.read("/etc/debian_version").chomp
end
+ elsif File.exists?("/etc/parallels-release")
+ contents = File.read("/etc/parallels-release").chomp
+ platform get_redhatish_platform(contents)
+ platform_version contents.match(/(\d\.\d\.\d)/)[0]
elsif File.exists?("/etc/redhat-release")
contents = File.read("/etc/redhat-release").chomp
platform get_redhatish_platform(contents)
@@ -107,9 +111,9 @@ Ohai.plugin(:Platform) do
case platform
when /debian/, /ubuntu/, /linuxmint/, /raspbian/
platform_family "debian"
- when /fedora/
+ when /fedora/, /pidora/
platform_family "fedora"
- when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/, /ibm_powerkvm/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
+ when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
platform_family "rhel"
when /suse/
platform_family "suse"
diff --git a/lib/ohai/plugins/linux/virtualization.rb b/lib/ohai/plugins/linux/virtualization.rb
index 49d01565..73ba253a 100644
--- a/lib/ohai/plugins/linux/virtualization.rb
+++ b/lib/ohai/plugins/linux/virtualization.rb
@@ -137,7 +137,7 @@ Ohai.plugin(:Virtualization) do
# Detect Linux-VServer
if File.exists?("/proc/self/status")
proc_self_status = File.read("/proc/self/status")
- vxid = proc_self_status.match(/^(s_context|VxID): (\d+)$/)
+ vxid = proc_self_status.match(/^(s_context|VxID):\s*(\d+)$/)
if vxid and vxid[2]
virtualization[:system] = "linux-vserver"
if vxid[2] == "0"
@@ -158,7 +158,7 @@ Ohai.plugin(:Virtualization) do
# /proc/self/cgroup could have a name including alpha/digit/dashes
# <index #>:<subsystem>:/lxc/<named container id>
#
- # /proc/self/cgroup could have a non-lxc cgroup name indicating other uses
+ # /proc/self/cgroup could have a non-lxc cgroup name indicating other uses
# of cgroups. This is probably not LXC/Docker.
# <index #>:<subsystem>:/Charlie
#
diff --git a/lib/ohai/plugins/openstack.rb b/lib/ohai/plugins/openstack.rb
index eb357336..28ba3970 100644
--- a/lib/ohai/plugins/openstack.rb
+++ b/lib/ohai/plugins/openstack.rb
@@ -22,6 +22,26 @@ Ohai.plugin(:Openstack) do
include Ohai::Mixin::Ec2Metadata
+ def collect_openstack_metadata(addr = Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, api_version = '2013-04-04')
+ path = "/openstack/#{api_version}/meta_data.json"
+ uri = "http://#{addr}#{path}"
+ begin
+ response = http_client.get_response(URI.parse(uri),nil,nil)
+ case response.code
+ when '200'
+ FFI_Yajl::Parser.parse(response.body)
+ when '404'
+ Ohai::Log.debug("Encountered 404 response retreiving OpenStack specific metadata path: #{path} ; continuing.")
+ nil
+ else
+ raise "Encountered error retrieving OpenStack specific metadata (#{path} returned #{response.code} response)"
+ end
+ rescue => e
+ Ohai::Log.debug("Encountered error retrieving OpenStack specific metadata (#{uri}), due to #{e.class}")
+ nil
+ end
+ end
+
collect_data do
# Adds openstack Mash
if hint?('openstack') || hint?('hp')
@@ -36,6 +56,8 @@ Ohai.plugin(:Openstack) do
openstack['provider'] = 'hp'
else
openstack['provider'] = 'openstack'
+ Ohai::Log.debug("connecting to the OpenStack specific metadata service")
+ openstack['metadata'] = collect_openstack_metadata
end
else
diff --git a/lib/ohai/plugins/passwd.rb b/lib/ohai/plugins/passwd.rb
index 1e10f708..675a70b8 100644
--- a/lib/ohai/plugins/passwd.rb
+++ b/lib/ohai/plugins/passwd.rb
@@ -32,7 +32,11 @@ Ohai.plugin(:Passwd) do
end
unless current_user
- current_user fix_encoding(Etc.getlogin)
+ current_user fix_encoding(Etc.getpwuid(Process.euid).name)
end
end
+
+ collect_data(:windows) do
+ # Etc returns nil on Windows
+ end
end
diff --git a/lib/ohai/plugins/python.rb b/lib/ohai/plugins/python.rb
index 683042ba..c6c4dfc8 100644
--- a/lib/ohai/plugins/python.rb
+++ b/lib/ohai/plugins/python.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,7 +26,7 @@ Ohai.plugin(:Python) do
python = Mash.new
- so = shell_out("python -c \"import sys; print sys.version\"")
+ so = shell_out("python -c \"import sys; print (sys.version)\"")
if so.exitstatus == 0
output = so.stdout.split
diff --git a/lib/ohai/plugins/rackspace.rb b/lib/ohai/plugins/rackspace.rb
index df30e348..8736b370 100644
--- a/lib/ohai/plugins/rackspace.rb
+++ b/lib/ohai/plugins/rackspace.rb
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+require "resolv"
+
Ohai.plugin(:Rackspace) do
provides "rackspace"
@@ -129,7 +131,11 @@ Ohai.plugin(:Rackspace) do
rackspace[:public_ipv4] = rackspace[:public_ip]
get_global_ipv6_address(:public_ipv6, :eth0)
unless rackspace[:public_ip].nil?
- rackspace[:public_hostname] = "#{rackspace[:public_ip].gsub('.','-')}.static.cloud-ips.com"
+ rackspace[:public_hostname] = begin
+ Resolv.getname(rackspace[:public_ip])
+ rescue Resolv::ResolvError, Resolv::ResolvTimeout
+ rackspace[:public_ip]
+ end
end
rackspace[:local_ipv4] = rackspace[:private_ip]
get_global_ipv6_address(:local_ipv6, :eth1)
diff --git a/lib/ohai/plugins/solaris2/zpools.rb b/lib/ohai/plugins/solaris2/zpools.rb
index f0867cd5..b9b07287 100644
--- a/lib/ohai/plugins/solaris2/zpools.rb
+++ b/lib/ohai/plugins/solaris2/zpools.rb
@@ -26,7 +26,7 @@ Ohai.plugin(:Zpools) do
so = shell_out("zpool list -H -o name,size,alloc,free,cap,dedup,health,version")
so.stdout.lines do |line|
case line
- when /^([-_0-9A-Za-z]*)\s+([.0-9]+[MGTPE])\s+([.0-9]+[MGTPE])\s+([.0-9]+[MGTPE])\s+(\d+%)\s+([.0-9]+x)\s+([-_0-9A-Za-z]+)\s+(\d+)$/
+ when /^([-_0-9A-Za-z]*)\s+([.0-9]+[MGTPE])\s+([.0-9]+[MGTPE])\s+([.0-9]+[MGTPE])\s+(\d+%)\s+([.0-9]+x)\s+([-_0-9A-Za-z]+)\s+(\d+|-)$/
pools[$1] = Mash.new
pools[$1][:pool_size] = $2
pools[$1][:pool_allocated] = $3
diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb
index 69919da9..511fb9ea 100644
--- a/lib/ohai/system.rb
+++ b/lib/ohai/system.rb
@@ -29,8 +29,6 @@ require 'ohai/provides_map'
require 'ohai/hints'
require 'mixlib/shellout'
-require 'ffi_yajl/json_gem'
-
module Ohai
class System
include Ohai::Mixin::ConstantHelper
diff --git a/lib/ohai/version.rb b/lib/ohai/version.rb
index 4c1ecc87..f1512f27 100644
--- a/lib/ohai/version.rb
+++ b/lib/ohai/version.rb
@@ -18,5 +18,5 @@
module Ohai
OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
- VERSION = '7.4.0'
+ VERSION = '7.6.0.rc.0'
end