Merge "Move segment deletion back to PRECOMMIT_DELETE" into stable/pike
This commit is contained in:
commit
8c5fc0fa6a
@ -460,6 +460,11 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
||||
network = self._make_network_dict(network_db, context=context)
|
||||
registry.notify(resources.NETWORK, events.PRECOMMIT_DELETE,
|
||||
self, context=context, network_id=id)
|
||||
# We expire network_db here because precommit deletion
|
||||
# might have left the relationship stale, for example,
|
||||
# if we deleted a segment.
|
||||
context.session.expire(network_db)
|
||||
network_db = self._get_network(context, id)
|
||||
context.session.delete(network_db)
|
||||
registry.notify(resources.NETWORK, events.AFTER_DELETE,
|
||||
self, context=context, network=network)
|
||||
|
@ -314,6 +314,6 @@ def subscribe():
|
||||
resources.SEGMENT, events.PRECOMMIT_CREATE)
|
||||
registry.subscribe(_delete_segments_for_network,
|
||||
resources.NETWORK,
|
||||
events.BEFORE_DELETE)
|
||||
events.PRECOMMIT_DELETE)
|
||||
|
||||
subscribe()
|
||||
|
@ -365,6 +365,18 @@ class TestSegment(SegmentTestCase):
|
||||
self._update('segments', segment['segment']['id'], segment,
|
||||
expected_code=webob.exc.HTTPClientError.code)
|
||||
|
||||
def test_segment_notification_on_delete_network(self):
|
||||
with mock.patch.object(db, '_delete_segments_for_network') as dsn:
|
||||
db.subscribe()
|
||||
with self.network() as network:
|
||||
network = network['network']
|
||||
self._delete('networks', network['id'])
|
||||
dsn.assert_called_with(resources.NETWORK,
|
||||
events.PRECOMMIT_DELETE,
|
||||
mock.ANY,
|
||||
context=mock.ANY,
|
||||
network_id=mock.ANY)
|
||||
|
||||
|
||||
class TestSegmentML2(SegmentTestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user