summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Wiest <twiest@gmail.com>2014-10-23 16:27:39 -0400
committerThomas Wiest <twiest@gmail.com>2014-10-23 16:27:39 -0400
commitd8a336f0e86dbe2a933c805c75b8bcc11b67cf8a (patch)
tree44ba1eb9aef8cb65b3c47dec2bf4c41d70e25c76 /lib
parentcde5cba28b7b0e9386f1c549ecf9141bbcadc64e (diff)
parent6878f8690843e3f4b4c68f464bb39dd682bf51f4 (diff)
downloadopenshift-d8a336f0e86dbe2a933c805c75b8bcc11b67cf8a.tar.gz
openshift-d8a336f0e86dbe2a933c805c75b8bcc11b67cf8a.tar.bz2
openshift-d8a336f0e86dbe2a933c805c75b8bcc11b67cf8a.tar.xz
openshift-d8a336f0e86dbe2a933c805c75b8bcc11b67cf8a.zip
Merge pull request #12 from twiest/pull
made aws list display more information, and be able to only show a single environment
Diffstat (limited to 'lib')
-rw-r--r--lib/aws_command.rb14
-rw-r--r--lib/aws_helper.rb8
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/aws_command.rb b/lib/aws_command.rb
index d471557b8..bc353ae64 100644
--- a/lib/aws_command.rb
+++ b/lib/aws_command.rb
@@ -35,7 +35,7 @@ module OpenShift
# Add a created by tag
ah.extra_vars['oo_new_inst_tags'] = {} if ah.extra_vars['oo_new_inst_tags'].nil?
- ah.extra_vars['oo_new_inst_tags']["created-by"] = ENV['USER']
+ ah.extra_vars['oo_new_inst_tags']['created-by'] = ENV['USER']
ah.extra_vars['oo_new_inst_tags'].merge!(AwsHelper.generate_env_tag(options[:env]))
ah.extra_vars['oo_new_inst_tags'].merge!(AwsHelper.generate_host_type_tag(options[:type]))
ah.extra_vars['oo_new_inst_tags'].merge!(AwsHelper.generate_env_host_type_tag(options[:env], options[:type]))
@@ -96,15 +96,21 @@ module OpenShift
ah.run_playbook("playbooks/aws/#{host_type}/config.yml")
end
+ option :env, :required => false, :aliases => '-e', :enum => SUPPORTED_ENVS,
+ :desc => 'The environment to list.'
desc "list", "Lists instances."
def list()
AwsHelper.check_creds()
hosts = AwsHelper.get_hosts()
+ hosts.delete_if { |h| h.env != options[:env] } unless options[:env].nil?
+
+ fmt_str = "%34s %5s %8s %17s %7s"
+
puts
- puts "Instances"
- puts "---------"
- hosts.each { |h| puts " #{h.name}.#{h.env}" }
+ puts fmt_str % ['Name','Env', 'State', 'IP', 'Created By']
+ puts fmt_str % ['----','---', '-----', '--', '----------']
+ hosts.each { |h| puts fmt_str % [h.name, h.env, h.state, h.public_ip, h.created_by ] }
puts
end
diff --git a/lib/aws_helper.rb b/lib/aws_helper.rb
index 6d213107b..053f5267e 100644
--- a/lib/aws_helper.rb
+++ b/lib/aws_helper.rb
@@ -21,12 +21,14 @@ module OpenShift
retval << OpenStruct.new({
:name => info['ec2_tag_Name'],
:env => info['ec2_tag_environment'] || 'UNSET',
- :external_ip => info['ec2_ip_address'],
- :public_dns => info['ec2_public_dns_name']
+ :public_ip => info['ec2_ip_address'],
+ :public_dns => info['ec2_public_dns_name'],
+ :state => info['ec2_state'],
+ :created_by => info['ec2_tag_created-by']
})
end
- retval.sort_by! { |h| [h.env, h.name] }
+ retval.sort_by! { |h| [h.env, h.state, h.name] }
return retval
end