Last active
August 29, 2015 14:01
-
-
Save kszarek/20043a054ab035b573c3 to your computer and use it in GitHub Desktop.
faf show
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@task | |
def show(debug=False): | |
"""Show server list via EC2""" | |
instances = get_instances_map(debug) | |
sorted_instances = sorted(instances, key=lambda instance: instance['name']) | |
print 'Instance ID Name ', | |
print 'Public IP Private IP Flavor State', | |
print ' Status Prev Version Current Version Next Version' | |
for instance in sorted_instances: | |
print "{0:11s}".format(instance['id']), | |
print "{0:16s}".format(instance['name']), | |
print "{0:14s}".format(instance['ip']), | |
print "{0:13s}".format(instance['privateIp']), | |
print "{0:10s}".format(instance['type']), | |
if instance['state'] == 'running': | |
print(green("running")), | |
elif instance['state'] == 'stopped': | |
print(yellow('stopped')), | |
elif instance['state'] == 'terminated': | |
print(red('terminated')), | |
else: | |
print(instance['state']), | |
if instance['status'] == 'InService': | |
print(green("{0:12s}".format(instance['status']))), | |
elif instance['status'] == 'OutOfService': | |
print(red("{0:12s}".format(instance['status']))), | |
else: | |
print("{0:12s}".format(instance['status'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment