diff options
author | Tim Smith <tsmith@chef.io> | 2017-09-19 16:54:52 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2017-10-24 09:18:41 -0700 |
commit | 208b3535112daad99201ab2d66df31772d6d76aa (patch) | |
tree | a7d61b41e40f48239a1a7ecc32e06eb0a96a5d1c | |
parent | ac5c75f2a471e983cd48cc6861855c9c152d96b2 (diff) | |
download | ohai-208b3535112daad99201ab2d66df31772d6d76aa.tar.gz |
Detect Rackspace on Windows
This uses the same method we previously used on EC2. It won't poll any data since that requires the xen cli tools, but it will show up as being on rackspace, which is an important first step.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/rackspace.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/ohai/plugins/rackspace.rb b/lib/ohai/plugins/rackspace.rb index 0648a934..f8a8f9a2 100644 --- a/lib/ohai/plugins/rackspace.rb +++ b/lib/ohai/plugins/rackspace.rb @@ -43,13 +43,27 @@ Ohai.plugin(:Rackspace) do false end + # Checks for the rackspace manufacturer on Windows + # === Return + # true:: If the rackspace cloud can be identified + # false:: Otherwise + def has_rackspace_manufacturer? + return false unless RUBY_PLATFORM =~ /mswin|mingw32|windows/ + require "wmi-lite/wmi" + wmi = WmiLite::Wmi.new + if wmi.first_of("Win32_ComputerSystem")["PrimaryOwnerName"] == "Rackspace" + Ohai::Log.debug("Plugin Rackspace: has_rackspace_manufacturer? == true") + return true + end + end + # Identifies the rackspace cloud # # === Return # true:: If the rackspace cloud can be identified # false:: Otherwise def looks_like_rackspace? - hint?("rackspace") || has_rackspace_metadata? || has_rackspace_kernel? + hint?("rackspace") || has_rackspace_metadata? || has_rackspace_kernel? || has_rackspace_manufacturer? end # Names rackspace ip address @@ -137,8 +151,8 @@ Ohai.plugin(:Rackspace) do rackspace Mash.new get_ip_address(:public_ip, :eth0) get_ip_address(:private_ip, :eth1) - get_region() - get_instance_id() + get_region + get_instance_id # public_ip + private_ip are deprecated in favor of public_ipv4 and local_ipv4 to standardize. rackspace[:public_ipv4] = rackspace[:public_ip] get_global_ipv6_address(:public_ipv6, :eth0) |