Revision 93914390
b/kamaki/cli/commands/cyclades_cli.py | ||
---|---|---|
72 | 72 |
detail=FlagArgument('show detailed output', '-l') |
73 | 73 |
) |
74 | 74 |
|
75 |
def __init__(self, arguments={}): |
|
76 |
super(server_list, self).__init__(arguments) |
|
77 |
|
|
78 | 75 |
def _info_print(self, server): |
79 | 76 |
addr_dict = {} |
80 | 77 |
if 'attachments' in server: |
... | ... | |
173 | 170 |
class server_create(_init_cyclades): |
174 | 171 |
"""Create a server""" |
175 | 172 |
|
176 |
def __init__(self, arguments={}): |
|
177 |
super(server_create, self).__init__(arguments) |
|
178 |
self.arguments['personality'] = PersonalityArgument(\ |
|
173 |
arguments = dict( |
|
174 |
personality=PersonalityArgument( |
|
179 | 175 |
'add one or more personality files ( ' +\ |
180 |
'"PATH,[SERVER_PATH,[OWNER,[GROUP,[MODE]]]]" )', |
|
176 |
'"PATH,[SERVER_PATH,[OWNER,[GROUP,[MODE]]]]" )',
|
|
181 | 177 |
parsed_name='--personality') |
178 |
) |
|
182 | 179 |
|
183 | 180 |
def main(self, name, flavor_id, image_id): |
184 | 181 |
super(self.__class__, self).main() |
185 | 182 |
|
186 | 183 |
try: |
187 |
reply = self.client.create_server(name, |
|
188 |
int(flavor_id), |
|
189 |
image_id, |
|
190 |
self.get_argument('personality')) |
|
184 |
reply = self.client.create_server( |
|
185 |
name, |
|
186 |
int(flavor_id), |
|
187 |
image_id, |
|
188 |
self['personality'] |
|
189 |
) |
|
191 | 190 |
except ClientError as err: |
192 | 191 |
raiseCLIError(err) |
193 | 192 |
except ValueError as err: |
... | ... | |
232 | 231 |
@command(server_cmds) |
233 | 232 |
class server_reboot(_init_cyclades): |
234 | 233 |
"""Reboot a server""" |
235 |
|
|
236 |
def __init__(self, arguments={}):
|
|
237 |
super(server_reboot, self).__init__(arguments)
|
|
238 |
self.arguments['hard'] = FlagArgument('perform a hard reboot', '-f')
|
|
234 |
|
|
235 |
arguments = dict(
|
|
236 |
hard=FlagArgument('perform a hard reboot', '-f')
|
|
237 |
) |
|
239 | 238 |
|
240 | 239 |
def main(self, server_id): |
241 | 240 |
super(self.__class__, self).main() |
242 | 241 |
try: |
243 |
self.client.reboot_server(int(server_id), |
|
244 |
self.get_argument('hard')) |
|
242 |
self.client.reboot_server(int(server_id), self['hard']) |
|
245 | 243 |
except ValueError as err: |
246 | 244 |
raiseCLIError(err, 'Server id must be positive integer', 1) |
247 | 245 |
except Exception as err: |
... | ... | |
401 | 399 |
class server_wait(_init_cyclades): |
402 | 400 |
"""Wait for server to finish [BUILD, STOPPED, REBOOT, ACTIVE]""" |
403 | 401 |
|
404 |
def __init__(self, arguments={}): |
|
405 |
super(self.__class__, self).__init__(arguments) |
|
406 |
self.arguments['progress_bar'] = ProgressBarArgument(\ |
|
407 |
'do not show progress bar', '--no-progress-bar', False) |
|
402 |
arguments = dict( |
|
403 |
progress_bar=ProgressBarArgument( |
|
404 |
'do not show progress bar', |
|
405 |
'--no-progress-bar', |
|
406 |
False |
|
407 |
) |
|
408 |
) |
|
408 | 409 |
|
409 | 410 |
def main(self, server_id, currect_status='BUILD'): |
410 | 411 |
super(self.__class__, self).main() |
... | ... | |
436 | 437 |
class flavor_list(_init_cyclades): |
437 | 438 |
"""List flavors""" |
438 | 439 |
|
439 |
def __init__(self, arguments={}):
|
|
440 |
super(flavor_list, self).__init__(arguments)
|
|
441 |
self.arguments['detail'] = FlagArgument('show detailed output', '-l')
|
|
440 |
arguments = dict(
|
|
441 |
detail=FlagArgument('show detailed output', '-l')
|
|
442 |
) |
|
442 | 443 |
|
443 | 444 |
def main(self): |
444 | 445 |
super(self.__class__, self).main() |
445 | 446 |
try: |
446 |
flavors = self.client.list_flavors(self.get_argument('detail'))
|
|
447 |
flavors = self.client.list_flavors(self['detail'])
|
|
447 | 448 |
except Exception as err: |
448 | 449 |
raiseCLIError(err) |
449 |
print_items(flavors, with_redundancy=self.get_argument('detail'))
|
|
450 |
print_items(flavors, with_redundancy=self['detail'])
|
|
450 | 451 |
|
451 | 452 |
|
452 | 453 |
@command(flavor_cmds) |
... | ... | |
489 | 490 |
class network_list(_init_cyclades): |
490 | 491 |
"""List networks""" |
491 | 492 |
|
492 |
def __init__(self, arguments={}):
|
|
493 |
super(network_list, self).__init__(arguments)
|
|
494 |
self.arguments['detail'] = FlagArgument('show detailed output', '-l')
|
|
493 |
arguments = dict(
|
|
494 |
detail=FlagArgument('show detailed output', '-l')
|
|
495 |
) |
|
495 | 496 |
|
496 | 497 |
def print_networks(self, nets): |
497 | 498 |
for net in nets: |
498 | 499 |
netname = bold(net.pop('name')) |
499 | 500 |
netid = bold(unicode(net.pop('id'))) |
500 | 501 |
print('%s (%s)' % (netid, netname)) |
501 |
if self.get_argument('detail'):
|
|
502 |
if self['detail']:
|
|
502 | 503 |
network_info.print_network(net) |
503 | 504 |
|
504 | 505 |
def main(self): |
505 | 506 |
super(self.__class__, self).main() |
506 | 507 |
try: |
507 |
networks = self.client.list_networks(self.get_argument('detail'))
|
|
508 |
networks = self.client.list_networks(self['detail'])
|
|
508 | 509 |
except Exception as err: |
509 | 510 |
raiseCLIError(err) |
510 | 511 |
self.print_networks(networks) |
... | ... | |
514 | 515 |
class network_create(_init_cyclades): |
515 | 516 |
"""Create a network""" |
516 | 517 |
|
517 |
def __init__(self, arguments={}): |
|
518 |
super(network_create, self).__init__(arguments) |
|
519 |
self.arguments['cidr'] =\ |
|
520 |
ValueArgument('specific cidr for new network', '--with-cidr') |
|
521 |
self.arguments['gateway'] =\ |
|
522 |
ValueArgument('specific gateway for new network', '--with-gateway') |
|
523 |
self.arguments['dhcp'] =\ |
|
524 |
ValueArgument('specific dhcp for new network', '--with-dhcp') |
|
525 |
self.arguments['type'] =\ |
|
526 |
ValueArgument('specific type for new network', '--with-type') |
|
518 |
arguments = dict( |
|
519 |
cidr=ValueArgument('specify cidr', '--with-cidr'), |
|
520 |
gateway=ValueArgument('specify gateway', '--with-gateway'), |
|
521 |
dhcp=ValueArgument('specify dhcp', '--with-dhcp'), |
|
522 |
type=ValueArgument('specify type', '--with-type') |
|
523 |
) |
|
527 | 524 |
|
528 | 525 |
def main(self, name): |
529 | 526 |
super(self.__class__, self).main() |
530 | 527 |
try: |
531 | 528 |
reply = self.client.create_network(name, |
532 |
cidr=self.get_argument('cidr'),
|
|
533 |
gateway=self.get_argument('gateway'),
|
|
534 |
dhcp=self.get_argument('dhcp'),
|
|
535 |
type=self.get_argument('type'))
|
|
529 |
cidr=self['cidr'],
|
|
530 |
gateway=self['gateway'],
|
|
531 |
dhcp=self['dhcp'],
|
|
532 |
type=self['type'])
|
|
536 | 533 |
except Exception as err: |
537 | 534 |
raiseCLIError(err) |
538 | 535 |
print_dict(reply) |
Also available in: Unified diff