Commit 2afb8137 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Remove "PERMANENTS" from kamaki.cli.cmds classes

Resolves #9

This variable was used only once per case
parent ea8f09c3
...@@ -121,8 +121,6 @@ class server_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter): ...@@ -121,8 +121,6 @@ class server_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
Use filtering arguments (e.g., --name-like) to manage long server lists Use filtering arguments (e.g., --name-like) to manage long server lists
""" """
PERMANENTS = ('id', 'name')
arguments = dict( arguments = dict(
detail=FlagArgument('show detailed output', ('-l', '--details')), detail=FlagArgument('show detailed output', ('-l', '--details')),
since=DateArgument( since=DateArgument(
...@@ -215,7 +213,7 @@ class server_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter): ...@@ -215,7 +213,7 @@ class server_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
pass pass
else: else:
for srv in servers: for srv in servers:
for key in set(srv).difference(self.PERMANENTS): for key in set(srv).difference(['id', 'name']):
srv.pop(key) srv.pop(key)
kwargs = dict(with_enumeration=self['enum']) kwargs = dict(with_enumeration=self['enum'])
...@@ -809,8 +807,6 @@ class server_wait(_CycladesInit, _ServerWait): ...@@ -809,8 +807,6 @@ class server_wait(_CycladesInit, _ServerWait):
class flavor_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter): class flavor_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
"""List available hardware flavors""" """List available hardware flavors"""
PERMANENTS = ('id', 'name')
arguments = dict( arguments = dict(
detail=FlagArgument('show detailed output', ('-l', '--details')), detail=FlagArgument('show detailed output', ('-l', '--details')),
limit=IntArgument('limit # of listed flavors', ('-n', '--number')), limit=IntArgument('limit # of listed flavors', ('-n', '--number')),
...@@ -852,7 +848,7 @@ class flavor_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter): ...@@ -852,7 +848,7 @@ class flavor_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
remove_from_items(flavors, 'links') remove_from_items(flavors, 'links')
if detail and not self['detail']: if detail and not self['detail']:
for flv in flavors: for flv in flavors:
for key in set(flv).difference(self.PERMANENTS): for key in set(flv).difference(['id', 'name']):
flv.pop(key) flv.pop(key)
kwargs = dict(out=StringIO(), title=()) if self['more'] else {} kwargs = dict(out=StringIO(), title=()) if self['more'] else {}
self.print_( self.print_(
......
...@@ -123,10 +123,6 @@ def load_image_meta(filepath): ...@@ -123,10 +123,6 @@ def load_image_meta(filepath):
class image_list(_ImageInit, OptionalOutput, NameFilter, IDFilter): class image_list(_ImageInit, OptionalOutput, NameFilter, IDFilter):
"""List images accessible by user""" """List images accessible by user"""
PERMANENTS = (
'id', 'name',
'status', 'container_format', 'disk_format', 'size')
arguments = dict( arguments = dict(
detail=FlagArgument('show detailed output', ('-l', '--details')), detail=FlagArgument('show detailed output', ('-l', '--details')),
container_format=ValueArgument( container_format=ValueArgument(
...@@ -222,7 +218,9 @@ class image_list(_ImageInit, OptionalOutput, NameFilter, IDFilter): ...@@ -222,7 +218,9 @@ class image_list(_ImageInit, OptionalOutput, NameFilter, IDFilter):
images = self._add_owner_name(images) images = self._add_owner_name(images)
elif detail and not self['detail']: elif detail and not self['detail']:
for img in images: for img in images:
for key in set(img).difference(self.PERMANENTS): for key in set(img).difference([
'id', 'name', 'status', 'container_format',
'disk_format', 'size']):
img.pop(key) img.pop(key)
kwargs = dict(with_enumeration=self['enum']) kwargs = dict(with_enumeration=self['enum'])
if self['limit']: if self['limit']:
...@@ -585,9 +583,6 @@ class image_unregister(_ImageInit): ...@@ -585,9 +583,6 @@ class image_unregister(_ImageInit):
@command(imagecompute_cmds) @command(imagecompute_cmds)
class imagecompute_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter): class imagecompute_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
"""List images""" """List images"""
PERMANENTS = ('id', 'name')
arguments = dict( arguments = dict(
detail=FlagArgument('show detailed output', ('-l', '--details')), detail=FlagArgument('show detailed output', ('-l', '--details')),
limit=IntArgument('limit number listed images', ('-n', '--number')), limit=IntArgument('limit number listed images', ('-n', '--number')),
...@@ -643,7 +638,7 @@ class imagecompute_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter): ...@@ -643,7 +638,7 @@ class imagecompute_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
images = self._add_name(self._add_name(images, 'tenant_id')) images = self._add_name(self._add_name(images, 'tenant_id'))
elif detail and not self['detail']: elif detail and not self['detail']:
for img in images: for img in images:
for key in set(img).difference(self.PERMANENTS): for key in set(img).difference(['id', 'name']):
img.pop(key) img.pop(key)
kwargs = dict(with_enumeration=self['enum']) kwargs = dict(with_enumeration=self['enum'])
if self['limit']: if self['limit']:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment