[aim-mapping] Notification for segmentation label update
A port_update notification is now being sent from the aim_mapping driver to the opflex agent so that the updated labels on the policy_target (the one that this port is associated with), can be fetched. Change-Id: Ibb458ef29c62ed3d2a8666f87d0ee5adb30eba0a Closes-bug: #1649013
This commit is contained in:
parent
be792291c1
commit
4896386a70
|
@ -633,6 +633,14 @@ class AIMMappingDriver(nrd.CommonNeutronBase, aim_rpc.AIMMappingRPCMixin):
|
|||
# TODO(Sumit): Implement
|
||||
pass
|
||||
|
||||
@log.log_method_call
|
||||
def update_policy_target_postcommit(self, context):
|
||||
if self.apic_segmentation_label_driver and (
|
||||
set(context.current['segmentation_labels']) != (
|
||||
set(context.original['segmentation_labels']))):
|
||||
self.aim_mech_driver._notify_port_update(
|
||||
context._plugin_context, context.current['port_id'])
|
||||
|
||||
@log.log_method_call
|
||||
def delete_policy_target_precommit(self, context):
|
||||
pt_db = context._plugin._get_policy_target(
|
||||
|
|
|
@ -48,6 +48,7 @@ class ApicSegmentationLabelExtensionDriver(api.ExtensionDriver,
|
|||
def process_update_policy_target(self, session, data, result):
|
||||
pt = data['policy_target']
|
||||
if not 'segmentation_labels' in pt:
|
||||
self.extend_policy_target_dict(session, result)
|
||||
return
|
||||
rows = self.get_policy_target_segmentation_labels(
|
||||
session, policy_target_id=result['id'])
|
||||
|
@ -62,6 +63,7 @@ class ApicSegmentationLabelExtensionDriver(api.ExtensionDriver,
|
|||
self.delete_policy_target_segmentation_label(
|
||||
session, policy_target_id=result['id'],
|
||||
segmentation_label=label)
|
||||
result['segmentation_labels'] = pt['segmentation_labels']
|
||||
|
||||
def extend_policy_target_dict(self, session, result):
|
||||
rows = self.get_policy_target_segmentation_labels(
|
||||
|
|
|
@ -1684,6 +1684,31 @@ class TestPolicyTarget(AIMBaseTestCase):
|
|||
res = req.get_response(self.api)
|
||||
self.assertEqual(webob.exc.HTTPNotFound.code, res.status_int)
|
||||
|
||||
def test_policy_target_segmentation_label_update(self):
|
||||
if not 'apic_segmentation_label' in self._extension_drivers:
|
||||
self.skipTest("apic_segmentation_label ED not configured")
|
||||
mock_notif = mock.Mock()
|
||||
self.driver.aim_mech_driver.notifier.port_update = mock_notif
|
||||
ptg = self.create_policy_target_group(
|
||||
name="ptg1")['policy_target_group']
|
||||
pt = self.create_policy_target(
|
||||
policy_target_group_id=ptg['id'])['policy_target']
|
||||
self.assertItemsEqual([], pt['segmentation_labels'])
|
||||
segmentation_labels = ['a=b', 'c=d']
|
||||
self._bind_port_to_host(pt['port_id'], 'h1')
|
||||
pt = self.update_policy_target(
|
||||
pt['id'], expected_res_status=200,
|
||||
segmentation_labels=segmentation_labels)['policy_target']
|
||||
self.assertItemsEqual(segmentation_labels, pt['segmentation_labels'])
|
||||
port = self._plugin.get_port(self._context, pt['port_id'])
|
||||
mock_notif.assert_called_once_with(mock.ANY, port)
|
||||
mock_notif.reset_mock()
|
||||
pt = self.update_policy_target(
|
||||
pt['id'], name='updated-pt',
|
||||
expected_res_status=200)['policy_target']
|
||||
self.assertItemsEqual(segmentation_labels, pt['segmentation_labels'])
|
||||
mock_notif.assert_not_called()
|
||||
|
||||
def _verify_gbp_details_assertions(self, mapping, req_mapping, port_id,
|
||||
expected_epg_name, expected_epg_tenant,
|
||||
subnet, default_route=None):
|
||||
|
|
Loading…
Reference in New Issue