Revision a494a741 kamaki/cli/commands/cyclades_cli.py
b/kamaki/cli/commands/cyclades_cli.py | ||
---|---|---|
1 |
# Copyright 2012 GRNET S.A. All rights reserved.
|
|
1 |
# Copyright 2011-2013 GRNET S.A. All rights reserved.
|
|
2 | 2 |
# |
3 | 3 |
# Redistribution and use in source and binary forms, with or |
4 | 4 |
# without modification, are permitted provided that the following |
... | ... | |
33 | 33 |
|
34 | 34 |
from kamaki.cli import command |
35 | 35 |
from kamaki.cli.command_tree import CommandTree |
36 |
from kamaki.cli.utils import print_dict, print_list, bold |
|
36 |
from kamaki.cli.utils import print_dict, print_list, print_items, bold
|
|
37 | 37 |
from kamaki.cli.errors import raiseCLIError, CLISyntaxError |
38 | 38 |
from kamaki.clients.cyclades import CycladesClient, ClientError |
39 | 39 |
from kamaki.cli.argument import FlagArgument, ValueArgument, KeyValueArgument |
... | ... | |
437 | 437 |
super(flavor_list, self).__init__(arguments) |
438 | 438 |
self.arguments['detail'] = FlagArgument('show detailed output', '-l') |
439 | 439 |
|
440 |
@classmethod |
|
441 |
def _print(self, flist): |
|
442 |
for i, flavor in enumerate(flist): |
|
443 |
print(bold('%s. %s' % (i, flavor['name']))) |
|
444 |
print_dict(flavor, exclude=('name'), ident=1) |
|
445 |
|
|
446 | 440 |
def main(self): |
447 | 441 |
super(self.__class__, self).main() |
448 | 442 |
try: |
449 | 443 |
flavors = self.client.list_flavors(self.get_argument('detail')) |
450 | 444 |
except Exception as err: |
451 | 445 |
raiseCLIError(err) |
452 |
self._print(flavors)
|
|
446 |
print_items(flavors, with_redundancy=self.get_argument('detail'))
|
|
453 | 447 |
|
454 | 448 |
|
455 | 449 |
@command(flavor_cmds) |
Also available in: Unified diff