Allow NSX plugins to work without FWaaS
When neutrion FWaaS is not configured, the NSX plugins should come up and work even if the neutron-fwaas code is not installed. This patch adds try/except on fwaas imports, and some mocks to allow it. Change-Id: I44895c1ded046668c56d559b47a69c44102d2f04
This commit is contained in:
parent
7c3f1e63df
commit
f7318af8a0
@ -18,17 +18,23 @@ from oslo_log import log as logging
|
||||
|
||||
from neutron.agent.l3 import router_info
|
||||
from neutron.common import config as neutron_config # noqa
|
||||
from neutron_fwaas.db.firewall import firewall_db # noqa
|
||||
from neutron_fwaas.db.firewall import firewall_router_insertion_db \
|
||||
as fw_r_ins_db
|
||||
from neutron_fwaas.services.firewall.agents.l3reference \
|
||||
import firewall_l3_agent
|
||||
from neutron_lib import constants as nl_constants
|
||||
from neutron_lib import context as n_context
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
from neutron_fwaas.db.firewall import firewall_db # noqa
|
||||
from neutron_fwaas.db.firewall import firewall_router_insertion_db \
|
||||
as fw_r_ins_db
|
||||
from neutron_fwaas.services.firewall.agents.l3reference \
|
||||
import firewall_l3_agent
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as firewall_l3_agent
|
||||
|
||||
|
||||
class NsxFwaasCallbacks(firewall_l3_agent.L3WithFWaaS):
|
||||
"""Common NSX RPC callbacks for Firewall As A Service - V1."""
|
||||
|
@ -18,15 +18,21 @@ from oslo_log import log as logging
|
||||
|
||||
from neutron.agent.l3 import router_info
|
||||
from neutron.common import config as neutron_config # noqa
|
||||
from neutron_fwaas.db.firewall.v2 import firewall_db_v2
|
||||
from neutron_fwaas.services.firewall.agents.l3reference \
|
||||
import firewall_l3_agent_v2
|
||||
from neutron_lib import constants as nl_constants
|
||||
from neutron_lib import context as n_context
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
from neutron_fwaas.db.firewall.v2 import firewall_db_v2
|
||||
from neutron_fwaas.services.firewall.agents.l3reference \
|
||||
import firewall_l3_agent_v2
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as firewall_l3_agent_v2
|
||||
|
||||
|
||||
class DummyAgentApi(object):
|
||||
def is_router_in_namespace(self, router_id):
|
||||
|
41
vmware_nsx/services/fwaas/common/fwaas_mocks.py
Normal file
41
vmware_nsx/services/fwaas/common/fwaas_mocks.py
Normal file
@ -0,0 +1,41 @@
|
||||
# Copyright 2018 VMware, Inc.
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This file contains FWaaS mocks, to allow the vmware nsx plugins to work when
|
||||
# FWaaS code does not exist, and FWaaS is not configured in neutron
|
||||
|
||||
FIREWALL = 'FIREWALL'
|
||||
FIREWALL_V2 = 'FIREWALL_V2'
|
||||
|
||||
|
||||
class L3WithFWaaS(object):
|
||||
def __init__(self, **kwargs):
|
||||
self.fwaas_enabled = False
|
||||
|
||||
|
||||
class FwaasDriverBase(object):
|
||||
pass
|
||||
|
||||
|
||||
class FirewallPlugin(object):
|
||||
pass
|
||||
|
||||
|
||||
class FirewallPluginV2(object):
|
||||
pass
|
||||
|
||||
|
||||
class FirewallCallbacks(object):
|
||||
pass
|
@ -13,9 +13,15 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_fwaas.common import fwaas_constants
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
try:
|
||||
from neutron_fwaas.common import fwaas_constants
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as fwaas_constants
|
||||
|
||||
|
||||
def is_fwaas_v1_plugin_enabled():
|
||||
fwaas_plugin = directory.get_plugin(fwaas_constants.FIREWALL)
|
||||
|
@ -16,7 +16,6 @@
|
||||
from oslo_log import helpers as log_helpers
|
||||
from oslo_log import log as logging
|
||||
|
||||
from neutron_fwaas.services.firewall.drivers import fwaas_base
|
||||
from neutron_lib.exceptions import firewall_v1 as exceptions
|
||||
|
||||
from vmware_nsx.extensions import projectpluginmap
|
||||
@ -27,6 +26,13 @@ from vmware_nsx.services.fwaas.nsx_v3 import edge_fwaas_driver_v1 as t_driver
|
||||
LOG = logging.getLogger(__name__)
|
||||
FWAAS_DRIVER_NAME = 'FwaaS V1 NSX-TV driver'
|
||||
|
||||
try:
|
||||
from neutron_fwaas.services.firewall.drivers import fwaas_base
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as fwaas_base
|
||||
|
||||
|
||||
class EdgeFwaasTVDriverV1(fwaas_base.FwaasDriverBase):
|
||||
"""NSX-TV driver for Firewall As A Service - V1.
|
||||
|
@ -16,7 +16,6 @@
|
||||
from oslo_log import helpers as log_helpers
|
||||
from oslo_log import log as logging
|
||||
|
||||
from neutron_fwaas.services.firewall.drivers import fwaas_base_v2
|
||||
from neutron_lib.exceptions import firewall_v2 as exceptions
|
||||
|
||||
from vmware_nsx.extensions import projectpluginmap
|
||||
@ -26,6 +25,13 @@ from vmware_nsx.services.fwaas.nsx_v3 import edge_fwaas_driver_v2 as t_driver
|
||||
LOG = logging.getLogger(__name__)
|
||||
FWAAS_DRIVER_NAME = 'FwaaS V2 NSX-TV driver'
|
||||
|
||||
try:
|
||||
from neutron_fwaas.services.firewall.drivers import fwaas_base_v2
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as fwaas_base_v2
|
||||
|
||||
|
||||
class EdgeFwaasTVDriverV2(fwaas_base_v2.FwaasDriverBase):
|
||||
"""NSX-TV driver for Firewall As A Service - V2.
|
||||
|
@ -16,10 +16,15 @@
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron_fwaas.services.firewall import fwaas_plugin
|
||||
|
||||
from vmware_nsx.plugins.nsx import utils as tvd_utils
|
||||
|
||||
try:
|
||||
from neutron_fwaas.services.firewall import fwaas_plugin
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as fwaas_plugin
|
||||
|
||||
|
||||
@tvd_utils.filter_plugins
|
||||
class FwaasTVPluginV1(fwaas_plugin.FirewallPlugin):
|
||||
|
@ -13,10 +13,15 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_fwaas.services.firewall import fwaas_plugin_v2
|
||||
|
||||
from vmware_nsx.plugins.nsx import utils as tvd_utils
|
||||
|
||||
try:
|
||||
from neutron_fwaas.services.firewall import fwaas_plugin_v2
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as fwaas_plugin_v2
|
||||
|
||||
|
||||
@tvd_utils.filter_plugins
|
||||
class FwaasTVPluginV2(fwaas_plugin_v2.FirewallPluginV2):
|
||||
|
@ -19,8 +19,6 @@ from neutron_lib.plugins import directory
|
||||
from oslo_log import helpers as log_helpers
|
||||
from oslo_log import log as logging
|
||||
|
||||
from neutron_fwaas.services.firewall.drivers import fwaas_base
|
||||
|
||||
from vmware_nsx.common import locking
|
||||
from vmware_nsx.extensions import projectpluginmap
|
||||
from vmware_nsx.plugins.nsx_v.vshield import edge_utils
|
||||
@ -29,6 +27,13 @@ LOG = logging.getLogger(__name__)
|
||||
FWAAS_DRIVER_NAME = 'Fwaas V1 NSX-V driver'
|
||||
RULE_NAME_PREFIX = 'Fwaas-'
|
||||
|
||||
try:
|
||||
from neutron_fwaas.services.firewall.drivers import fwaas_base
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as fwaas_base
|
||||
|
||||
|
||||
class EdgeFwaasDriver(fwaas_base.FwaasDriverBase):
|
||||
"""NSX-V driver for Firewall As A Service - V1."""
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import netaddr
|
||||
|
||||
from neutron_fwaas.services.firewall.drivers import fwaas_base
|
||||
from neutron_lib.api.definitions import constants as fwaas_consts
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import registry
|
||||
@ -30,6 +29,13 @@ LOG = logging.getLogger(__name__)
|
||||
RULE_NAME_PREFIX = 'Fwaas-'
|
||||
DEFAULT_RULE_NAME = 'Default LR Layer3 Rule'
|
||||
|
||||
try:
|
||||
from neutron_fwaas.services.firewall.drivers import fwaas_base
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as fwaas_base
|
||||
|
||||
|
||||
class CommonEdgeFwaasV3Driver(fwaas_base.FwaasDriverBase):
|
||||
"""Base class for NSX-V3 driver for Firewall As A Service - V1 & V2."""
|
||||
|
@ -22,9 +22,6 @@ from neutron_lib import context
|
||||
from neutron_lib.plugins import constants as const
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron_fwaas.services.firewall import fwaas_plugin as fwaas_plugin_v1
|
||||
from neutron_fwaas.services.firewall import fwaas_plugin_v2
|
||||
|
||||
from vmware_nsx.common import config
|
||||
from vmware_nsx.db import db as nsx_db
|
||||
from vmware_nsx.extensions import projectpluginmap
|
||||
@ -35,6 +32,17 @@ from vmware_nsx.services.fwaas.nsx_v3 import fwaas_callbacks_v2
|
||||
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
|
||||
from vmware_nsxlib.v3 import nsx_constants
|
||||
|
||||
try:
|
||||
from neutron_fwaas.services.firewall import fwaas_plugin as fwaas_plugin_v1
|
||||
from neutron_fwaas.services.firewall import fwaas_plugin_v2
|
||||
except ImportError:
|
||||
# FWaaS project no found
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as fwaas_plugin_v1
|
||||
from vmware_nsx.services.fwaas.common import fwaas_mocks \
|
||||
as fwaas_plugin_v2
|
||||
|
||||
|
||||
_NSXLIB = None
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user