From 527eca9f73dfdc75e5760576b25a659caf7e0b02 Mon Sep 17 00:00:00 2001 From: Boden R Date: Fri, 2 Mar 2018 15:28:49 -0700 Subject: [PATCH] use plugin common utils from neutron-lib The public APIs that are part of neutron.plugins.common.utils were rehomed into neutron-lib with Iabb155b5d2d0ec6104ebee5dd42cf292bdf3ec61 and will removed in neutron with commit I1d63cbea463e92e1d2e053f8e1a564ed52cb84f8 This patch consumes the common plugin utils from neutron-lib Change-Id: I54ef960de54bc3ae781af7ba9473729c94197d0d --- vmware_nsx/db/networkgw_db.py | 2 +- vmware_nsx/plugins/dvs/plugin.py | 2 +- vmware_nsx/plugins/nsx_mh/plugin.py | 2 +- vmware_nsx/plugins/nsx_v/plugin.py | 2 +- vmware_nsx/plugins/nsx_v3/plugin.py | 6 +++--- vmware_nsx/services/l2gateway/nsx_v3/driver.py | 4 ++-- vmware_nsx/tests/unit/nsx_v/test_plugin.py | 2 +- vmware_nsx/tests/unit/nsx_v3/test_plugin.py | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/vmware_nsx/db/networkgw_db.py b/vmware_nsx/db/networkgw_db.py index 5ed3130ec3..ff031e5faf 100644 --- a/vmware_nsx/db/networkgw_db.py +++ b/vmware_nsx/db/networkgw_db.py @@ -17,9 +17,9 @@ from sqlalchemy.orm import exc as sa_orm_exc from neutron.db import _model_query as model_query from neutron.db import _utils as db_utils from neutron.db import api as db_api -from neutron.plugins.common import utils from neutron_lib import constants from neutron_lib import exceptions +from neutron_lib.plugins import utils from oslo_log import log as logging from oslo_utils import uuidutils import six diff --git a/vmware_nsx/plugins/dvs/plugin.py b/vmware_nsx/plugins/dvs/plugin.py index 852137dfac..2b7e74d74f 100644 --- a/vmware_nsx/plugins/dvs/plugin.py +++ b/vmware_nsx/plugins/dvs/plugin.py @@ -40,7 +40,6 @@ from neutron.db import securitygroups_db from neutron.db import vlantransparent_db as vlan_ext_db from neutron.extensions import providernet 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 multiprovidernet as mpnet_apidef from neutron_lib.api.definitions import portbindings as pbin @@ -49,6 +48,7 @@ from neutron_lib.api.definitions import vlantransparent as vlan_apidef from neutron_lib.api import validators from neutron_lib import constants from neutron_lib import exceptions as n_exc +from neutron_lib.plugins import utils import vmware_nsx from vmware_nsx._i18n import _ diff --git a/vmware_nsx/plugins/nsx_mh/plugin.py b/vmware_nsx/plugins/nsx_mh/plugin.py index 2633a3e72a..c67433d3e1 100644 --- a/vmware_nsx/plugins/nsx_mh/plugin.py +++ b/vmware_nsx/plugins/nsx_mh/plugin.py @@ -61,7 +61,6 @@ from neutron.db import quota_db # noqa from neutron.db import securitygroups_db from neutron.extensions import providernet 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 @@ -70,6 +69,7 @@ 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 from neutron_lib.exceptions import multiprovidernet as mpnet_exc +from neutron_lib.plugins import utils import vmware_nsx from vmware_nsx._i18n import _ diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index c9d2110301..8cf8cbaa34 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -47,6 +47,7 @@ from neutron_lib.exceptions import multiprovidernet as mpnet_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 +from neutron_lib.plugins import utils from neutron_lib.services.qos import constants as qos_consts from oslo_config import cfg from oslo_log import log as logging @@ -85,7 +86,6 @@ from neutron.db import vlantransparent_db from neutron.extensions import providernet from neutron.extensions import securitygroup as ext_sg from neutron.objects import securitygroup -from neutron.plugins.common import utils from neutron.quota import resource_registry from neutron.services.flavors import flavors_plugin from vmware_nsx.dvs import dvs diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index 4202d98665..320f7b56f9 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -58,7 +58,6 @@ from neutron.db import securitygroups_db from neutron.db import vlantransparent_db from neutron.extensions import providernet from neutron.extensions import securitygroup as ext_sg -from neutron.plugins.common import utils as n_utils from neutron.quota import resource_registry from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo from neutron_lib.api.definitions import portbindings as pbin @@ -72,6 +71,7 @@ from neutron_lib.callbacks import resources from neutron_lib import constants as const from neutron_lib import context as q_context from neutron_lib import exceptions as n_exc +from neutron_lib.plugins import utils as plugin_utils from neutron_lib.utils import helpers from neutron_lib.utils import net as nlib_net from oslo_config import cfg @@ -251,7 +251,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, self.cfg_group = 'nsx_v3' # group name for nsx_v3 section in nsx.ini self.tier0_groups_dict = {} - self._network_vlans = n_utils.parse_network_vlan_ranges( + self._network_vlans = plugin_utils.parse_network_vlan_ranges( cfg.CONF.nsx_v3.network_vlan_ranges) # Initialize the network availability zones, which will be used only # when native_dhcp_metadata is True @@ -810,7 +810,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, vlan_id = self._generate_segment_id(context, physical_net, network_data) - elif not n_utils.is_valid_vlan_tag(vlan_id): + elif not plugin_utils.is_valid_vlan_tag(vlan_id): err_msg = (_('Segmentation ID %(segmentation_id)s out of ' 'range (%(min_id)s through %(max_id)s)') % {'segmentation_id': vlan_id, diff --git a/vmware_nsx/services/l2gateway/nsx_v3/driver.py b/vmware_nsx/services/l2gateway/nsx_v3/driver.py index ad0b4699f5..361adfb4e3 100644 --- a/vmware_nsx/services/l2gateway/nsx_v3/driver.py +++ b/vmware_nsx/services/l2gateway/nsx_v3/driver.py @@ -23,7 +23,6 @@ from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import uuidutils -from neutron.plugins.common import utils as n_utils from neutron_lib.api.definitions import provider_net as providernet from neutron_lib.callbacks import events from neutron_lib.callbacks import registry @@ -32,6 +31,7 @@ from neutron_lib import constants from neutron_lib import context from neutron_lib import exceptions as n_exc from neutron_lib.plugins import directory +from neutron_lib.plugins import utils as plugin_utils from vmware_nsx._i18n import _ from vmware_nsx.common import utils as nsx_utils @@ -204,7 +204,7 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin): def _validate_segment_id(self, seg_id): if not seg_id: raise l2gw_exc.L2GatewaySegmentationRequired - return n_utils.is_valid_vlan_tag(seg_id) + return plugin_utils.is_valid_vlan_tag(seg_id) def create_l2_gateway_connection(self, context, l2_gateway_connection): gw_connection = l2_gateway_connection.get(self.connection_resource) diff --git a/vmware_nsx/tests/unit/nsx_v/test_plugin.py b/vmware_nsx/tests/unit/nsx_v/test_plugin.py index e6d9a9120a..fc85c9fe86 100644 --- a/vmware_nsx/tests/unit/nsx_v/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v/test_plugin.py @@ -22,7 +22,6 @@ import netaddr from neutron.extensions import address_scope from neutron.extensions import l3 from neutron.extensions import securitygroup as secgrp -from neutron.plugins.common import utils from neutron.tests.unit import _test_extension_portbindings as test_bindings import neutron.tests.unit.db.test_allowedaddresspairs_db as test_addr_pair import neutron.tests.unit.db.test_db_base_plugin_v2 as test_plugin @@ -51,6 +50,7 @@ from neutron_lib import context from neutron_lib import exceptions as n_exc from neutron_lib.plugins import constants as plugin_const from neutron_lib.plugins import directory +from neutron_lib.plugins import utils from neutron_lib.services.qos import constants as qos_consts from neutron_lib.utils import helpers from neutron_lib.utils import net diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index 9b33e3aadd..0b1b700439 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -19,7 +19,6 @@ from neutron.db import models_v2 from neutron.extensions import address_scope from neutron.extensions import l3 from neutron.extensions import securitygroup as secgrp -from neutron.plugins.common import utils as n_utils from neutron.tests.unit import _test_extension_portbindings as test_bindings from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin from neutron.tests.unit.extensions import test_address_scope @@ -43,6 +42,7 @@ from neutron_lib import constants from neutron_lib import context from neutron_lib import exceptions as n_exc from neutron_lib.plugins import directory +from neutron_lib.plugins import utils as plugin_utils from oslo_config import cfg from oslo_utils import uuidutils from webob import exc @@ -552,7 +552,7 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin): net_type = 'vlan' name = 'phys_net' plugin = directory.get_plugin() - plugin._network_vlans = n_utils.parse_network_vlan_ranges( + plugin._network_vlans = plugin_utils.parse_network_vlan_ranges( cfg.CONF.nsx_v3.network_vlan_ranges) expected = [('subnets', []), ('name', name), ('admin_state_up', True),