Skip to content

Commit

Permalink
Implement status command
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljoseph committed Jul 6, 2012
1 parent 93ad244 commit 220b1ec
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions righteous/cli.py
Expand Up @@ -197,6 +197,8 @@ def initialise(arguments):
puts_err(colored.red('Authentication failed'))
exit(2)

return verbose

def list(arguments):
initialise(arguments)
servers = righteous.list_servers()
Expand All @@ -211,8 +213,33 @@ def stop():
def delete():
print 'deleting'

def status():
print 'status'
def status(arguments):
verbose = initialise(arguments)
envs = arguments['<environment>']

if envs:
puts(columns(
[(colored.green('Nickname')), 15],
[(colored.green('Instance Type')), 10],
[(colored.green('Status')), 20],
[(colored.green('Instance href')), 60],
))

for env in envs:
server = righteous.find_server(env)
settings = righteous.server_settings(server['href'])
if server and verbose:
server_info = righteous.server_info(server['href'])
puts(colored.cyan(pformat(server_info)))
puts(colored.cyan(pformat(settings)))

puts(columns(
[env, 15],
[settings['ec2-instance-type'], 10],
[server['state'] if server else 'Found', 20],
[server['href'] if server else 'Not', 60],

))

if __name__ == '__main__':
arguments = docopt(__doc__, version='righteous cli')
Expand Down

0 comments on commit 220b1ec

Please sign in to comment.