|
119 | 119 | """, |
120 | 120 | 'keys:remove': """Usage: deis keys:remove <key> |
121 | 121 | """, |
122 | | - 'layers:create': """Usage: deis layers:create <id> --flavor=<flavor> [options] |
| 122 | + 'layers:create': """Usage: deis layers:create <id> <flavor> --run_list=<run_list> [options] |
123 | 123 |
|
124 | 124 | Chef Options: |
125 | 125 |
|
126 | | ---run_list=RUN_LIST run-list to use when bootstrapping nodes |
127 | | ---environment=ENVIRONMENT chef environment to place nodes |
128 | | ---initial_attributes=INITIAL_ATTRS initial attributes for nodes |
| 126 | +--run_list=RUN_LIST run-list to use when bootstrapping nodes |
| 127 | +--environment=ENVIRONMENT chef environment to place nodes [default: _default] |
| 128 | +--attributes=INITIAL_ATTRS initial attributes for nodes |
129 | 129 |
|
130 | 130 | SSH Options: |
131 | 131 |
|
132 | 132 | --ssh_username=USERNAME username for ssh connections [default: ubuntu] |
133 | 133 | --ssh_private_key=PRIVATE_KEY private key for ssh comm (default: auto-gen) |
134 | 134 | --ssh_public_key=PUBLIC_KEY public key for ssh comm (default: auto-gen) |
135 | 135 |
|
| 136 | +""", |
| 137 | + 'layers:destroy': """Usage: deis layers:destroy <id> |
136 | 138 | """, |
137 | 139 | 'layers:scale': """Usage: deis layers:scale <type=num>... |
138 | 140 | """, |
@@ -533,13 +535,11 @@ def flavors_list(self, args): |
533 | 535 |
|
534 | 536 | def formations_create(self, args): |
535 | 537 | """Create a formation.""" |
536 | | - body = {'flavor': args['--flavor']} |
537 | | - formation_id = args.get('--id') |
538 | | - if formation_id: |
539 | | - body.update({'id': formation_id}) |
540 | | - image = args.get('--image') |
541 | | - if image: |
542 | | - body.update({'image': image}) |
| 538 | + body = {} |
| 539 | + for opt in ('--id', '--image'): |
| 540 | + o = args.get(opt) |
| 541 | + if o: |
| 542 | + body.update({opt.strip('-'): o}) |
543 | 543 | response = self._dispatch('post', '/api/formations', |
544 | 544 | json.dumps(body)) |
545 | 545 | if response.status_code == requests.codes.created: # @UndefinedVariable |
@@ -699,21 +699,36 @@ def layers_create(self, args): |
699 | 699 | formation = args.get('--formation') |
700 | 700 | if not formation: |
701 | 701 | formation = self._session.formation |
702 | | - body = {'id': args['<id>'], 'flavor': args['<flavor>']} |
703 | | - for opt in ('--run_list', '--environment', '--initial_attributes', |
| 702 | + body = {'id': args['<id>'], 'flavor': args['<flavor>'], 'run_list': args['--run_list']} |
| 703 | + for opt in ('--environment', '--initial_attributes', |
704 | 704 | '--ssh_username', '--ssh_private_key', '--ssh_public_key'): |
705 | 705 | o = args.get(opt) |
706 | 706 | if o: |
707 | 707 | body.update({opt.strip('-'): o}) |
708 | | - response = self._dispatch('post', '/api/formations/{}/layers'.format(formation), |
709 | | - json.dumps(body)) |
710 | 708 | sys.stdout.write('Creating layer {}...'.format(args['<id>'])) |
711 | 709 | sys.stdout.flush() |
| 710 | + response = self._dispatch('post', '/api/formations/{}/layers'.format(formation), |
| 711 | + json.dumps(body)) |
712 | 712 | if response.status_code == requests.codes.created: # @UndefinedVariable |
713 | 713 | print('done') |
714 | 714 | else: |
715 | 715 | print('Error!', response.text) |
716 | 716 |
|
| 717 | + def layers_destroy(self, args): |
| 718 | + """Destroy a layer of nodes.""" |
| 719 | + formation = args.get('--formation') |
| 720 | + if not formation: |
| 721 | + formation = self._session.formation |
| 722 | + layer = args['<id>'] |
| 723 | + sys.stdout.write('Destroying layer {layer}...'.format(**locals())) |
| 724 | + sys.stdout.flush() |
| 725 | + response = self._dispatch('delete', |
| 726 | + '/api/formations/{formation}/layers/{layer}'.format(**locals())) |
| 727 | + if response.status_code == requests.codes.no_content: # @UndefinedVariable |
| 728 | + print('done') |
| 729 | + else: |
| 730 | + print('Error!', response.text) |
| 731 | + |
717 | 732 | def layers_list(self, args): |
718 | 733 | """List layers for this formation.""" |
719 | 734 | formation = args.get('--formation') |
|
0 commit comments