Skip to content

Commit cb9906d

Browse files
author
Gabriel Monroy
committed
cleanup create, scale, destroy workflow and output #16
1 parent 2d5823e commit cb9906d

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

client/deis/client.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def flavors_list(self, args):
487487

488488
def formations_create(self, args):
489489
"""
490-
Usage: deis formations:create [--flavor=<flavor> --id=<id>]
490+
Usage: deis formations:create [--id=<id> --flavor=<flavor>]
491491
"""
492492
body = {}
493493
for opt in ('--id',):
@@ -501,7 +501,7 @@ def formations_create(self, args):
501501
if response.status_code == requests.codes.created: # @UndefinedVariable
502502
data = response.json()
503503
formation = data['id']
504-
print 'done, created {}'.format(formation)
504+
print('done, created {}'.format(formation))
505505
# add a git remote
506506
hostname = urlparse.urlparse(self._settings['controller']).netloc
507507
git_remote = 'git@{hostname}:{formation}.git'.format(**locals())
@@ -511,7 +511,13 @@ def formations_create(self, args):
511511
stdout=subprocess.PIPE)
512512
except subprocess.CalledProcessError:
513513
sys.exit(1)
514-
print('Git remote deis added')
514+
print('Git remote deis added\n')
515+
# create default layers if a flavor was provided
516+
flavor = args.get('--flavor')
517+
if flavor:
518+
self.layers_create({'<id>': 'runtime', '<flavor>': flavor})
519+
self.layers_create({'<id>': 'proxy', '<flavor>': flavor})
520+
print('\nUse `deis layers:scale runtime=1 proxy=1` to scale a basic formation\n')
515521
else:
516522
print('Error!', response.text)
517523

@@ -560,7 +566,8 @@ def formations_destroy(self, args):
560566
if confirm != formation:
561567
print('Destroy aborted')
562568
return
563-
print 'Destroying {0}...'.format(formation),
569+
sys.stdout.write('Destroying {}... '.format(formation))
570+
sys.stdout.flush()
564571
response = self._dispatch('delete', '/api/formations/{}'.format(formation))
565572
if response.status_code in (requests.codes.no_content, requests.codes.not_found): # @UndefinedVariable
566573
print('done')
@@ -782,12 +789,14 @@ def layers_scale(self, args):
782789
for type_num in args.get('<type=num>'):
783790
typ, count = type_num.split('=')
784791
body.update({typ: int(count)})
792+
print('Scaling layers... but first, coffee!')
793+
# TODO: add threaded spinner to print dots
785794
response = self._dispatch('post',
786795
'/api/formations/{}/scale/layers'.format(formation),
787796
json.dumps(body))
788797
if response.status_code == requests.codes.ok: # @UndefinedVariable
789-
databag = json.loads(response.content)
790-
print(json.dumps(databag, indent=2))
798+
print('...done\n')
799+
print('Use `git push deis master` to deploy to your formation')
791800
else:
792801
print('Error!', response.text)
793802

0 commit comments

Comments
 (0)