use l3 api def from neutron-lib
Commit I81748aa0e48b1275df3e1ea41b1d36a117d0097d added the l3 extension API definition to neutron-lib, commit I2324a3a02789c798248cab41c278a2d9981d24be rehomed the l3 exceptions and Ifd79eb1a92853e49bd4ef028e7a7bd89811c6957 shims the l3 exceptions in neutron. This patch consumes the l3 API definition from neutron-lib in prep for If2e66e06b83e15ee2851ea2bc3b64ad366e675dd Change-Id: I56409beb595c69f2ecaac5349dea35bee14a26ce
This commit is contained in:
parent
53ad625179
commit
17213439c9
@ -19,6 +19,7 @@ import random
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context as n_context
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.exceptions import l3 as l3_exc
|
||||
from oslo_log import log
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_service import loopingcall
|
||||
@ -30,7 +31,6 @@ from neutron.db import api as db_api
|
||||
from neutron.db.models import external_net as external_net_db
|
||||
from neutron.db.models import l3 as l3_db
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import l3
|
||||
|
||||
from vmware_nsx._i18n import _
|
||||
from vmware_nsx.api_client import exception as api_exc
|
||||
@ -388,7 +388,7 @@ class NsxSynchronizer(object):
|
||||
try:
|
||||
router = self._plugin._get_router(context,
|
||||
neutron_router_data['id'])
|
||||
except l3.RouterNotFound:
|
||||
except l3_exc.RouterNotFound:
|
||||
pass
|
||||
else:
|
||||
router.status = status
|
||||
|
@ -24,6 +24,7 @@ from neutron_lib import constants
|
||||
from neutron_lib import context as q_context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.exceptions import allowedaddresspairs as addr_exc
|
||||
from neutron_lib.exceptions import l3 as l3_exc
|
||||
from neutron_lib.exceptions import port_security as psec_exc
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_config import cfg
|
||||
@ -59,7 +60,6 @@ from neutron.db import portbindings_db
|
||||
from neutron.db import portsecurity_db
|
||||
from neutron.db import quota_db # noqa
|
||||
from neutron.db import securitygroups_db
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
@ -1766,8 +1766,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
subnet_id = port['fixed_ips'][0]['subnet_id']
|
||||
if not (port['device_owner'] in constants.ROUTER_INTERFACE_OWNERS
|
||||
and port['device_id'] == router_id):
|
||||
raise l3.RouterInterfaceNotFound(router_id=router_id,
|
||||
port_id=port_id)
|
||||
raise l3_exc.RouterInterfaceNotFound(
|
||||
router_id=router_id, port_id=port_id)
|
||||
elif 'subnet_id' in interface_info:
|
||||
subnet_id = interface_info['subnet_id']
|
||||
subnet = self._get_subnet(context, subnet_id)
|
||||
@ -1782,8 +1782,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
port_id = p['id']
|
||||
break
|
||||
else:
|
||||
raise l3.RouterInterfaceNotFoundForSubnet(router_id=router_id,
|
||||
subnet_id=subnet_id)
|
||||
raise l3_exc.RouterInterfaceNotFoundForSubnet(
|
||||
router_id=router_id, subnet_id=subnet_id)
|
||||
# Finally remove the data from the Neutron DB
|
||||
# This will also destroy the port on the logical switch
|
||||
info = super(NsxPluginV2, self).remove_router_interface(
|
||||
|
@ -22,6 +22,7 @@ from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef
|
||||
from neutron_lib.api.definitions import availability_zone as az_def
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo
|
||||
from neutron_lib.api.definitions import l3 as l3_apidef
|
||||
from neutron_lib.api.definitions import network as net_def
|
||||
from neutron_lib.api.definitions import port as port_def
|
||||
from neutron_lib.api.definitions import port_security as psec
|
||||
@ -37,6 +38,7 @@ from neutron_lib import context as n_context
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.exceptions import allowedaddresspairs as addr_exc
|
||||
from neutron_lib.exceptions import l3 as l3_exc
|
||||
from neutron_lib.exceptions import port_security as psec_exc
|
||||
from neutron_lib.plugins import constants as plugin_const
|
||||
from neutron_lib.plugins import directory
|
||||
@ -77,7 +79,6 @@ from neutron.db import quota_db # noqa
|
||||
from neutron.db import securitygroups_db
|
||||
from neutron.db import vlantransparent_db
|
||||
from neutron.extensions import flavors
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
@ -453,7 +454,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
r["router_type"] = router_type
|
||||
|
||||
@staticmethod
|
||||
@resource_extend.extends([l3.ROUTERS])
|
||||
@resource_extend.extends([l3_apidef.ROUTERS])
|
||||
def _extend_nsx_router_dict(router_res, router_db):
|
||||
router_type_obj = rt_rtr.RouterType_mixin()
|
||||
router_type_obj._extend_nsx_router_dict(
|
||||
@ -3172,14 +3173,14 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
fips = self.get_floatingips_count(context.elevated(),
|
||||
filters=router_filter)
|
||||
if fips:
|
||||
raise l3.RouterInUse(router_id=router_id)
|
||||
raise l3_exc.RouterInUse(router_id=router_id)
|
||||
|
||||
device_filter = {'device_id': [router_id],
|
||||
'device_owner': [l3_db.DEVICE_OWNER_ROUTER_INTF]}
|
||||
ports = self.get_ports_count(context.elevated(),
|
||||
filters=device_filter)
|
||||
if ports:
|
||||
raise l3.RouterInUse(router_id=router_id)
|
||||
raise l3_exc.RouterInUse(router_id=router_id)
|
||||
|
||||
def delete_router(self, context, id):
|
||||
self._check_router_in_use(context, id)
|
||||
@ -3187,7 +3188,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
# Clear vdr's gw relative components if the router has gw info
|
||||
if router_driver.get_type() == "distributed":
|
||||
router = self.get_router(context, id)
|
||||
if router.get(l3.EXTERNAL_GW_INFO):
|
||||
if router.get(l3_apidef.EXTERNAL_GW_INFO):
|
||||
try:
|
||||
router_driver._update_router_gw_info(context, id, {})
|
||||
except Exception as e:
|
||||
@ -3248,7 +3249,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
router_db.flavor_id = r['flavor_id']
|
||||
|
||||
@staticmethod
|
||||
@resource_extend.extends([l3.ROUTERS])
|
||||
@resource_extend.extends([l3_apidef.ROUTERS])
|
||||
def add_flavor_id(router_res, router_db):
|
||||
router_res['flavor_id'] = router_db['flavor_id']
|
||||
|
||||
@ -3634,10 +3635,10 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
msg = _("cannot add an external subnet/port as a router interface")
|
||||
raise n_exc.InvalidInput(error_message=msg)
|
||||
|
||||
snat_disabled = (router[l3.EXTERNAL_GW_INFO] and
|
||||
not router[l3.EXTERNAL_GW_INFO]['enable_snat'])
|
||||
snat_disabled = (router[l3_apidef.EXTERNAL_GW_INFO] and
|
||||
not router[l3_apidef.EXTERNAL_GW_INFO]['enable_snat'])
|
||||
if snat_disabled and subnet_id:
|
||||
gw_network_id = router[l3.EXTERNAL_GW_INFO]['network_id']
|
||||
gw_network_id = router[l3_apidef.EXTERNAL_GW_INFO]['network_id']
|
||||
self._validate_address_scope_for_router_interface(
|
||||
context.elevated(), router_id, gw_network_id, subnet_id)
|
||||
|
||||
|
@ -20,12 +20,12 @@ import time
|
||||
|
||||
import eventlet
|
||||
import netaddr
|
||||
from neutron.extensions import l3
|
||||
from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context as q_context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.exceptions import l3 as l3_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
@ -2566,7 +2566,7 @@ class NsxVCallbacks(object):
|
||||
if uuidutils.is_uuid_like(router_id):
|
||||
try:
|
||||
router_db = self.plugin._get_router(context, router_id)
|
||||
except l3.RouterNotFound:
|
||||
except l3_exc.RouterNotFound:
|
||||
# Router might have been deleted before deploy finished
|
||||
LOG.warning("Router %s not found", name)
|
||||
|
||||
@ -2632,7 +2632,7 @@ class NsxVCallbacks(object):
|
||||
try:
|
||||
router_db = self.plugin._get_router(context, router_id)
|
||||
router_db['status'] = constants.ERROR
|
||||
except l3.RouterNotFound:
|
||||
except l3_exc.RouterNotFound:
|
||||
# Router might have been deleted before deploy finished
|
||||
LOG.warning("Router %s not found", router_id)
|
||||
|
||||
|
@ -17,11 +17,13 @@ import netaddr
|
||||
from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef
|
||||
from neutron_lib.api.definitions import availability_zone as az_def
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api.definitions import l3 as l3_apidef
|
||||
from neutron_lib.api.definitions import network as net_def
|
||||
from neutron_lib.api.definitions import port_security as psec
|
||||
from neutron_lib.api import faults
|
||||
from neutron_lib.api.validators import availability_zone as az_validator
|
||||
from neutron_lib.exceptions import allowedaddresspairs as addr_exc
|
||||
from neutron_lib.exceptions import l3 as l3_exc
|
||||
from neutron_lib.exceptions import port_security as psec_exc
|
||||
from neutron_lib.services.qos import constants as qos_consts
|
||||
|
||||
@ -50,7 +52,6 @@ from neutron.db import models_v2
|
||||
from neutron.db import portbindings_db
|
||||
from neutron.db import portsecurity_db
|
||||
from neutron.db import securitygroups_db
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.plugins.common import utils as n_utils
|
||||
@ -3201,7 +3202,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
nsx_rpc.handle_router_metadata_access(self, context, router_id,
|
||||
interface=None)
|
||||
router = self.get_router(context, router_id)
|
||||
if router.get(l3.EXTERNAL_GW_INFO):
|
||||
if router.get(l3_apidef.EXTERNAL_GW_INFO):
|
||||
self._update_router_gw_info(context, router_id, {})
|
||||
nsx_router_id = nsx_db.get_nsx_router_id(context.session,
|
||||
router_id)
|
||||
@ -3522,7 +3523,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
raise n_exc.InvalidInput(error_message=err_msg)
|
||||
else:
|
||||
# attach to multiple routers
|
||||
raise l3.RouterInterfaceAttachmentConflict(reason=err_msg)
|
||||
raise l3_exc.RouterInterfaceAttachmentConflict(reason=err_msg)
|
||||
|
||||
def _add_router_interface_wrapper(self, context, router_id,
|
||||
interface_info):
|
||||
@ -3633,8 +3634,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
context, router_id, subnet_id)
|
||||
if not (port['device_owner'] in const.ROUTER_INTERFACE_OWNERS
|
||||
and port['device_id'] == router_id):
|
||||
raise l3.RouterInterfaceNotFound(router_id=router_id,
|
||||
port_id=port_id)
|
||||
raise l3_exc.RouterInterfaceNotFound(
|
||||
router_id=router_id, port_id=port_id)
|
||||
elif 'subnet_id' in interface_info:
|
||||
subnet_id = interface_info['subnet_id']
|
||||
self._confirm_router_interface_not_in_use(
|
||||
@ -3650,8 +3651,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
port_id = p['id']
|
||||
break
|
||||
else:
|
||||
raise l3.RouterInterfaceNotFoundForSubnet(router_id=router_id,
|
||||
subnet_id=subnet_id)
|
||||
raise l3_exc.RouterInterfaceNotFoundForSubnet(
|
||||
router_id=router_id, subnet_id=subnet_id)
|
||||
try:
|
||||
# TODO(berlin): Revocate announce the subnet on tier0 if
|
||||
# enable_snat is False
|
||||
|
@ -22,11 +22,11 @@ import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.exceptions import l3 as l3_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from neutron.extensions import l3
|
||||
from neutron.tests import base
|
||||
from neutron.tests.unit.api.v2 import test_base
|
||||
from neutron.tests.unit import testlib_api
|
||||
@ -657,7 +657,7 @@ class SyncTestCase(testlib_api.SqlTestCase):
|
||||
q_rtr_data = self._plugin._get_router(ctx, q_rtr_id)
|
||||
with mock.patch.object(self._plugin,
|
||||
'_get_router') as _get_router:
|
||||
_get_router.side_effect = l3.RouterNotFound(
|
||||
_get_router.side_effect = l3_exc.RouterNotFound(
|
||||
router_id=q_rtr_data['id'])
|
||||
self._plugin._synchronizer.synchronize_router(ctx, q_rtr_data)
|
||||
|
||||
|
@ -41,6 +41,7 @@ from neutron.tests.unit import testlib_api
|
||||
from neutron_lib.api.definitions import allowedaddresspairs as addrp_apidef
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api.definitions import extra_dhcp_opt as edo_ext
|
||||
from neutron_lib.api.definitions import l3 as l3_apidef
|
||||
from neutron_lib.api.definitions import port_security as psec
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
@ -5623,7 +5624,7 @@ class TestRouterFlavorTestCase(extension.ExtensionTestCase,
|
||||
self.plugin._process_router_flavor_create = mock.Mock()
|
||||
|
||||
self.plugin.register_dict_extend_funcs(
|
||||
l3.ROUTERS, [self._mock_add_flavor_id])
|
||||
l3_apidef.ROUTERS, [self._mock_add_flavor_id])
|
||||
|
||||
# init the availability zones
|
||||
self.az_name = 'az7'
|
||||
|
Loading…
Reference in New Issue
Block a user