from kamaki.cli import command
from kamaki.cli.command_tree import CommandTree
-from kamaki.cli.utils import print_dict
+from kamaki.cli.utils import print_dict, remove_from_items
from kamaki.cli.errors import raiseCLIError, CLISyntaxError, CLIBaseUrlError
from kamaki.clients.cyclades import CycladesClient, ClientError
from kamaki.cli.argument import FlagArgument, ValueArgument, KeyValueArgument
@errors.cyclades.date
def _run(self):
servers = self.client.list_servers(self['detail'], self['since'])
+ if not (self['detail'] or self['json_output']):
+ remove_from_items(servers, 'links')
kwargs = dict(with_enumeration=self['enum'])
if self['more']:
@errors.cyclades.connection
def _run(self):
flavors = self.client.list_flavors(self['detail'])
+ if not (self['detail'] or self['json_output']):
+ remove_from_items(flavors, 'links')
pg_size = 10 if self['more'] and not self['limit'] else self['limit']
self._print(
flavors,
@errors.cyclades.connection
def _run(self):
networks = self.client.list_networks(self['detail'])
+ if not (self['detail'] or self['json_output']):
+ remove_from_items(networks, 'links')
kwargs = dict(with_enumeration=self['enum'])
if self['more']:
kwargs['page_size'] = self['limit'] or 10
if path.isfile(f):
total_size += path.getsize(f)
return total_size
+
+
+def remove_from_items(list_of_dicts, key_to_remove):
+ for item in list_of_dicts:
+ assert isinstance(item, dict), 'Item %s not a dict' % item
+ item.pop(key_to_remove, None)