diff --git a/vmware_nsx/services/fwaas/common/fwaas_callbacks_v1.py b/vmware_nsx/services/fwaas/common/fwaas_callbacks_v1.py index 6312c8cef7..a9f247dbf7 100644 --- a/vmware_nsx/services/fwaas/common/fwaas_callbacks_v1.py +++ b/vmware_nsx/services/fwaas/common/fwaas_callbacks_v1.py @@ -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.""" diff --git a/vmware_nsx/services/fwaas/common/fwaas_callbacks_v2.py b/vmware_nsx/services/fwaas/common/fwaas_callbacks_v2.py index c31b486a20..27a97a6608 100644 --- a/vmware_nsx/services/fwaas/common/fwaas_callbacks_v2.py +++ b/vmware_nsx/services/fwaas/common/fwaas_callbacks_v2.py @@ -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): diff --git a/vmware_nsx/services/fwaas/common/fwaas_mocks.py b/vmware_nsx/services/fwaas/common/fwaas_mocks.py new file mode 100644 index 0000000000..3cbbfff5dc --- /dev/null +++ b/vmware_nsx/services/fwaas/common/fwaas_mocks.py @@ -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 diff --git a/vmware_nsx/services/fwaas/common/utils.py b/vmware_nsx/services/fwaas/common/utils.py index e7ec2be89c..57be037109 100644 --- a/vmware_nsx/services/fwaas/common/utils.py +++ b/vmware_nsx/services/fwaas/common/utils.py @@ -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) diff --git a/vmware_nsx/services/fwaas/nsx_tv/edge_fwaas_driver_v1.py b/vmware_nsx/services/fwaas/nsx_tv/edge_fwaas_driver_v1.py index 1cd2481582..998142d5c7 100644 --- a/vmware_nsx/services/fwaas/nsx_tv/edge_fwaas_driver_v1.py +++ b/vmware_nsx/services/fwaas/nsx_tv/edge_fwaas_driver_v1.py @@ -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. diff --git a/vmware_nsx/services/fwaas/nsx_tv/edge_fwaas_driver_v2.py b/vmware_nsx/services/fwaas/nsx_tv/edge_fwaas_driver_v2.py index 60ec0e5fe7..94dc3c7917 100644 --- a/vmware_nsx/services/fwaas/nsx_tv/edge_fwaas_driver_v2.py +++ b/vmware_nsx/services/fwaas/nsx_tv/edge_fwaas_driver_v2.py @@ -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. diff --git a/vmware_nsx/services/fwaas/nsx_tv/plugin_v1.py b/vmware_nsx/services/fwaas/nsx_tv/plugin_v1.py index b1d5855729..c832be2ca5 100644 --- a/vmware_nsx/services/fwaas/nsx_tv/plugin_v1.py +++ b/vmware_nsx/services/fwaas/nsx_tv/plugin_v1.py @@ -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): diff --git a/vmware_nsx/services/fwaas/nsx_tv/plugin_v2.py b/vmware_nsx/services/fwaas/nsx_tv/plugin_v2.py index 9ec45d1f5e..b82310217c 100644 --- a/vmware_nsx/services/fwaas/nsx_tv/plugin_v2.py +++ b/vmware_nsx/services/fwaas/nsx_tv/plugin_v2.py @@ -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): diff --git a/vmware_nsx/services/fwaas/nsx_v/edge_fwaas_driver.py b/vmware_nsx/services/fwaas/nsx_v/edge_fwaas_driver.py index 63c15612ff..14f5771160 100644 --- a/vmware_nsx/services/fwaas/nsx_v/edge_fwaas_driver.py +++ b/vmware_nsx/services/fwaas/nsx_v/edge_fwaas_driver.py @@ -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.""" diff --git a/vmware_nsx/services/fwaas/nsx_v3/edge_fwaas_driver_base.py b/vmware_nsx/services/fwaas/nsx_v3/edge_fwaas_driver_base.py index b07cd06554..616390b516 100644 --- a/vmware_nsx/services/fwaas/nsx_v3/edge_fwaas_driver_base.py +++ b/vmware_nsx/services/fwaas/nsx_v3/edge_fwaas_driver_base.py @@ -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.""" diff --git a/vmware_nsx/shell/admin/plugins/nsxv3/resources/utils.py b/vmware_nsx/shell/admin/plugins/nsxv3/resources/utils.py index a69af6e2a4..4d92277ec4 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv3/resources/utils.py +++ b/vmware_nsx/shell/admin/plugins/nsxv3/resources/utils.py @@ -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