Revision 5b4e563f
b/kamaki/cli/commands/cyclades.py | ||
---|---|---|
264 | 264 |
"""Detailed information on a Virtual Machine""" |
265 | 265 |
|
266 | 266 |
arguments = dict( |
267 |
addr=FlagArgument(
|
|
267 |
nics=FlagArgument(
|
|
268 | 268 |
'Show only the network interfaces of this virtual server', |
269 | 269 |
'--nics'), |
270 |
network_id=ValueArgument( |
|
271 |
'Show the connection details to that network', '--network-id'), |
|
270 | 272 |
vnc=FlagArgument( |
271 | 273 |
'Show VNC connection information (valid for a short period)', |
272 | 274 |
'--vnc-credentials'), |
... | ... | |
277 | 279 |
@errors.cyclades.connection |
278 | 280 |
@errors.cyclades.server_id |
279 | 281 |
def _run(self, server_id): |
280 |
vm = self.client.get_server_details(server_id)
|
|
281 |
if self['addr']:
|
|
282 |
vm = self.client.get_server_nics(server_id)
|
|
283 |
if self['nics']:
|
|
282 | 284 |
self._print(vm.get('attachments', [])) |
285 |
elif self['network_id']: |
|
286 |
self._print( |
|
287 |
self.client.get_server_network_nics( |
|
288 |
server_id, self['network_id']), self.print_dict) |
|
283 | 289 |
elif self['vnc']: |
284 | 290 |
self.error( |
285 | 291 |
'(!) For security reasons, the following credentials are ' |
... | ... | |
298 | 304 |
|
299 | 305 |
def main(self, server_id): |
300 | 306 |
super(self.__class__, self)._run() |
301 |
choose_one = ('addr', 'vnc', 'stats')
|
|
307 |
choose_one = ('nics', 'vnc', 'stats')
|
|
302 | 308 |
count = len([a for a in choose_one if self[a]]) |
303 | 309 |
if count > 1: |
304 | 310 |
raise CLIInvalidArgument('Invalid argument compination', details=[ |
... | ... | |
728 | 734 |
|
729 | 735 |
|
730 | 736 |
@command(server_cmds) |
731 |
class server_addr(_init_cyclades):
|
|
737 |
class server_nics(_init_cyclades):
|
|
732 | 738 |
"""DEPRECATED, use: [kamaki] server info SERVER_ID --nics""" |
733 | 739 |
|
734 | 740 |
def main(self, *args): |
b/kamaki/cli/commands/network.py | ||
---|---|---|
119 | 119 |
@errors.generic.all |
120 | 120 |
@errors.cyclades.connection |
121 | 121 |
def _run(self): |
122 |
detail = bool(self['detail'] or self['user_id']) |
|
123 |
nets = self.client.list_networks(detail=detail) |
|
122 |
nets = self.client.list_networks(detail=True) |
|
124 | 123 |
nets = self._filter_by_user_id(nets) |
125 | 124 |
nets = self._filter_by_name(nets) |
126 | 125 |
nets = self._filter_by_id(nets) |
127 |
if detail and not self['detail']:
|
|
126 |
if not self['detail']: |
|
128 | 127 |
nets = [dict( |
129 |
id=n['id'], name=n['name'], links=n['links']) for n in nets] |
|
130 |
kwargs = dict() |
|
128 |
_0_id=n['id'], |
|
129 |
_1_name=n['name'], |
|
130 |
_2_public='( %s )' % 'public' if ( |
|
131 |
n.get('public', None)) else 'private') for n in nets] |
|
132 |
kwargs = dict(title=('_0_id', '_1_name', '_2_public')) |
|
133 |
else: |
|
134 |
kwargs = dict() |
|
131 | 135 |
if self['more']: |
132 | 136 |
kwargs['out'] = StringIO() |
133 | 137 |
kwargs['title'] = () |
... | ... | |
256 | 260 |
nets = self._filter_by_id(nets) |
257 | 261 |
if not self['detail']: |
258 | 262 |
nets = [dict( |
259 |
id=n['id'], name=n['name'], links=n['links']) for n in nets] |
|
260 |
kwargs = dict() |
|
263 |
_0_id=n['id'], |
|
264 |
_1_name=n['name'], |
|
265 |
_2_net='( of network %s )' % n['network_id']) for n in nets] |
|
266 |
kwargs = dict(title=('_0_id', '_1_name', '_2_net')) |
|
267 |
else: |
|
268 |
kwargs = dict() |
|
261 | 269 |
if self['more']: |
262 | 270 |
kwargs['out'] = StringIO() |
263 | 271 |
kwargs['title'] = () |
b/kamaki/clients/compute/__init__.py | ||
---|---|---|
282 | 282 |
r = self.servers_metadata_delete(server_id, key) |
283 | 283 |
return r.headers |
284 | 284 |
|
285 |
def get_server_nics(self, server_id, changes_since=None): |
|
286 |
r = self.servers_ips_get(server_id, changes_since=changes_since) |
|
287 |
return r.json |
|
288 |
|
|
289 |
def get_server_network_nics( |
|
290 |
self, server_id, network_id, changes_since=None): |
|
291 |
r = self.servers_ips_get( |
|
292 |
server_id, network_id=network_id, changes_since=changes_since) |
|
293 |
return r.json['network'] |
|
294 |
|
|
285 | 295 |
def list_flavors(self, detail=False, response_headers=dict( |
286 | 296 |
previous=None, next=None)): |
287 | 297 |
r = self.flavors_get(detail=bool(detail)) |
... | ... | |
375 | 385 |
r = self.images_metadata_delete(image_id, key) |
376 | 386 |
return r.headers |
377 | 387 |
|
388 |
# Extensions |
|
389 |
|
|
378 | 390 |
def get_floating_ip_pools(self, tenant_id): |
379 | 391 |
""" |
380 | 392 |
:param tenant_id: (str) |
Also available in: Unified diff