Allows multiple deletions

Allows deletion of multiples resources in the same command.

Change-Id: I307cb515b0db45f1abc61521610fc4e6617597bb
This commit is contained in:
Lucas Alvares Gomes 2013-10-03 14:02:05 +01:00
parent e3f64c0055
commit 113ce00529
3 changed files with 30 additions and 15 deletions

View File

@ -66,13 +66,18 @@ def do_chassis_create(cc, args):
utils.print_dict(data, wrap=72) utils.print_dict(data, wrap=72)
@utils.arg('chassis', metavar='<chassis id>', help="ID of chassis") @utils.arg('chassis',
metavar='<chassis id>',
nargs='+',
help="ID of chassis")
def do_chassis_delete(cc, args): def do_chassis_delete(cc, args):
"""Delete a chassis.""" """Delete a chassis."""
try: for c in args.chassis:
cc.chassis.delete(args.chassis) try:
except exc.HTTPNotFound: cc.chassis.delete(c)
raise exc.CommandError('Chassis not found: %s' % args.chassis) except exc.HTTPNotFound:
raise exc.CommandError('Chassis not found: %s' % c)
print 'Deleted chassis %s' % c
@utils.arg('chassis', @utils.arg('chassis',

View File

@ -86,13 +86,18 @@ def do_node_create(cc, args):
utils.print_dict(data, wrap=72) utils.print_dict(data, wrap=72)
@utils.arg('node', metavar='<node id>', help="ID of node") @utils.arg('node',
metavar='<node id>',
nargs='+',
help="ID of node")
def do_node_delete(cc, args): def do_node_delete(cc, args):
"""Delete a node.""" """Delete a node."""
try: for n in args.node:
cc.node.delete(args.node) try:
except exc.HTTPNotFound: cc.node.delete(n)
raise exc.CommandError('Node not found: %s' % args.node) except exc.HTTPNotFound:
raise exc.CommandError('Node not found: %s' % n)
print 'Deleted node %s' % n
@utils.arg('node', @utils.arg('node',

View File

@ -69,13 +69,18 @@ def do_port_create(cc, args):
utils.print_dict(data, wrap=72) utils.print_dict(data, wrap=72)
@utils.arg('port', metavar='<port id>', help="ID of port") @utils.arg('port',
metavar='<port id>',
nargs='+',
help="ID of port")
def do_port_delete(cc, args): def do_port_delete(cc, args):
"""Delete a port.""" """Delete a port."""
try: for p in args.port:
cc.port.delete(args.port) try:
except exc.HTTPNotFound: cc.port.delete(p)
raise exc.CommandError('Port not found: %s' % args.port) except exc.HTTPNotFound:
raise exc.CommandError('Port not found: %s' % p)
print 'Deleted port %s' % p
@utils.arg('port', @utils.arg('port',