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.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):
"""Delete a chassis."""
for c in args.chassis:
try:
cc.chassis.delete(args.chassis)
cc.chassis.delete(c)
except exc.HTTPNotFound:
raise exc.CommandError('Chassis not found: %s' % args.chassis)
raise exc.CommandError('Chassis not found: %s' % c)
print 'Deleted chassis %s' % c
@utils.arg('chassis',

View File

@ -86,13 +86,18 @@ def do_node_create(cc, args):
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):
"""Delete a node."""
for n in args.node:
try:
cc.node.delete(args.node)
cc.node.delete(n)
except exc.HTTPNotFound:
raise exc.CommandError('Node not found: %s' % args.node)
raise exc.CommandError('Node not found: %s' % n)
print 'Deleted node %s' % n
@utils.arg('node',

View File

@ -69,13 +69,18 @@ def do_port_create(cc, args):
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):
"""Delete a port."""
for p in args.port:
try:
cc.port.delete(args.port)
cc.port.delete(p)
except exc.HTTPNotFound:
raise exc.CommandError('Port not found: %s' % args.port)
raise exc.CommandError('Port not found: %s' % p)
print 'Deleted port %s' % p
@utils.arg('port',