Merge "use extra route api def from lib"
This commit is contained in:
commit
cedfcc7b9e
@ -59,7 +59,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 extraroute
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import providernet
|
||||
@ -67,8 +66,10 @@ from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.plugins.common import utils
|
||||
from neutron.quota import resource_registry
|
||||
from neutron_lib.api.definitions import extra_dhcp_opt as edo_ext
|
||||
from neutron_lib.api.definitions import extraroute as xroute_apidef
|
||||
from neutron_lib.api.definitions import portbindings as pbin
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib.exceptions import extraroute as xroute_exc
|
||||
|
||||
import vmware_nsx
|
||||
from vmware_nsx._i18n import _
|
||||
@ -123,7 +124,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
"binding",
|
||||
"dvr",
|
||||
"ext-gw-mode",
|
||||
"extraroute",
|
||||
xroute_apidef.ALIAS,
|
||||
"mac-learning",
|
||||
"multi-provider",
|
||||
"network-gateway",
|
||||
@ -1595,9 +1596,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
try:
|
||||
return super(NsxPluginV2, self).update_router(context,
|
||||
router_id, router)
|
||||
except (extraroute.InvalidRoutes,
|
||||
extraroute.RouterInterfaceInUseByRoute,
|
||||
extraroute.RoutesExhausted):
|
||||
except (xroute_exc.InvalidRoutes,
|
||||
xroute_exc.RouterInterfaceInUseByRoute,
|
||||
xroute_exc.RoutesExhausted):
|
||||
with excutils.save_and_reraise_exception():
|
||||
# revert changes made to NSX
|
||||
self._update_lrouter_routes(
|
||||
|
@ -13,15 +13,13 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
|
||||
import mock
|
||||
import netaddr
|
||||
import six
|
||||
from webob import exc
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import address_scope
|
||||
from neutron.extensions import extraroute
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import l3_ext_gw_mode
|
||||
from neutron.extensions import securitygroup as secgrp
|
||||
@ -35,9 +33,9 @@ from neutron.tests.unit.extensions \
|
||||
import test_l3_ext_gw_mode as test_ext_gw_mode
|
||||
from neutron.tests.unit.scheduler \
|
||||
import test_dhcp_agent_scheduler as test_dhcpagent
|
||||
|
||||
from neutron_lib.api.definitions import address_scope as addr_apidef
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api.definitions import extraroute as xroute_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
|
||||
@ -48,6 +46,7 @@ from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
from webob import exc
|
||||
|
||||
from vmware_nsx.api_client import exception as api_exc
|
||||
from vmware_nsx.common import utils
|
||||
@ -964,7 +963,7 @@ class TestL3ExtensionManager(object):
|
||||
l3.RESOURCE_ATTRIBUTE_MAP[key].update(
|
||||
l3_ext_gw_mode.EXTENDED_ATTRIBUTES_2_0.get(key, {}))
|
||||
l3.RESOURCE_ATTRIBUTE_MAP[key].update(
|
||||
extraroute.EXTENDED_ATTRIBUTES_2_0.get(key, {}))
|
||||
xroute_apidef.RESOURCE_ATTRIBUTE_MAP.get(key, {}))
|
||||
# Finally add l3 resources to the global attribute map
|
||||
attributes.RESOURCE_ATTRIBUTE_MAP.update(
|
||||
l3.RESOURCE_ATTRIBUTE_MAP)
|
||||
@ -980,29 +979,18 @@ class TestL3ExtensionManager(object):
|
||||
return []
|
||||
|
||||
|
||||
def backup_l3_attribute_map():
|
||||
"""Return a backup of the original l3 attribute map."""
|
||||
return dict((res, attrs.copy()) for
|
||||
(res, attrs) in six.iteritems(l3.RESOURCE_ATTRIBUTE_MAP))
|
||||
|
||||
|
||||
def restore_l3_attribute_map(map_to_restore):
|
||||
"""Ensure changes made by fake ext mgrs are reverted."""
|
||||
l3.RESOURCE_ATTRIBUTE_MAP = map_to_restore
|
||||
|
||||
|
||||
class L3NatTest(test_l3_plugin.L3BaseForIntTests, NsxV3PluginTestCaseMixin,
|
||||
test_address_scope.AddressScopeTestCase):
|
||||
|
||||
def _restore_l3_attribute_map(self):
|
||||
l3.RESOURCE_ATTRIBUTE_MAP = self._l3_attribute_map_bk
|
||||
def _restore(self):
|
||||
l3.RESOURCE_ATTRIBUTE_MAP = self._backup
|
||||
|
||||
def setUp(self, plugin=PLUGIN_NAME, ext_mgr=None,
|
||||
service_plugins=None):
|
||||
self._l3_attribute_map_bk = backup_l3_attribute_map()
|
||||
self._backup = copy.deepcopy(l3.RESOURCE_ATTRIBUTE_MAP)
|
||||
cfg.CONF.set_override('api_extensions_path', vmware.NSXEXT_PATH)
|
||||
cfg.CONF.set_default('max_routes', 3)
|
||||
self.addCleanup(restore_l3_attribute_map, self._l3_attribute_map_bk)
|
||||
self.addCleanup(self._restore)
|
||||
ext_mgr = ext_mgr or TestL3ExtensionManager()
|
||||
mock_nsx_version = mock.patch.object(nsx_plugin.utils,
|
||||
'is_nsx_version_2_0_0',
|
||||
|
Loading…
x
Reference in New Issue
Block a user