Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Fixed #248 -- exposed deis layers:update in CLI.
Browse files Browse the repository at this point in the history
  • Loading branch information
mboersma committed Oct 28, 2013
1 parent 4190cef commit 0c6f8cd
Showing 1 changed file with 61 additions and 5 deletions.
66 changes: 61 additions & 5 deletions client/deis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,22 +1277,33 @@ def layers_create(self, args):
"""
Create a layer of nodes
Usage: deis layers:create <formation> <id> <flavor> [--proxy --runtime] [options]
SSH Options:
Usage: deis layers:create <formation> <id> <flavor> [options]
Options:
--proxy=<yn> layer can be used for proxy [default: y]
--runtime=<yn> layer can be used for runtime [default: y]
--ssh_username=USERNAME username for ssh connections [default: ubuntu]
--ssh_private_key=PRIVATE_KEY private key for ssh comm (default: auto-gen)
--ssh_public_key=PUBLIC_KEY public key for ssh comm (default: auto-gen)
--ssh_port=<port> port number for ssh comm (default: 22)
"""
formation = args.get('<formation>')
body = {'id': args['<id>'], 'flavor': args['<flavor>']}
for opt in ('--formation', '--proxy', '--runtime',
'--ssh_username', '--ssh_private_key', '--ssh_public_key'):
for opt in ('--formation', '--ssh_username', '--ssh_private_key',
'--ssh_public_key'):
o = args.get(opt)
if o:
body.update({opt.strip('-'): o})
o = args.get('--ssh_port')
if o:
body.update({'ssh_port': int(o)})
for opt in ('--proxy', '--runtime'):
o = args.get(opt)
if o and o.lower() in ['n', 'no', 'f', 'false', '0', 'off']:
body.update({opt.strip('-'): False})
else:
body.update({opt.strip('-'): True})
sys.stdout.write("Creating {} layer... ".format(args['<id>']))
sys.stdout.flush()
try:
Expand Down Expand Up @@ -1365,6 +1376,51 @@ def layers_list(self, args):
else:
raise ResponseError(response)

def layers_update(self, args):
"""
Create a layer of nodes
Usage: deis layers:update <formation> <id> [options]
Options:
--proxy=<yn> layer can be used for proxy [default: y]
--runtime=<yn> layer can be used for runtime [default: y]
--ssh_username=USERNAME username for ssh connections [default: ubuntu]
--ssh_private_key=PRIVATE_KEY private key for ssh comm (default: auto-gen)
--ssh_public_key=PUBLIC_KEY public key for ssh comm (default: auto-gen)
--ssh_port=<port> port number for ssh comm (default: 22)
"""
formation = args.get('<formation>')
layer = args['<id>'] # noqa
body = {'id': args['<id>']}
for opt in ('--ssh_username', '--ssh_private_key', '--ssh_public_key',
'--ssh_port'):
o = args.get(opt)
if o:
body.update({opt.strip('-'): o})
o = args.get('--ssh_port')
if o:
body.update({'ssh_port': int(o)})
for opt in ('--proxy', '--runtime'):
o = args.get(opt)
if o is not None:
if o.lower() in ['n', 'no', 'f', 'false', '0', 'off']:
body.update({opt.strip('-'): False})
else:
body.update({opt.strip('-'): True})
sys.stdout.write("Updating {} layer... ".format(args['<id>']))
sys.stdout.flush()
response = self._dispatch(
'patch', "/api/formations/{formation}/layers/{layer}".format(**locals()),
json.dumps(body))
if response.status_code == requests.codes.ok: # @UndefinedVariable
print('done.')
print(json.dumps(response.json(), indent=2))
else:
raise ResponseError(response)

def nodes(self, args):
"""
Valid commands for nodes:
Expand Down

0 comments on commit 0c6f8cd

Please sign in to comment.