Commit 5b4e563f authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Always use "details" call in neworks/subnets list

parent 2320de66
......@@ -264,9 +264,11 @@ class server_info(_init_cyclades, _optional_json):
"""Detailed information on a Virtual Machine"""
arguments = dict(
addr=FlagArgument(
nics=FlagArgument(
'Show only the network interfaces of this virtual server',
'--nics'),
network_id=ValueArgument(
'Show the connection details to that network', '--network-id'),
vnc=FlagArgument(
'Show VNC connection information (valid for a short period)',
'--vnc-credentials'),
......@@ -277,9 +279,13 @@ class server_info(_init_cyclades, _optional_json):
@errors.cyclades.connection
@errors.cyclades.server_id
def _run(self, server_id):
vm = self.client.get_server_details(server_id)
if self['addr']:
vm = self.client.get_server_nics(server_id)
if self['nics']:
self._print(vm.get('attachments', []))
elif self['network_id']:
self._print(
self.client.get_server_network_nics(
server_id, self['network_id']), self.print_dict)
elif self['vnc']:
self.error(
'(!) For security reasons, the following credentials are '
......@@ -298,7 +304,7 @@ class server_info(_init_cyclades, _optional_json):
def main(self, server_id):
super(self.__class__, self)._run()
choose_one = ('addr', 'vnc', 'stats')
choose_one = ('nics', 'vnc', 'stats')
count = len([a for a in choose_one if self[a]])
if count > 1:
raise CLIInvalidArgument('Invalid argument compination', details=[
......@@ -728,7 +734,7 @@ class server_shutdown(_init_cyclades, _optional_output_cmd, _server_wait):
@command(server_cmds)
class server_addr(_init_cyclades):
class server_nics(_init_cyclades):
"""DEPRECATED, use: [kamaki] server info SERVER_ID --nics"""
def main(self, *args):
......
......@@ -119,15 +119,19 @@ class network_list(_init_network, _optional_json, _name_filter, _id_filter):
@errors.generic.all
@errors.cyclades.connection
def _run(self):
detail = bool(self['detail'] or self['user_id'])
nets = self.client.list_networks(detail=detail)
nets = self.client.list_networks(detail=True)
nets = self._filter_by_user_id(nets)
nets = self._filter_by_name(nets)
nets = self._filter_by_id(nets)
if detail and not self['detail']:
if not self['detail']:
nets = [dict(
id=n['id'], name=n['name'], links=n['links']) for n in nets]
kwargs = dict()
_0_id=n['id'],
_1_name=n['name'],
_2_public='( %s )' % 'public' if (
n.get('public', None)) else 'private') for n in nets]
kwargs = dict(title=('_0_id', '_1_name', '_2_public'))
else:
kwargs = dict()
if self['more']:
kwargs['out'] = StringIO()
kwargs['title'] = ()
......@@ -256,8 +260,12 @@ class subnet_list(_init_network, _optional_json, _name_filter, _id_filter):
nets = self._filter_by_id(nets)
if not self['detail']:
nets = [dict(
id=n['id'], name=n['name'], links=n['links']) for n in nets]
kwargs = dict()
_0_id=n['id'],
_1_name=n['name'],
_2_net='( of network %s )' % n['network_id']) for n in nets]
kwargs = dict(title=('_0_id', '_1_name', '_2_net'))
else:
kwargs = dict()
if self['more']:
kwargs['out'] = StringIO()
kwargs['title'] = ()
......
......@@ -282,6 +282,16 @@ class ComputeClient(ComputeRestClient):
r = self.servers_metadata_delete(server_id, key)
return r.headers
def get_server_nics(self, server_id, changes_since=None):
r = self.servers_ips_get(server_id, changes_since=changes_since)
return r.json
def get_server_network_nics(
self, server_id, network_id, changes_since=None):
r = self.servers_ips_get(
server_id, network_id=network_id, changes_since=changes_since)
return r.json['network']
def list_flavors(self, detail=False, response_headers=dict(
previous=None, next=None)):
r = self.flavors_get(detail=bool(detail))
......@@ -375,6 +385,8 @@ class ComputeClient(ComputeRestClient):
r = self.images_metadata_delete(image_id, key)
return r.headers
# Extensions
def get_floating_ip_pools(self, tenant_id):
"""
:param tenant_id: (str)
......
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