summaryrefslogtreecommitdiffstats
path: root/lib/gce_helper.rb
diff options
context:
space:
mode:
authorThomas Wiest <twiest@users.noreply.github.com>2015-05-28 09:49:14 -0400
committerThomas Wiest <twiest@users.noreply.github.com>2015-05-28 09:49:14 -0400
commit43d08da2a4af64015cd0fd83b36d843e51b21b0d (patch)
tree3a96ee3547c7a5a66c8ca4b7afb71263ba8a28aa /lib/gce_helper.rb
parent551562cd54f06db6e96e6f8d8986bc08a27c7d8a (diff)
parent8fc2fe0b7ecf71b675158eabcc00a3a14218abe2 (diff)
downloadopenshift-43d08da2a4af64015cd0fd83b36d843e51b21b0d.tar.gz
openshift-43d08da2a4af64015cd0fd83b36d843e51b21b0d.tar.bz2
openshift-43d08da2a4af64015cd0fd83b36d843e51b21b0d.tar.xz
openshift-43d08da2a4af64015cd0fd83b36d843e51b21b0d.zip
Merge pull request #252 from twiest/pr
Removed cloud.rb and it's associated libraries as it's no longer used.
Diffstat (limited to 'lib/gce_helper.rb')
-rw-r--r--lib/gce_helper.rb94
1 files changed, 0 insertions, 94 deletions
diff --git a/lib/gce_helper.rb b/lib/gce_helper.rb
deleted file mode 100644
index 19fa00020..000000000
--- a/lib/gce_helper.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-require 'ostruct'
-
-module OpenShift
- module Ops
- class GceHelper
- MYDIR = File.expand_path(File.dirname(__FILE__))
-
- def self.get_list()
- 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)
- end
-
- def self.get_tag(tags, selector)
- tags.each do |tag|
- return $1 if tag =~ selector
- end
-
- return nil
- end
-
- def self.get_hosts()
- hosts = get_list()
-
- retval = []
- hosts['_meta']['hostvars'].each do |host, info|
- retval << OpenStruct.new({
- :name => info['gce_name'],
- :env => get_tag(info['gce_tags'], /^env-(\w+)$/) || 'UNSET',
- :public_ip => info['gce_public_ip'],
- :state => info['gce_status'],
- :created_by => get_tag(info['gce_tags'], /^created-by-(\w+)$/) || 'UNSET',
- })
- end
-
- retval.sort_by! { |h| [h.env, h.state, h.name] }
-
- return retval
-
- end
-
- def self.get_host_details(host)
- cmd = "#{MYDIR}/../inventory/gce/gce.py --host #{host}"
- details = %x[#{cmd} 2>&1]
-
- raise "Error: failed to get host details\n#{details}" unless $?.exitstatus == 0
-
- retval = JSON.parse(details)
-
- raise "Error: host not found [#{host}]" if retval.empty?
-
- # Convert OpenShift specific tags to entries
- retval['gce_tags'].each do |tag|
- if tag =~ /\Ahost-type-([\w\d-]+)\z/
- retval['host-type'] = $1
- end
-
- if tag =~ /\Aenv-([\w\d]+)\z/
- retval['env'] = $1
- end
- end
-
- return retval
- end
-
- def self.generate_env_tag(env)
- return "env-#{env}"
- end
-
- def self.generate_env_tag_name(env)
- return "tag_#{generate_env_tag(env)}"
- end
-
- def self.generate_host_type_tag(host_type)
- return "host-type-#{host_type}"
- end
-
- def self.generate_host_type_tag_name(host_type)
- return "tag_#{generate_host_type_tag(host_type)}"
- end
-
- def self.generate_env_host_type_tag(env, host_type)
- return "env-host-type-#{env}-#{host_type}"
- end
-
- def self.generate_env_host_type_tag_name(env, host_type)
- return "tag_#{generate_env_host_type_tag(env, host_type)}"
- end
- end
- end
-end