Skip to content

Commit

Permalink
Add rackspace networks if available
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisroberts committed Apr 17, 2013
1 parent a824628 commit b15af5f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/ohai/plugins/rackspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@ def get_region()
Ohai::Log.debug("Unable to find xenstore-ls, cannot capture region information for Rackspace cloud")
end

def get_networks
status, stdout, stderr = run_command(:no_status_check => true, :command => 'xenstore-ls vm-data/networking')
if status == 0
stdout.split("\n").map{|l| l.split('=').first.strip }.map do |item|
_status, _stdout, _stderr = run_command(:no_status_check => true, :command => "xenstore-read vm-data/networking/#{item}")
if status == 0
Yajl::Parser.new.parse(_stdout)
else
raise Ohai::Exceptions::Exec
end
end
end
rescue Ohai::Exceptions::Exec
Ohai::Log.debug('Unable to capture custom private networking information for Rackspace cloud')
end

# Adds rackspace Mash
if looks_like_rackspace?
rackspace Mash.new
Expand All @@ -106,4 +122,5 @@ def get_region()
rackspace[:local_ipv4] = rackspace[:private_ip]
get_global_ipv6_address(:local_ipv6, :eth1)
rackspace[:local_hostname] = hostname
rackspace[:networks] = get_networks
end

0 comments on commit b15af5f

Please sign in to comment.