diff options
author | Thomas Wiest <twiest@gmail.com> | 2014-10-23 15:35:16 -0400 |
---|---|---|
committer | Thomas Wiest <twiest@gmail.com> | 2014-10-23 15:35:16 -0400 |
commit | cde5cba28b7b0e9386f1c549ecf9141bbcadc64e (patch) | |
tree | 22a39c5589aa3f6a2a01f185041258e4fd69dea6 /lib/gce_helper.rb | |
parent | 1057c69acdaf47e2bcd4b395069e3bc1bd9eec88 (diff) | |
parent | 5f9c7eb2d2ad44776d33197857dcd0afe693b5f5 (diff) | |
download | openshift-cde5cba28b7b0e9386f1c549ecf9141bbcadc64e.tar.gz openshift-cde5cba28b7b0e9386f1c549ecf9141bbcadc64e.tar.bz2 openshift-cde5cba28b7b0e9386f1c549ecf9141bbcadc64e.tar.xz openshift-cde5cba28b7b0e9386f1c549ecf9141bbcadc64e.zip |
Merge pull request #11 from twiest/pull
Added atomic aws host to cloud.rb
Diffstat (limited to 'lib/gce_helper.rb')
-rw-r--r--[-rwxr-xr-x] | lib/gce_helper.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/gce_helper.rb b/lib/gce_helper.rb index 6c0f57cf3..2ff716ce1 100755..100644 --- a/lib/gce_helper.rb +++ b/lib/gce_helper.rb @@ -1,15 +1,27 @@ +require 'ostruct' + module OpenShift module Ops class GceHelper MYDIR = File.expand_path(File.dirname(__FILE__)) - def self.list_hosts() + def self.get_hosts() cmd = "#{MYDIR}/../inventory/gce/gce.py --list" hosts = %x[#{cmd} 2>&1] raise "Error: failed to list hosts\n#{hosts}" unless $?.exitstatus == 0 - return JSON.parse(hosts) + # invert the hash so that it's key is the host, and values is an array of metadata + data = {} + JSON.parse(hosts).each do |key,value| + value.each { |h| (data[h] ||= []) << key } + end + + # For now, we only care about the name. In the future, we may want the other metadata included. + retval = [] + data.keys.sort.each { |k| retval << OpenStruct.new({ :name => k }) } + + return retval end def self.get_host_details(host) |