Change network delete to delete by uuid or cidr

With melange it will be possible to have overlapping cidrs so it would be
better to specify the uuid of the network to delete.

Change-Id: I6781225d587952cbab3387cd40164d8ac77c58d6
This commit is contained in:
Brad Hall
2011-10-02 08:20:50 -07:00
parent 6367eedcc2
commit 0b8400a0b6
2 changed files with 21 additions and 5 deletions

View File

@@ -858,14 +858,26 @@ class NetworkCommands(object):
network.cidr,
network.cidr_v6)
@args('--network', dest="fixed_range", metavar='<x.x.x.x/yy>',
@args('--fixed_range', dest="fixed_range", metavar='<x.x.x.x/yy>',
help='Network to delete')
def delete(self, fixed_range):
@args('--uuid', dest='uuid', metavar='<uuid>',
help='UUID of network to delete')
def delete(self, fixed_range=None, uuid=None):
"""Deletes a network"""
# delete the network
if fixed_range is None and uuid is None:
raise Exception("Please specify either fixed_range or uuid")
net_manager = utils.import_object(FLAGS.network_manager)
net_manager.delete_network(context.get_admin_context(), fixed_range)
if "QuantumManager" in FLAGS.network_manager:
if uuid is None:
raise Exception("UUID is required to delete Quantum Networks")
if fixed_range:
raise Exception("Deleting by fixed_range is not supported " \
"with the QuantumManager")
# delete the network
net_manager.delete_network(context.get_admin_context(),
fixed_range, uuid)
@args('--network', dest="fixed_range", metavar='<x.x.x.x/yy>',
help='Network to modify')

View File

@@ -196,7 +196,11 @@ class QuantumTestCaseBase(object):
def _delete_nets(self):
for n in networks:
ctx = context.RequestContext('user1', n['project_id'])
self.net_man.delete_network(ctx, n['cidr'])
db_nets = db.network_get_all(ctx.elevated())
for x in db_nets:
if x['label'] == n['label']:
n['uuid'] = x['uuid']
self.net_man.delete_network(ctx, None, n['uuid'])
def test_allocate_and_deallocate_instance_static(self):
self._create_nets()