Delete share network subnet during network deletion
Share network subnet is deleted during share network deletion which was missing earlier causing lots of stale db entries. Change-Id: Idb58b4ca389cfb1aaf8f9f1f8aa2fd15979c4872 Closes-bug: #2037422
This commit is contained in:
parent
49c568de9a
commit
cd767dd468
@ -4679,6 +4679,8 @@ def share_network_create(context, values):
|
||||
@context_manager.writer
|
||||
def share_network_delete(context, id):
|
||||
network_ref = _share_network_get(context, id)
|
||||
for subnet in network_ref['share_network_subnets']:
|
||||
share_network_subnet_delete(context, subnet['id'])
|
||||
network_ref.soft_delete(session=context.session)
|
||||
|
||||
|
||||
|
@ -2738,6 +2738,24 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
self.fake_context,
|
||||
self.share_nw_dict['id'])
|
||||
|
||||
@ddt.data([{'id': 'fake_id_1', 'availability_zone_id': 'None'}],
|
||||
[{'id': 'fake_id_2', 'availability_zone_id': 'None'},
|
||||
{'id': 'fake_id_3', 'availability_zone_id': 'fake_az_id'}])
|
||||
def test_delete_with_subnets(self, subnets):
|
||||
db_api.share_network_create(self.fake_context, self.share_nw_dict)
|
||||
|
||||
for subnet in subnets:
|
||||
subnet['share_network_id'] = self.share_nw_dict['id']
|
||||
db_api.share_network_subnet_create(self.fake_context, subnet)
|
||||
|
||||
db_api.share_network_delete(self.fake_context,
|
||||
self.share_nw_dict['id'])
|
||||
|
||||
self.assertRaises(exception.ShareNetworkSubnetNotFound,
|
||||
db_api.share_network_subnet_get,
|
||||
self.fake_context,
|
||||
subnets[0]['id'])
|
||||
|
||||
def test_delete_not_found(self):
|
||||
self.assertRaises(exception.ShareNetworkNotFound,
|
||||
db_api.share_network_delete,
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Now, default share network subnet is deleted when share network is deleted,
|
||||
in case it is the only subnet present in share network. Please refer to the
|
||||
`Launchpad bug #2037422 <https://bugs.launchpad.net/manila/+bug/2037422>`_
|
||||
for more details.
|
Loading…
Reference in New Issue
Block a user