Skip to content

Commit bbfad86

Browse files
author
Gabriel Monroy
committed
add formation info and node destroy
1 parent f60c9e4 commit bbfad86

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

client/deis/client.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@
102102
'flavors:list': """Usage: deis flavors:list
103103
""",
104104
'formations:create': """Usage: deis formations:create --flavor=<flavor> [--image=<image> --id=<id>]
105+
""",
106+
'formations:list': """Usage: deis formations:info
105107
""",
106108
'formations:list': """Usage: deis formations:list
107109
""",
@@ -112,6 +114,8 @@
112114
'formations:calculate': """Usage: deis formations:calculate
113115
""",
114116
'formations:balance': """Usage: deis formations:balance
117+
""",
118+
'info': """Usage: deis info
115119
""",
116120
'keys:add': """Usage: deis keys:add [<key>]
117121
""",
@@ -146,7 +150,7 @@
146150
""",
147151
'nodes:list': """Usage: deis nodes:list
148152
""",
149-
'nodes:delete': """Usage: deis nodes:delete <id>
153+
'nodes:destroy': """Usage: deis nodes:destroy <id>
150154
""",
151155
'providers:create': """Usage: deis providers:create --type=<type> [--id=<id> --creds=<creds>]
152156
""",
@@ -567,6 +571,17 @@ def formations_list(self, args):
567571
else:
568572
print('Error!', response.text)
569573

574+
def formations_info(self, args):
575+
"""Retrieve formation info"""
576+
formation = args.get('<formation>')
577+
if not formation:
578+
formation = self._session.formation
579+
response = self._dispatch('get', '/api/formations/{}'.format(formation))
580+
if response.status_code == requests.codes.ok: # @UndefinedVariable
581+
print(json.dumps(response.json(), indent=2))
582+
else:
583+
print('Error!', response.text)
584+
570585
def formations_destroy(self, args):
571586
formation = args.get('<formation>')
572587
if not formation:
@@ -787,13 +802,18 @@ def nodes_list(self, args):
787802
else:
788803
print('Error!', response.text)
789804

790-
def nodes_delete(self, args):
791-
"""Delete a node by ID."""
805+
def nodes_destroy(self, args):
806+
"""Destroy a node by ID."""
807+
formation = args.get('--formation')
808+
if not formation:
809+
formation = self._session.formation
792810
node = args['<id>']
793811
response = self._dispatch('delete',
794-
'/api/nodes/{}'.format(node))
812+
'/api/formations/{formation}/nodes/{node}'.format(**locals()))
813+
sys.stdout.write('Destroying {}... '.format(node))
814+
sys.stdout.flush()
795815
if response.status_code == requests.codes.no_content: # @UndefinedVariable
796-
print('Node deleted successfully')
816+
print('done')
797817
else:
798818
print('Error!', response.status_code, response.text)
799819

@@ -899,6 +919,7 @@ def main():
899919
'login': cli.auth_login,
900920
'logout': cli.auth_logout,
901921
'create': cli.formations_create,
922+
'info': cli.formations_info,
902923
'destroy': cli.formations_destroy,
903924
'scale': cli.containers_scale,
904925
'calculate': cli.formations_calculate,

0 commit comments

Comments
 (0)