NSX|V+V3: Fix FWaaS RPC bindings
All plugin processes should have fwaas_callbacks initialized, but only one should have it with the rpc listener to handle fwaas plugin requests. This patch initialized the fwaas callbacks with rpc only from the after_spawn callback, and for the rest of the forked processses - without rpc. Change-Id: I05d4982c89929344dd8a614cc46ed516721a71bb
This commit is contained in:
parent
c2b779d278
commit
58525c3f98
@ -376,7 +376,10 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
return False
|
||||
|
||||
def spawn_complete(self, resource, event, trigger, payload=None):
|
||||
# This method should run only once, but after init_complete
|
||||
# Init the FWaaS support with RPC listeners for the original process
|
||||
self._init_fwaas(with_rpc=True)
|
||||
|
||||
# The rest of this method should run only once, but after init_complete
|
||||
if not self.init_is_complete:
|
||||
self.init_complete(None, None, None)
|
||||
|
||||
@ -419,8 +422,9 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
self.octavia_listener = octavia_listener.NSXOctaviaListener(
|
||||
**octavia_objects)
|
||||
|
||||
# Init the FWaaS support
|
||||
self._init_fwaas()
|
||||
# Init the FWaaS support without RPC listeners
|
||||
# for the spawn workers
|
||||
self._init_fwaas(with_rpc=False)
|
||||
|
||||
self.init_is_complete = True
|
||||
|
||||
@ -505,11 +509,12 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
self.start_rpc_listeners_called = True
|
||||
return self.conn.consume_in_threads()
|
||||
|
||||
def _init_fwaas(self):
|
||||
def _init_fwaas(self, with_rpc):
|
||||
# Bind FWaaS callbacks to the driver
|
||||
if fwaas_utils.is_fwaas_v2_plugin_enabled():
|
||||
LOG.info("NSXv FWaaS v2 plugin enabled")
|
||||
self.fwaas_callbacks = fwaas_callbacks_v2.NsxvFwaasCallbacksV2()
|
||||
self.fwaas_callbacks = fwaas_callbacks_v2.NsxvFwaasCallbacksV2(
|
||||
with_rpc)
|
||||
|
||||
def _create_security_group_container(self):
|
||||
name = "OpenStack Security Group container"
|
||||
|
@ -399,7 +399,10 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
||||
return False
|
||||
|
||||
def spawn_complete(self, resource, event, trigger, payload=None):
|
||||
# This method should run only once, but after init_complete
|
||||
# Init the FWaaS support with RPC listeners for the original process
|
||||
self._init_fwaas(with_rpc=True)
|
||||
|
||||
# The rest of this method should run only once, but after init_complete
|
||||
if not self.init_is_complete:
|
||||
self.init_complete(None, None, None)
|
||||
|
||||
@ -409,9 +412,6 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
||||
self,
|
||||
self._get_octavia_stats_getter()))
|
||||
|
||||
# Init the FWaaS support
|
||||
self._init_fwaas()
|
||||
|
||||
def init_complete(self, resource, event, trigger, payload=None):
|
||||
with locking.LockManager.get_lock('plugin-init-complete'):
|
||||
if self.init_is_complete:
|
||||
@ -433,6 +433,10 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
||||
# Init octavia listener and endpoints
|
||||
self._init_octavia()
|
||||
|
||||
# Init the FWaaS support without RPC listeners
|
||||
# for the spawn workers
|
||||
self._init_fwaas(with_rpc=False)
|
||||
|
||||
self.init_is_complete = True
|
||||
|
||||
def _init_octavia(self):
|
||||
@ -462,10 +466,15 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
||||
def _get_octavia_stats_getter(self):
|
||||
return listener_mgr.stats_getter
|
||||
|
||||
def _init_fwaas(self):
|
||||
def _init_fwaas(self, with_rpc):
|
||||
if self.fwaas_callbacks:
|
||||
# already initialized
|
||||
return
|
||||
|
||||
if fwaas_utils.is_fwaas_v2_plugin_enabled():
|
||||
LOG.info("NSXv3 FWaaS v2 plugin enabled")
|
||||
self.fwaas_callbacks = fwaas_callbacks_v2.Nsxv3FwaasCallbacksV2()
|
||||
self.fwaas_callbacks = fwaas_callbacks_v2.Nsxv3FwaasCallbacksV2(
|
||||
with_rpc)
|
||||
|
||||
def _init_lbv2_driver(self):
|
||||
# Get LBaaSv2 driver during plugin initialization. If the platform
|
||||
|
@ -41,15 +41,22 @@ class DummyAgentApi(object):
|
||||
|
||||
class NsxFwaasCallbacksV2(firewall_l3_agent_v2.L3WithFWaaS):
|
||||
"""Common NSX RPC callbacks for Firewall As A Service - V2."""
|
||||
def __init__(self):
|
||||
def __init__(self, with_rpc):
|
||||
# The super code needs a configuration object with the neutron host
|
||||
# and an agent_mode, which our driver doesn't use.
|
||||
neutron_conf = cfg.CONF
|
||||
neutron_conf.agent_mode = 'nsx'
|
||||
self.with_rpc = with_rpc
|
||||
super(NsxFwaasCallbacksV2, self).__init__(conf=neutron_conf)
|
||||
self.agent_api = DummyAgentApi()
|
||||
self.core_plugin = self._get_core_plugin()
|
||||
|
||||
def start_rpc_listeners(self, host, conf):
|
||||
# Make sure RPC queue will be created only when needed
|
||||
if not self.with_rpc:
|
||||
return
|
||||
return super(NsxFwaasCallbacksV2, self).start_rpc_listeners(host, conf)
|
||||
|
||||
@property
|
||||
def plugin_type(self):
|
||||
pass
|
||||
|
@ -29,8 +29,8 @@ RULE_NAME_PREFIX = 'Fwaas-'
|
||||
class NsxvFwaasCallbacksV2(com_callbacks.NsxFwaasCallbacksV2):
|
||||
"""NSX-V RPC callbacks for Firewall As A Service - V2."""
|
||||
|
||||
def __init__(self):
|
||||
super(NsxvFwaasCallbacksV2, self).__init__()
|
||||
def __init__(self, with_rpc):
|
||||
super(NsxvFwaasCallbacksV2, self).__init__(with_rpc)
|
||||
# update the fwaas driver in case of TV plugin
|
||||
self.internal_driver = None
|
||||
if self.fwaas_enabled:
|
||||
|
@ -29,8 +29,8 @@ LOG = logging.getLogger(__name__)
|
||||
class Nsxv3FwaasCallbacksV2(com_callbacks.NsxFwaasCallbacksV2):
|
||||
"""NSX-V3 RPC callbacks for Firewall As A Service - V2."""
|
||||
|
||||
def __init__(self):
|
||||
super(Nsxv3FwaasCallbacksV2, self).__init__()
|
||||
def __init__(self, with_rpc):
|
||||
super(Nsxv3FwaasCallbacksV2, self).__init__(with_rpc)
|
||||
# update the fwaas driver in case of TV plugin
|
||||
self.internal_driver = None
|
||||
if self.fwaas_enabled:
|
||||
|
@ -134,7 +134,7 @@ class NsxV3PluginWrapper(plugin.NsxV3Plugin):
|
||||
fwaas_plugin_class = manager.NeutronManager.load_class_for_provider(
|
||||
'neutron.service_plugins', provider)
|
||||
fwaas_plugin = fwaas_plugin_class()
|
||||
self.fwaas_callbacks = callbacks_class()
|
||||
self.fwaas_callbacks = callbacks_class(False)
|
||||
# override the fwplugin_rpc since there is no RPC support in adminutils
|
||||
if plugin_callbacks:
|
||||
self.fwaas_callbacks.fwplugin_rpc = plugin_callbacks(fwaas_plugin)
|
||||
|
@ -40,7 +40,7 @@ class NsxvFwaasTestCase(test_v_plugin.NsxVPluginV2TestCase):
|
||||
|
||||
self.plugin = directory.get_plugin()
|
||||
self.plugin.fwaas_callbacks = fwaas_callbacks_v2.\
|
||||
NsxvFwaasCallbacksV2()
|
||||
NsxvFwaasCallbacksV2(False)
|
||||
self.plugin.fwaas_callbacks.fwaas_enabled = True
|
||||
self.plugin.fwaas_callbacks.fwaas_driver = self.firewall
|
||||
self.plugin.fwaas_callbacks.internal_driver = self.firewall
|
||||
|
@ -61,7 +61,7 @@ class Nsxv3FwaasTestCase(test_v3_plugin.NsxV3PluginTestCaseMixin):
|
||||
|
||||
self.plugin = directory.get_plugin()
|
||||
self.plugin.fwaas_callbacks = fwaas_callbacks_v2.\
|
||||
Nsxv3FwaasCallbacksV2()
|
||||
Nsxv3FwaasCallbacksV2(False)
|
||||
self.plugin.fwaas_callbacks.fwaas_enabled = True
|
||||
self.plugin.fwaas_callbacks.fwaas_driver = self.firewall
|
||||
self.plugin.fwaas_callbacks.internal_driver = self.firewall
|
||||
|
Loading…
x
Reference in New Issue
Block a user