From fc26f83d5d789344628eab283dd40876ebd2058d Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Thu, 18 Aug 2016 08:26:20 +0300 Subject: [PATCH] NSX-V service insertion fix callback registry For the initialization of the service insertion, we need the "before spawn" callback added in I249ba32dede16e61b1c757a8010dac610484da4f Change-Id: Ifde507b7c9be7f6a12c02ca3a93079751d803b1a --- .../services/flowclassifier/nsx_v/driver.py | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/vmware_nsx/services/flowclassifier/nsx_v/driver.py b/vmware_nsx/services/flowclassifier/nsx_v/driver.py index 98537585e4..8f2afe78e7 100644 --- a/vmware_nsx/services/flowclassifier/nsx_v/driver.py +++ b/vmware_nsx/services/flowclassifier/nsx_v/driver.py @@ -55,14 +55,10 @@ class NsxvFlowClassifierDriver(fc_driver.FlowClassifierDriverBase): self.init_security_group_in_profile() # register an event to the end of the init to handle the first upgrade - # TODO(asarfaty): This registry will call the callback on each - # spawned thread, but we need it to be called only once. - # So it should be replaces with events.BEFORE_SPAWN after approved - # in neutron if self._is_new_security_group: registry.subscribe(self.init_complete, resources.PROCESS, - events.AFTER_INIT) + events.BEFORE_SPAWN) def init_profile_id(self): """Init the service insertion profile ID @@ -122,19 +118,16 @@ class NsxvFlowClassifierDriver(fc_driver.FlowClassifierDriverBase): et.tostring(profile_binding, encoding="us-ascii")) def init_complete(self, resource, event, trigger, **kwargs): - # This callback is called for each process. - # Until fixing it, lock is used to keep things in order - with locking.LockManager.get_lock('service_insertion_init_complete'): - if self._is_new_security_group: - # add existing VMs to the new security group - # This code must run after init is done - core_plugin = manager.NeutronManager.get_plugin() - core_plugin.add_vms_to_service_insertion( - self._security_group_id) + if self._is_new_security_group: + # add existing VMs to the new security group + # This code must run after init is done + core_plugin = manager.NeutronManager.get_plugin() + core_plugin.add_vms_to_service_insertion( + self._security_group_id) - # Add the first flow classifier entry - if cfg.CONF.nsxv.service_insertion_redirect_all: - self.add_any_any_redirect_rule() + # Add the first flow classifier entry + if cfg.CONF.nsxv.service_insertion_redirect_all: + self.add_any_any_redirect_rule() def add_any_any_redirect_rule(self): """Add an any->any flow classifier entry