Commit a5acf923 authored by Stavros Sachtouris's avatar Stavros Sachtouris

Modify member methods in kamaki.cli.cmds classes

Refs #9

Renamed:
kamaki.cli.cmds._optional_json: _print --> print_
kamaki.cli.cmds.cyclades.Wait: _wait --> wait
kamaki.cli.cmds.cyclades.ServerWait: _wait --> wait
kamaki.cli.cmds.image: _load_image_meta --> load_image_meta
kamak.cli.cmds.network: _wait --> wait
kamaki.cli.cmds.pithos.PithosAccount:
    _is_dir --> obj_is_dir
    _resolve_pithos_url --> resolve_pithos_url

Removed:
kamaki.cli.cmds.pithos.PithosAccount:
    _validate_image_meta, _validate_image_location
parent e116c9ca
......@@ -312,7 +312,7 @@ class OptionalOutput(object):
'--output-format'),
)
def _print(self, output, print_method=print_items, **print_method_kwargs):
def print_(self, output, print_method=print_items, **print_method_kwargs):
if self['output_format']:
func = OutputFormatArgument.formats[self['output_format']]
func(output, out=self)
......@@ -385,7 +385,7 @@ class Wait(object):
'do not show progress bar', ('-N', '--no-progress-bar'), False)
)
def _wait(
def wait(
self, service, service_id, status_method, current_status,
countdown=True, timeout=60):
(progress_bar, wait_cb) = self._safe_progress_bar(
......
......@@ -123,7 +123,7 @@ class user_authenticate(_AstakosInit, OptionalOutput):
@errors.Astakos.astakosclient
@with_temp_token
def _run(self):
self._print(self.client.authenticate(), self.print_dict)
self.print_(self.client.authenticate(), self.print_dict)
def main(self, token=None):
super(self.__class__, self)._run()
......@@ -138,7 +138,7 @@ class user_uuid2name(_AstakosInit, OptionalOutput):
#@errors.Astakos.astakosclient
def _run(self, uuids):
r = self.client.get_usernames(uuids)
self._print(r, self.print_dict)
self.print_(r, self.print_dict)
unresolved = set(uuids).difference(r)
if unresolved:
self.error('Unresolved uuids: %s' % ', '.join(unresolved))
......@@ -156,7 +156,7 @@ class user_name2uuid(_AstakosInit, OptionalOutput):
@errors.Astakos.astakosclient
def _run(self, usernames):
r = self.client.get_uuids(usernames)
self._print(r, self.print_dict)
self.print_(r, self.print_dict)
unresolved = set(usernames).difference(r)
if unresolved:
self.error('Unresolved usernames: %s' % ', '.join(unresolved))
......@@ -209,7 +209,7 @@ class quota_list(_AstakosInit, OptionalOutput):
if not d:
raise CLIError('Resource "%s" not found' % self['resource'])
quotas = d
self._print(quotas, self._print_quotas)
self.print_(quotas, self._print_quotas)
def main(self):
super(self.__class__, self)._run()
......@@ -248,7 +248,7 @@ class user_info(_AstakosInit, OptionalOutput):
' /user list',
'To authenticate and add a new user in the session list',
' /user add <new token>'])
self._print(self.auth_base.user_info(token), self.print_dict)
self.print_(self.auth_base.user_info(token), self.print_dict)
@command(user_cmds)
......@@ -259,7 +259,7 @@ class user_add(_AstakosInit, OptionalOutput):
@errors.Astakos.astakosclient
def _run(self, token=None):
ask = token and token not in self.auth_base._uuids
self._print(self.auth_base.authenticate(token), self.print_dict)
self.print_(self.auth_base.authenticate(token), self.print_dict)
if ask and self.ask_user(
'Token is temporarily stored in memory. If it is stored in'
' kamaki configuration file, it will be available in later'
......@@ -286,7 +286,7 @@ class user_list(_AstakosInit, OptionalOutput):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self):
self._print([u if self['detail'] else (dict(
self.print_([u if self['detail'] else (dict(
id=u['id'], name=u['name'])) for u in self.auth_base.list_users()])
def main(self):
......@@ -378,7 +378,7 @@ class service_list(_AstakosInit, OptionalOutput):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self):
self._print(self.client.get_services())
self.print_(self.client.get_services())
def main(self):
super(self.__class__, self)._run()
......@@ -394,9 +394,9 @@ class service_uuid2username(_AstakosInit, OptionalOutput):
@with_temp_token
def _run(self, uuids):
if 1 == len(uuids):
self._print(self.client.service_get_username(uuids[0]))
self.print_(self.client.service_get_username(uuids[0]))
else:
self._print(
self.print_(
self.client.service_get_usernames(uuids),
self.print_dict)
......@@ -414,9 +414,9 @@ class service_username2uuid(_AstakosInit, OptionalOutput):
@with_temp_token
def _run(self, usernames):
if 1 == len(usernames):
self._print(self.client.service_get_uuid(usernames[0]))
self.print_(self.client.service_get_uuid(usernames[0]))
else:
self._print(
self.print_(
self.client.service_get_uuids(usernames),
self.print_dict)
......@@ -437,7 +437,7 @@ class service_quotas(_AstakosInit, OptionalOutput):
@errors.Astakos.astakosclient
@with_temp_token
def _run(self):
self._print(self.client.service_get_quotas(self['uuid']))
self.print_(self.client.service_get_quotas(self['uuid']))
def main(self, service_token):
super(self.__class__, self)._run()
......@@ -451,7 +451,7 @@ class commission_pending(_AstakosInit, OptionalOutput):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self):
self._print(self.client.get_pending_commissions())
self.print_(self.client.get_pending_commissions())
def main(self):
super(self.__class__, self)._run()
......@@ -466,7 +466,7 @@ class commission_info(_AstakosInit, OptionalOutput):
@errors.Astakos.astakosclient
def _run(self, commission_id):
commission_id = int(commission_id)
self._print(
self.print_(
self.client.get_commission_info(commission_id), self.print_dict)
def main(self, commission_id):
......@@ -522,7 +522,7 @@ class commission_resolve(_AstakosInit, OptionalOutput):
def _run(self):
self.writeln('accepted ', self['accept'])
self.writeln('rejected ', self['reject'])
self._print(
self.print_(
self.client.resolve_commissions(self['accept'], self['reject']),
self.print_dict)
......@@ -550,7 +550,7 @@ class commission_issue(_AstakosInit, OptionalOutput):
@errors.Astakos.astakosclient
def _run(self, holder, source, provisions, name=''):
provisions = loads(provisions)
self._print(self.client.issue_one_commission(
self.print_(self.client.issue_one_commission(
holder, source, provisions, name,
self['force'], self['accept']))
......@@ -566,7 +566,7 @@ class resource_list(_AstakosInit, OptionalOutput):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self):
self._print(self.client.get_resources(), self.print_dict)
self.print_(self.client.get_resources(), self.print_dict)
def main(self):
super(self.__class__, self)._run()
......@@ -586,7 +586,7 @@ class endpoint_list(_AstakosInit, OptionalOutput, NameFilter):
r = self._filter_by_name(r)
if self['endpoint_type']:
r = filter_dicts_by_dict(r, dict(type=self['endpoint_type']))
self._print(r)
self.print_(r)
def main(self):
super(self.__class__, self)._run()
......@@ -643,7 +643,7 @@ class project_list(_AstakosInit, OptionalOutput):
id=i['id'],
name=i['name'],
description=i['description']) for i in r]
self._print(r)
self.print_(r)
def main(self):
super(self.__class__, self)._run()
......@@ -657,7 +657,7 @@ class project_info(_AstakosInit, OptionalOutput):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self, project_id):
self._print(
self.print_(
self.client.get_project(project_id), self.print_dict)
def main(self, project_id):
......@@ -772,7 +772,7 @@ class project_create(_AstakosInit, OptionalOutput):
('resources', self['resource_capacities'])):
if arg:
specs[key] = arg
self._print(self.client.create_project(specs), self.print_dict)
self.print_(self.client.create_project(specs), self.print_dict)
def main(self):
super(self.__class__, self)._run()
......@@ -847,7 +847,7 @@ class project_modify(_AstakosInit, OptionalOutput):
if private is not None:
self['private'] = private
self._print(
self.print_(
self.client.modify_project(project_id, specs), self.print_dict)
def main(self, project_id):
......@@ -964,7 +964,7 @@ class membership_list(_AstakosInit, OptionalOutput):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self):
self._print(self.client.get_memberships(self['project']))
self.print_(self.client.get_memberships(self['project']))
def main(self):
super(self.__class__, self)._run()
......@@ -978,7 +978,7 @@ class membership_info(_AstakosInit, OptionalOutput):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self, memb_id):
self._print(
self.print_(
self.client.get_membership(memb_id), self.print_dict)
def main(self, membership_id):
......@@ -994,7 +994,7 @@ class _MembershipAction(_AstakosInit, OptionalOutput):
@errors.Generic.all
@errors.Astakos.astakosclient
def _run(self, memb_id, quote_a_reason):
self._print(self.client.membership_action(
self.print_(self.client.membership_action(
memb_id, self.action, quote_a_reason))
def main(self, membership_id):
......
......@@ -69,8 +69,8 @@ server_states = ('BUILD', 'ACTIVE', 'STOPPED', 'REBOOT')
class _ServerWait(Wait):
def _wait(self, server_id, current_status, timeout=60):
super(_ServerWait, self)._wait(
def wait(self, server_id, current_status, timeout=60):
super(_ServerWait, self).wait(
'Server', server_id, self.client.wait_server, current_status,
countdown=(current_status not in ('BUILD', )),
timeout=timeout if current_status not in ('BUILD', ) else 100)
......@@ -228,7 +228,7 @@ class server_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
kwargs['title'] = ()
if self['limit']:
servers = servers[:self['limit']]
self._print(servers, **kwargs)
self.print_(servers, **kwargs)
if self['more']:
pager(kwargs['out'].getvalue())
......@@ -254,17 +254,16 @@ class server_info(_CycladesInit, OptionalOutput):
@errors.Cyclades.server_id
def _run(self, server_id):
if self['nics']:
self._print(
self.print_(
self.client.get_server_nics(server_id), self.print_dict)
elif self['stats']:
self._print(
self.print_(
self.client.get_server_stats(server_id), self.print_dict)
elif self['diagnostics']:
self._print(self.client.get_server_diagnostics(server_id))
self.print_(self.client.get_server_diagnostics(server_id))
else:
vm = self.client.get_server_details(server_id)
# self._print(self._restruct_server_info(vm), self.print_dict)
self._print(vm, self.print_dict)
self.print_(vm, self.print_dict)
def main(self, server_id):
super(self.__class__, self)._run()
......@@ -450,7 +449,7 @@ class server_create(_CycladesInit, OptionalOutput, _ServerWait):
s['name'] in requested_names)]
self.error('Failed to build %s servers' % size)
self.error('Found %s matching servers:' % len(spawned_servers))
self._print(spawned_servers, out=self._err)
self.print_(spawned_servers, out=self._err)
self.error('Check if any of these servers should be removed\n')
except Exception as ne:
self.error('Error (%s) while notifying about errors' % ne)
......@@ -468,10 +467,9 @@ class server_create(_CycladesInit, OptionalOutput, _ServerWait):
if not r:
self.error('Create %s: server response was %s' % (name, r))
continue
# self._print(self._restruct_server_info(r), self.print_dict)
self._print(r, self.print_dict)
self.print_(r, self.print_dict)
if self['wait']:
self._wait(r['id'], r['status'] or 'BUILD')
self.wait(r['id'], r['status'] or 'BUILD')
self.writeln(' ')
def main(self):
......@@ -653,7 +651,7 @@ class server_delete(_CycladesInit, _ServerWait):
self.client.delete_server(server_id)
if self['wait']:
self._wait(server_id, status)
self.wait(server_id, status)
def main(self, server_id_or_cluster_prefix):
super(self.__class__, self)._run()
......@@ -693,7 +691,7 @@ class server_reboot(_CycladesInit, _ServerWait):
self.client.reboot_server(int(server_id), hard_reboot)
if self['wait']:
self._wait(server_id, 'REBOOT')
self.wait(server_id, 'REBOOT')
def main(self, server_id):
super(self.__class__, self)._run()
......@@ -721,7 +719,7 @@ class server_start(_CycladesInit, _ServerWait):
self.client.start_server(int(server_id))
if self['wait']:
self._wait(server_id, status)
self.wait(server_id, status)
def main(self, server_id):
super(self.__class__, self)._run()
......@@ -749,7 +747,7 @@ class server_shutdown(_CycladesInit, _ServerWait):
self.client.shutdown_server(int(server_id))
if self['wait']:
self._wait(server_id, status)
self.wait(server_id, status)
def main(self, server_id):
super(self.__class__, self)._run()
......@@ -765,7 +763,7 @@ class server_console(_CycladesInit, OptionalOutput):
@errors.Cyclades.server_id
def _run(self, server_id):
self.error('The following credentials will be invalidated shortly')
self._print(
self.print_(
self.client.get_server_console(server_id), self.print_dict)
def main(self, server_id):
......@@ -793,7 +791,7 @@ class server_wait(_CycladesInit, _ServerWait):
def _run(self, server_id, current_status):
r = self.client.get_server_details(server_id)
if r['status'].lower() == current_status.lower():
self._wait(server_id, current_status, timeout=self['timeout'])
self.wait(server_id, current_status, timeout=self['timeout'])
else:
self.error(
'Server %s: Cannot wait for status %s, '
......@@ -857,7 +855,7 @@ class flavor_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
for key in set(flv).difference(self.PERMANENTS):
flv.pop(key)
kwargs = dict(out=StringIO(), title=()) if self['more'] else {}
self._print(
self.print_(
flavors,
with_redundancy=self['detail'], with_enumeration=self['enum'],
**kwargs)
......@@ -879,19 +877,9 @@ class flavor_info(_CycladesInit, OptionalOutput):
@errors.Cyclades.connection
@errors.Cyclades.flavor_id
def _run(self, flavor_id):
self._print(
self.print_(
self.client.get_flavor_details(int(flavor_id)), self.print_dict)
def main(self, flavor_id):
super(self.__class__, self)._run()
self._run(flavor_id=flavor_id)
def _add_name(self, net):
user_id, tenant_id, uuids = net['user_id'], net['tenant_id'], []
if user_id:
uuids.append(user_id)
if uuids or tenant_id:
usernames = self._uuids2usernames(uuids)
if user_id:
net['user_id'] += ' (%s)' % usernames[user_id]
......@@ -87,37 +87,7 @@ class _ImageInit(CommandInit):
# Plankton Image Commands
def _validate_image_meta(json_dict, return_str=False):
"""
:param json_dict" (dict) json-formated, of the form
{"key1": "val1", "key2": "val2", ...}
:param return_str: (boolean) if true, return a json dump
:returns: (dict) if return_str is not True, else return str
:raises TypeError, AttributeError: Invalid json format
:raises AssertionError: Valid json but invalid image properties dict
"""
json_str = dumps(json_dict, indent=2)
for k, v in json_dict.items():
if k.lower() == 'properties':
for pk, pv in v.items():
prop_ok = not (isinstance(pv, dict) or isinstance(pv, list))
assert prop_ok, 'Invalid property value for key %s' % pk
key_ok = not (' ' in k or '-' in k)
assert key_ok, 'Invalid property key %s' % k
continue
meta_ok = not (isinstance(v, dict) or isinstance(v, list))
assert meta_ok, 'Invalid value for meta key %s' % k
meta_ok = ' ' not in k
assert meta_ok, 'Invalid meta key [%s]' % k
json_dict[k] = '%s' % v
return json_str if return_str else json_dict
def _load_image_meta(filepath):
def load_image_meta(filepath):
"""
:param filepath: (str) the (relative) path of the metafile
......@@ -130,32 +100,25 @@ def _load_image_meta(filepath):
with open(path.abspath(filepath)) as f:
meta_dict = load(f)
try:
return _validate_image_meta(meta_dict)
for k, v in meta_dict.items():
if k.lower() == 'properties':
for pk, pv in v.items():
prop_ok = not isinstance(pv, (dict, list))
assert prop_ok, 'Invalid property value (key %s)' % pk
key_ok = not (' ' in k or '-' in k)
assert key_ok, 'Invalid property key %s' % k
continue
meta_ok = not isinstance(v, dict, list)
assert meta_ok, 'Invalid value (meta key %s)' % k
meta_ok = ' ' not in k
assert meta_ok, 'Invalid meta key [%s]' % k
meta_dict[k] = '%s' % v
return meta_dict
except AssertionError:
log.debug('Failed to load properties from file %s' % filepath)
raise
def _validate_image_location(location):
"""
:param location: (str) pithos://<user-id>/<container>/<image-path>
:returns: (<user-id>, <container>, <image-path>)
:raises AssertionError: if location is invalid
"""
prefix = 'pithos://'
msg = 'Invalid prefix for location %s , try: %s' % (location, prefix)
assert location.startswith(prefix), msg
service, sep, rest = location.partition('://')
assert sep and rest, 'Location %s is missing user-id' % location
uuid, sep, rest = rest.partition('/')
assert sep and rest, 'Location %s is missing container' % location
container, sep, img_path = rest.partition('/')
assert sep and img_path, 'Location %s is missing image path' % location
return uuid, container, img_path
@command(image_cmds)
class image_list(_ImageInit, OptionalOutput, NameFilter, IDFilter):
"""List images accessible by user"""
......@@ -223,7 +186,7 @@ class image_list(_ImageInit, OptionalOutput, NameFilter, IDFilter):
usernames = self._uuids2usernames(uuids)
for member in members:
member['member_id'] += ' (%s)' % usernames[member['member_id']]
self._print(members, title=('member_id',))
self.print_(members, title=('member_id',))
@errors.Generic.all
@errors.Cyclades.connection
......@@ -267,7 +230,7 @@ class image_list(_ImageInit, OptionalOutput, NameFilter, IDFilter):
if self['more']:
kwargs['out'] = StringIO()
kwargs['title'] = ()
self._print(images, **kwargs)
self.print_(images, **kwargs)
if self['more']:
pager(kwargs['out'].getvalue())
......@@ -287,7 +250,7 @@ class image_info(_ImageInit, OptionalOutput):
meta = self.client.get_meta(image_id)
if not self['output_format']:
meta['owner'] += ' (%s)' % self._uuid2username(meta['owner'])
self._print(meta, self.print_dict)
self.print_(meta, self.print_dict)
def main(self, image_id):
super(self.__class__, self)._run()
......@@ -377,7 +340,7 @@ class PithosLocationArgument(ValueArgument):
if location:
from kamaki.cli.cmds.pithos import _PithosContainer as pc
try:
uuid, self.container, self.path = pc._resolve_pithos_url(
uuid, self.container, self.path = pc.resolve_pithos_url(
location)
self.uuid = uuid or self.uuid
assert self.container, 'No container in pithos URI'
......@@ -464,7 +427,7 @@ class image_register(_ImageInit, OptionalOutput):
pfile = self['metafile']
if pfile:
try:
for k, v in _load_image_meta(pfile).items():
for k, v in load_image_meta(pfile).items():
key = k.lower().replace('-', '_')
if key == 'properties':
for pk, pv in v.items():
......@@ -552,7 +515,7 @@ class image_register(_ImageInit, OptionalOutput):
locator.container)] + howto_image_file)
raise
r['owner'] += ' (%s)' % self._uuid2username(r['owner'])
self._print(r, self.print_dict)
self.print_(r, self.print_dict)
#upload the metadata file
if not self['no_metafile_upload']:
......@@ -688,7 +651,7 @@ class imagecompute_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
if self['more']:
kwargs['out'] = StringIO()
kwargs['title'] = ()
self._print(images, **kwargs)
self.print_(images, **kwargs)
if self['more']:
pager(kwargs['out'].getvalue())
......@@ -709,7 +672,7 @@ class imagecompute_info(_CycladesInit, OptionalOutput):
uuids = [image['user_id']]
usernames = self._uuids2usernames(uuids)
image['user_id'] += ' (%s)' % usernames[image['user_id']]
self._print(image, self.print_dict)
self.print_(image, self.print_dict)
def main(self, image_id):
super(self.__class__, self)._run()
......
......@@ -58,8 +58,8 @@ port_states = ('BUILD', 'ACTIVE', 'DOWN', 'ERROR')
class _PortWait(Wait):
def _wait(self, port_id, current_status, timeout=60):
super(_PortWait, self)._wait(
def wait(self, port_id, current_status, timeout=60):
super(_PortWait, self).wait(
'Port', port_id, self.client.wait_port, current_status,
timeout=timeout)
......@@ -112,7 +112,7 @@ class network_list(_NetworkInit, OptionalOutput, NameFilter, IDFilter):
if self['more']:
kwargs['out'] = StringIO()
kwargs['title'] = ()
self._print(nets, **kwargs)
self.print_(nets, **kwargs)
if self['more']:
pager(kwargs['out'].getvalue())
......@@ -130,7 +130,7 @@ class network_info(_NetworkInit, OptionalOutput):
@errors.Cyclades.network_id
def _run(self, network_id):
net = self.client.get_network_details(network_id)
self._print(net, self.print_dict)
self.print_(net, self.print_dict)
def main(self, network_id):
super(self.__class__, self)._run()
......@@ -178,7 +178,7 @@ class network_create(_NetworkInit, OptionalOutput):
name=self['name'],
shared=self['shared'],
project=self['project_id'])
self._print(net, self.print_dict)
self.print_(net, self.print_dict)
def main(self):
super(self.__class__, self)._run()
......@@ -232,7 +232,7 @@ class network_modify(_NetworkInit, OptionalOutput):
@errors.Cyclades.network_id
def _run(self, network_id):
r = self.client.update_network(network_id, name=self['new_name'])
self._print(r, self.print_dict)
self.print_(r, self.print_dict)
def main(self, network_id):
super(self.__class__, self)._run()
......@@ -269,7 +269,7 @@ class subnet_list(_NetworkInit, OptionalOutput, NameFilter, IDFilter):
if self['more']:
kwargs['out'] = StringIO()
kwargs['title'] = ()
self._print(nets, **kwargs)
self.print_(nets, **kwargs)
if self['more']:
pager('%s' % kwargs['out'].getvalue())
......@@ -286,7 +286,7 @@ class subnet_info(_NetworkInit, OptionalOutput):
@errors.Cyclades.connection
def _run(self, subnet_id):
net = self.client.get_subnet_details(subnet_id)
self._print(net, self.print_dict)
self.print_(net, self.print_dict)
def main(self, subnet_id):
super(self.__class__, self)._run()
......@@ -342,7 +342,7 @@ class subnet_create(_NetworkInit, OptionalOutput):
network_id, cidr,
self['name'], self['allocation_pools'], self['gateway'],
self['subnet_id'], self['ipv6'], self['enable_dhcp'])
self._print(net, self.print_dict)
self.print_(net, self.print_dict)
def main(self):
super(self.__class__, self)._run()
......@@ -362,7 +362,7 @@ class subnet_modify(_NetworkInit, OptionalOutput):
@errors.Cyclades.connection
def _run(self, subnet_id):
r = self.client.update_subnet(subnet_id, name=self['new_name'])
self._print(r, self.print_dict)
self.print_(r, self.print_dict)
def main(self, subnet_id):
super(self.__class__, self)._run()
......@@ -397,7 +397,7 @@ class port_list(_NetworkInit, OptionalOutput, NameFilter, IDFilter):
if self['more']:
kwargs['out'] = StringIO()
kwargs['title'] = ()
self._print(ports, **kwargs)
self.print_(ports, **kwargs)
if self['more']:
pager(kwargs['out'].getvalue())
......@@ -414,7 +414,7 @@ class port_info(_NetworkInit, OptionalOutput):
@errors.Cyclades.connection
def _run(self, port_id):
port = self.client.get_port_details(port_id)
self._print(port, self.print_dict)
self.print_(port, self.print_dict)
def main(self, port_id):
super(self.__class__, self)._run()
......@@ -437,7 +437,7 @@ class port_delete(_NetworkInit, _PortWait):
self.client.delete_port(port_id)
if self['wait']:
try:
self._wait(port_id, status)
self.wait(port_id, status)
except ClientError as ce:
if ce.status not in (404, ):
raise
......@@ -461,7 +461,7 @@ class port_modify(_NetworkInit, OptionalOutput):
r = self.client.get_port_details(port_id)
r = self.client.update_port(
port_id, r['network_id'], name=self['new_name'])
self._print(r, self.print_dict)
self.print_(r, self.print_dict)