Revision b19653d1 tools/cloud
b/tools/cloud | ||
---|---|---|
336 | 336 |
print_dict(image) |
337 | 337 |
|
338 | 338 |
else: |
339 |
print '%3d %s' % (id, name)
|
|
339 |
print '%3d %s' % (id, name) |
|
340 | 340 |
|
341 | 341 |
|
342 | 342 |
@command_name('imginfo') |
... | ... | |
485 | 485 |
reply = self.http_get(path) |
486 | 486 |
|
487 | 487 |
for network in reply['networks']['values']: |
488 |
id = network.pop('id') |
|
488 | 489 |
name = network.pop('name') |
489 | 490 |
if self.detail: |
490 |
servers = network['servers']['values'] |
|
491 |
print '%s: %s' % (name, ', '.join(str(server_id) for server_id in servers)) |
|
491 |
print '%d %s' % (id, name) |
|
492 |
print_dict(network) |
|
493 |
|
|
492 | 494 |
else: |
493 |
print name
|
|
495 |
print '%3d %s' % (id, name)
|
|
494 | 496 |
|
495 | 497 |
|
496 | 498 |
@command_name('createnet') |
... | ... | |
509 | 511 |
@command_name('netinfo') |
510 | 512 |
class GetNetworkDetails(Command): |
511 | 513 |
description = 'get network details' |
512 |
syntax = '<network>' |
|
514 |
syntax = '<network id>'
|
|
513 | 515 |
|
514 |
def execute(self, network): |
|
515 |
path = '/api/%s/networks/%s' % (self.api, network)
|
|
516 |
def execute(self, network_id):
|
|
517 |
path = '/api/%s/networks/%d' % (self.api, int(network_id))
|
|
516 | 518 |
reply = self.http_get(path) |
517 | 519 |
net = reply['network'] |
518 |
name = net.pop('name')
|
|
520 |
name = net.pop('id')
|
|
519 | 521 |
print_dict(net) |
520 | 522 |
|
521 | 523 |
|
522 | 524 |
@command_name('renamenet') |
523 | 525 |
class UpdateNetworkName(Command): |
524 | 526 |
description = 'update network name' |
525 |
syntax = '<network> <new name>' |
|
527 |
syntax = '<network_id> <new name>'
|
|
526 | 528 |
|
527 |
def execute(self, network, name): |
|
528 |
path = '/api/%s/networks/%s' % (self.api, network)
|
|
529 |
def execute(self, network_id, name):
|
|
530 |
path = '/api/%s/networks/%d' % (self.api, int(network_id))
|
|
529 | 531 |
body = json.dumps({'network': {'name': name}}) |
530 | 532 |
self.http_put(path, body) |
531 | 533 |
|
... | ... | |
533 | 535 |
@command_name('deletenet') |
534 | 536 |
class DeleteNetwork(Command): |
535 | 537 |
description = 'delete network' |
536 |
syntax = '<network>' |
|
538 |
syntax = '<network id>'
|
|
537 | 539 |
|
538 |
def execute(self, network): |
|
539 |
path = '/api/%s/networks/%s' % (self.api, network)
|
|
540 |
def execute(self, network_id):
|
|
541 |
path = '/api/%s/networks/%d' % (self.api, int(network_id))
|
|
540 | 542 |
self.http_delete(path) |
541 | 543 |
|
542 | 544 |
|
543 | 545 |
@command_name('addnet') |
544 | 546 |
class AddNetwork(Command): |
545 | 547 |
description = 'add server to a network' |
546 |
syntax = '<server id> <network>' |
|
548 |
syntax = '<server id> <network id>'
|
|
547 | 549 |
|
548 |
def execute(self, server_id, network): |
|
549 |
path = '/api/%s/networks/%s/action' % (self.api, network)
|
|
550 |
def execute(self, server_id, network_id):
|
|
551 |
path = '/api/%s/networks/%d/action' % (self.api, int(network_id))
|
|
550 | 552 |
body = json.dumps({'add': {'serverRef': server_id}}) |
551 | 553 |
self.http_post(path, body, expected_status=202) |
552 | 554 |
|
... | ... | |
554 | 556 |
@command_name('removenet') |
555 | 557 |
class RemoveNetwork(Command): |
556 | 558 |
description = 'remove server from a network' |
557 |
syntax = '<server id> <network>' |
|
559 |
syntax = '<server id> <network id>'
|
|
558 | 560 |
|
559 |
def execute(self, server_id, network): |
|
560 |
path = '/api/%s/networks/%s/action' % (self.api, network)
|
|
561 |
def execute(self, server_id, network_id):
|
|
562 |
path = '/api/%s/networks/%s/action' % (self.api, int(network_id))
|
|
561 | 563 |
body = json.dumps({'remove': {'serverRef': server_id}}) |
562 | 564 |
self.http_post(path, body, expected_status=202) |
563 | 565 |
|
Also available in: Unified diff