summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoden R <bodenvmw@gmail.com>2018-03-02 13:07:51 -0700
committerBoden R <bodenvmw@gmail.com>2018-04-17 12:06:28 -0600
commit410a83c89de9912207574999b3736a550ed253ba (patch)
tree61d39dffb8147fe6227e011ae852b7d9e6fd701f
parentc16d15fff2953c7427dc2671dc479d044d5b90c3 (diff)
use plugin common utils from neutron-lib
A bulk of the public APIs that are part of neutron.plugins.common.utils were rehomed into neutron-lib with [1] and the remaining with [2]. This patch consumes [1] by: - Removing the rehomed code from neutron. - Removing the UTs that are no longer applicable. - Leaving the functions in [2][3] in neutron.plugins.common.utils until we release [2][3] and can consume it at which point we should be able to remove the utils module. NeutronLibImpact [1] Iabb155b5d2d0ec6104ebee5dd42cf292bdf3ec61 [2] I2c0e4ef03425ba0bb2651ae3e68d6c8cde7b8f90 [3] I73f5e8ad7a1a83392094db846d18964d811b8bb2 Change-Id: I1d63cbea463e92e1d2e053f8e1a564ed52cb84f8
Notes
Notes (review): Code-Review+2: garyk <gkotton@vmware.com> Code-Review+2: Ihar Hrachyshka <ihrachys@redhat.com> Code-Review+2: Miguel Lavalle <miguel.lavalle@huawei.com> Workflow+1: Miguel Lavalle <miguel.lavalle@huawei.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 18 Apr 2018 01:45:05 +0000 Reviewed-on: https://review.openstack.org/549313 Project: openstack/neutron Branch: refs/heads/master
-rw-r--r--neutron/db/l3_db.py17
-rw-r--r--neutron/db/l3_dvr_db.py3
-rw-r--r--neutron/plugins/common/utils.py190
-rw-r--r--neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py4
-rw-r--r--neutron/plugins/ml2/drivers/macvtap/macvtap_common.py7
-rw-r--r--neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py6
-rw-r--r--neutron/plugins/ml2/drivers/type_tunnel.py2
-rw-r--r--neutron/plugins/ml2/drivers/type_vlan.py2
-rw-r--r--neutron/plugins/ml2/extensions/dns_integration.py2
-rw-r--r--neutron/services/trunk/seg_types/validators.py6
-rw-r--r--neutron/tests/unit/common/test_utils.py302
-rw-r--r--neutron/tests/unit/plugins/common/test_utils.py2
-rw-r--r--neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py2
-rw-r--r--neutron/tests/unit/services/trunk/test_rules.py13
14 files changed, 45 insertions, 513 deletions
diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py
index 78e7e65..c9d5582 100644
--- a/neutron/db/l3_db.py
+++ b/neutron/db/l3_db.py
@@ -30,6 +30,7 @@ from neutron_lib import exceptions as n_exc
30from neutron_lib.exceptions import l3 as l3_exc 30from neutron_lib.exceptions import l3 as l3_exc
31from neutron_lib.plugins import constants as plugin_constants 31from neutron_lib.plugins import constants as plugin_constants
32from neutron_lib.plugins import directory 32from neutron_lib.plugins import directory
33from neutron_lib.plugins import utils as plugin_utils
33from neutron_lib.services import base as base_services 34from neutron_lib.services import base as base_services
34from oslo_log import log as logging 35from oslo_log import log as logging
35from oslo_utils import uuidutils 36from oslo_utils import uuidutils
@@ -381,8 +382,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
381 if not gw_port['fixed_ips']: 382 if not gw_port['fixed_ips']:
382 LOG.debug('No IPs available for external network %s', 383 LOG.debug('No IPs available for external network %s',
383 network_id) 384 network_id)
384 with p_utils.delete_port_on_error(self._core_plugin, 385 with plugin_utils.delete_port_on_error(
385 context.elevated(), gw_port['id']): 386 self._core_plugin, context.elevated(), gw_port['id']):
386 with context.session.begin(subtransactions=True): 387 with context.session.begin(subtransactions=True):
387 router.gw_port = self._core_plugin._get_port( 388 router.gw_port = self._core_plugin._get_port(
388 context.elevated(), gw_port['id']) 389 context.elevated(), gw_port['id'])
@@ -849,7 +850,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
849 port = self._check_router_port(context, port_id, '') 850 port = self._check_router_port(context, port_id, '')
850 revert_value = {'device_id': '', 851 revert_value = {'device_id': '',
851 'device_owner': port['device_owner']} 852 'device_owner': port['device_owner']}
852 with p_utils.update_port_on_error( 853 with plugin_utils.update_port_on_error(
853 self._core_plugin, context, port_id, revert_value): 854 self._core_plugin, context, port_id, revert_value):
854 port, subnets = self._add_interface_by_port( 855 port, subnets = self._add_interface_by_port(
855 context, router, port_id, device_owner) 856 context, router, port_id, device_owner)
@@ -863,10 +864,10 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
863 'device_owner': port['device_owner']} 864 'device_owner': port['device_owner']}
864 865
865 if cleanup_port: 866 if cleanup_port:
866 mgr = p_utils.delete_port_on_error( 867 mgr = plugin_utils.delete_port_on_error(
867 self._core_plugin, context, port['id']) 868 self._core_plugin, context, port['id'])
868 else: 869 else:
869 mgr = p_utils.update_port_on_error( 870 mgr = plugin_utils.update_port_on_error(
870 self._core_plugin, context, port['id'], revert_value) 871 self._core_plugin, context, port['id'], revert_value)
871 872
872 if new_router_intf: 873 if new_router_intf:
@@ -1311,9 +1312,9 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
1311 {'port': port}, 1312 {'port': port},
1312 check_allow_post=False) 1313 check_allow_post=False)
1313 1314
1314 with p_utils.delete_port_on_error(self._core_plugin, 1315 with plugin_utils.delete_port_on_error(
1315 context.elevated(), 1316 self._core_plugin, context.elevated(),
1316 external_port['id']),\ 1317 external_port['id']),\
1317 context.session.begin(subtransactions=True): 1318 context.session.begin(subtransactions=True):
1318 # Ensure IPv4 addresses are allocated on external port 1319 # Ensure IPv4 addresses are allocated on external port
1319 external_ipv4_ips = self._port_ipv4_fixed_ips(external_port) 1320 external_ipv4_ips = self._port_ipv4_fixed_ips(external_port)
diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py
index 0d7a856..ab77cc6 100644
--- a/neutron/db/l3_dvr_db.py
+++ b/neutron/db/l3_dvr_db.py
@@ -26,6 +26,7 @@ from neutron_lib import exceptions as n_exc
26from neutron_lib.exceptions import l3 as l3_exc 26from neutron_lib.exceptions import l3 as l3_exc
27from neutron_lib.plugins import constants as plugin_constants 27from neutron_lib.plugins import constants as plugin_constants
28from neutron_lib.plugins import directory 28from neutron_lib.plugins import directory
29from neutron_lib.plugins import utils as plugin_utils
29from oslo_config import cfg 30from oslo_config import cfg
30from oslo_log import helpers as log_helper 31from oslo_log import helpers as log_helper
31from oslo_log import log as logging 32from oslo_log import log as logging
@@ -212,7 +213,7 @@ class DVRResourceOperationHandler(object):
212 msg = _("Unable to create the SNAT Interface Port") 213 msg = _("Unable to create the SNAT Interface Port")
213 raise n_exc.BadRequest(resource='router', msg=msg) 214 raise n_exc.BadRequest(resource='router', msg=msg)
214 215
215 with p_utils.delete_port_on_error( 216 with plugin_utils.delete_port_on_error(
216 self.l3plugin._core_plugin, context.elevated(), snat_port['id']): 217 self.l3plugin._core_plugin, context.elevated(), snat_port['id']):
217 l3_obj.RouterPort( 218 l3_obj.RouterPort(
218 context, 219 context,
diff --git a/neutron/plugins/common/utils.py b/neutron/plugins/common/utils.py
index becf5da..0801492 100644
--- a/neutron/plugins/common/utils.py
+++ b/neutron/plugins/common/utils.py
@@ -14,141 +14,18 @@
14 14
15""" 15"""
16Common utilities and helper functions for OpenStack Networking Plugins. 16Common utilities and helper functions for OpenStack Networking Plugins.
17These utils are private and for neutron internal use only.
17""" 18"""
18 19
19import collections
20import contextlib
21import hashlib
22
23from neutron_lib.api import attributes as lib_attrs 20from neutron_lib.api import attributes as lib_attrs
24from neutron_lib.api.definitions import network as net_def 21from neutron_lib.api.definitions import network as net_def
25from neutron_lib.api.definitions import port as port_def 22from neutron_lib.api.definitions import port as port_def
26from neutron_lib.api.definitions import subnet as subnet_def 23from neutron_lib.api.definitions import subnet as subnet_def
27from neutron_lib import constants as n_const
28from neutron_lib import exceptions
29from oslo_config import cfg 24from oslo_config import cfg
30from oslo_log import log as logging
31from oslo_utils import encodeutils
32from oslo_utils import excutils
33import webob.exc 25import webob.exc
34 26
35from neutron._i18n import _
36
37
38INTERFACE_HASH_LEN = 6
39LOG = logging.getLogger(__name__)
40
41
42def get_deployment_physnet_mtu():
43 """Retrieves global physical network MTU setting.
44
45 Plugins should use this function to retrieve the MTU set by the operator
46 that is equal to or less than the MTU of their nodes' physical interfaces.
47 Note that it is the responsibility of the plugin to deduct the value of
48 any encapsulation overhead required before advertising it to VMs.
49 """
50 return cfg.CONF.global_physnet_mtu
51
52
53def is_valid_vlan_tag(vlan):
54 return n_const.MIN_VLAN_TAG <= vlan <= n_const.MAX_VLAN_TAG
55
56
57def is_valid_gre_id(gre_id):
58 return n_const.MIN_GRE_ID <= gre_id <= n_const.MAX_GRE_ID
59
60
61def is_valid_vxlan_vni(vni):
62 return n_const.MIN_VXLAN_VNI <= vni <= n_const.MAX_VXLAN_VNI
63
64
65def is_valid_geneve_vni(vni):
66 return n_const.MIN_GENEVE_VNI <= vni <= n_const.MAX_GENEVE_VNI
67
68
69def verify_tunnel_range(tunnel_range, tunnel_type):
70 """Raise an exception for invalid tunnel range or malformed range."""
71 mappings = {n_const.TYPE_GRE: is_valid_gre_id,
72 n_const.TYPE_VXLAN: is_valid_vxlan_vni,
73 n_const.TYPE_GENEVE: is_valid_geneve_vni}
74 if tunnel_type in mappings:
75 for ident in tunnel_range:
76 if not mappings[tunnel_type](ident):
77 raise exceptions.NetworkTunnelRangeError(
78 tunnel_range=tunnel_range,
79 error=_("%(id)s is not a valid %(type)s identifier") %
80 {'id': ident, 'type': tunnel_type})
81 if tunnel_range[1] < tunnel_range[0]:
82 raise exceptions.NetworkTunnelRangeError(
83 tunnel_range=tunnel_range,
84 error=_("End of tunnel range is less "
85 "than start of tunnel range"))
86
87
88def raise_invalid_tag(vlan_str, vlan_range):
89 """Raise an exception for invalid tag."""
90 raise exceptions.NetworkVlanRangeError(
91 vlan_range=vlan_range,
92 error=_("%s is not a valid VLAN tag") % vlan_str)
93
94
95def verify_vlan_range(vlan_range):
96 """Raise an exception for invalid tags or malformed range."""
97 for vlan_tag in vlan_range:
98 if not is_valid_vlan_tag(vlan_tag):
99 raise_invalid_tag(str(vlan_tag), vlan_range)
100 if vlan_range[1] < vlan_range[0]:
101 raise exceptions.NetworkVlanRangeError(
102 vlan_range=vlan_range,
103 error=_("End of VLAN range is less than start of VLAN range"))
104
105
106def parse_network_vlan_range(network_vlan_range):
107 """Interpret a string as network[:vlan_begin:vlan_end]."""
108 entry = network_vlan_range.strip()
109 if ':' in entry:
110 if entry.count(':') != 2:
111 raise exceptions.NetworkVlanRangeError(
112 vlan_range=entry,
113 error=_("Need exactly two values for VLAN range"))
114 network, vlan_min, vlan_max = entry.split(':')
115 if not network:
116 raise exceptions.PhysicalNetworkNameError()
117
118 try:
119 vlan_min = int(vlan_min)
120 except ValueError:
121 raise_invalid_tag(vlan_min, entry)
122
123 try:
124 vlan_max = int(vlan_max)
125 except ValueError:
126 raise_invalid_tag(vlan_max, entry)
127
128 vlan_range = (vlan_min, vlan_max)
129 verify_vlan_range(vlan_range)
130 return network, vlan_range
131 else:
132 return entry, None
133
134
135def parse_network_vlan_ranges(network_vlan_ranges_cfg_entries):
136 """Interpret a list of strings as network[:vlan_begin:vlan_end] entries."""
137 networks = collections.OrderedDict()
138 for entry in network_vlan_ranges_cfg_entries:
139 network, vlan_range = parse_network_vlan_range(entry)
140 if vlan_range:
141 networks.setdefault(network, []).append(vlan_range)
142 else:
143 networks.setdefault(network, [])
144 return networks
145
146
147def in_pending_status(status):
148 return status in (n_const.PENDING_CREATE,
149 n_const.PENDING_UPDATE,
150 n_const.PENDING_DELETE)
151 27
28# TODO(boden): remove when consuming I2c0e4ef03425ba0bb2651ae3e68d6c8cde7b8f90
152 29
153def _fixup_res_dict(context, attr_name, res_dict, check_allow_post=True): 30def _fixup_res_dict(context, attr_name, res_dict, check_allow_post=True):
154 attr_info = lib_attrs.RESOURCES[attr_name] 31 attr_info = lib_attrs.RESOURCES[attr_name]
@@ -187,60 +64,13 @@ def create_port(core_plugin, context, port, check_allow_post=True):
187 return core_plugin.create_port(context, {'port': port_data}) 64 return core_plugin.create_port(context, {'port': port_data})
188 65
189 66
190@contextlib.contextmanager 67# TODO(boden): consume with I73f5e8ad7a1a83392094db846d18964d811b8bb2
191def delete_port_on_error(core_plugin, context, port_id): 68def get_deployment_physnet_mtu():
192 try: 69 """Retrieves global physical network MTU setting.
193 yield
194 except Exception:
195 with excutils.save_and_reraise_exception():
196 try:
197 core_plugin.delete_port(context, port_id,
198 l3_port_check=False)
199 except exceptions.PortNotFound:
200 LOG.debug("Port %s not found", port_id)
201 except Exception:
202 LOG.exception("Failed to delete port: %s", port_id)
203
204
205@contextlib.contextmanager
206def update_port_on_error(core_plugin, context, port_id, revert_value):
207 try:
208 yield
209 except Exception:
210 with excutils.save_and_reraise_exception():
211 try:
212 core_plugin.update_port(context, port_id,
213 {'port': revert_value})
214 except Exception:
215 LOG.exception("Failed to update port: %s", port_id)
216
217
218def get_interface_name(name, prefix='', max_len=n_const.DEVICE_NAME_MAX_LEN):
219 """Construct an interface name based on the prefix and name.
220 70
221 The interface name can not exceed the maximum length passed in. Longer 71 Plugins should use this function to retrieve the MTU set by the operator
222 names are hashed to help ensure uniqueness. 72 that is equal to or less than the MTU of their nodes' physical interfaces.
73 Note that it is the responsibility of the plugin to deduct the value of
74 any encapsulation overhead required before advertising it to VMs.
223 """ 75 """
224 requested_name = prefix + name 76 return cfg.CONF.global_physnet_mtu
225
226 if len(requested_name) <= max_len:
227 return requested_name
228
229 # We can't just truncate because interfaces may be distinguished
230 # by an ident at the end. A hash over the name should be unique.
231 # Leave part of the interface name on for easier identification
232 if (len(prefix) + INTERFACE_HASH_LEN) > max_len:
233 raise ValueError(_("Too long prefix provided. New name would exceed "
234 "given length for an interface name."))
235
236 namelen = max_len - len(prefix) - INTERFACE_HASH_LEN
237 hashed_name = hashlib.sha1(encodeutils.to_utf8(name))
238 new_name = ('%(prefix)s%(truncated)s%(hash)s' %
239 {'prefix': prefix, 'truncated': name[0:namelen],
240 'hash': hashed_name.hexdigest()[0:INTERFACE_HASH_LEN]})
241 LOG.info("The requested interface name %(requested_name)s exceeds the "
242 "%(limit)d character limitation. It was shortened to "
243 "%(new_name)s to fit.",
244 {'requested_name': requested_name,
245 'limit': max_len, 'new_name': new_name})
246 return new_name
diff --git a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
index e078b0a..5349931 100644
--- a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
+++ b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
@@ -24,6 +24,7 @@ import sys
24import netaddr 24import netaddr
25from neutron_lib.agent import topics 25from neutron_lib.agent import topics
26from neutron_lib import constants 26from neutron_lib import constants
27from neutron_lib.plugins import utils as plugin_utils
27from neutron_lib.utils import helpers 28from neutron_lib.utils import helpers
28from oslo_config import cfg 29from oslo_config import cfg
29from oslo_log import log as logging 30from oslo_log import log as logging
@@ -40,7 +41,6 @@ from neutron.common import exceptions
40from neutron.common import profiler as setup_profiler 41from neutron.common import profiler as setup_profiler
41from neutron.common import utils 42from neutron.common import utils
42from neutron.conf.agent import common as agent_config 43from neutron.conf.agent import common as agent_config
43from neutron.plugins.common import utils as p_utils
44from neutron.plugins.ml2.drivers.agent import _agent_manager_base as amb 44from neutron.plugins.ml2.drivers.agent import _agent_manager_base as amb
45from neutron.plugins.ml2.drivers.agent import _common_agent as ca 45from neutron.plugins.ml2.drivers.agent import _common_agent as ca
46from neutron.plugins.ml2.drivers.agent import config as cagt_config # noqa 46from neutron.plugins.ml2.drivers.agent import config as cagt_config # noqa
@@ -197,7 +197,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
197 # prefix = mix_iHASHED.1111 197 # prefix = mix_iHASHED.1111
198 if (len(physical_interface) + len(vlan_postfix) > 198 if (len(physical_interface) + len(vlan_postfix) >
199 constants.DEVICE_NAME_MAX_LEN): 199 constants.DEVICE_NAME_MAX_LEN):
200 physical_interface = p_utils.get_interface_name( 200 physical_interface = plugin_utils.get_interface_name(
201 physical_interface, max_len=(constants.DEVICE_NAME_MAX_LEN - 201 physical_interface, max_len=(constants.DEVICE_NAME_MAX_LEN -
202 MAX_VLAN_POSTFIX_LEN)) 202 MAX_VLAN_POSTFIX_LEN))
203 return "%s%s" % (physical_interface, vlan_postfix) 203 return "%s%s" % (physical_interface, vlan_postfix)
diff --git a/neutron/plugins/ml2/drivers/macvtap/macvtap_common.py b/neutron/plugins/ml2/drivers/macvtap/macvtap_common.py
index 3d51d37..8d185d6 100644
--- a/neutron/plugins/ml2/drivers/macvtap/macvtap_common.py
+++ b/neutron/plugins/ml2/drivers/macvtap/macvtap_common.py
@@ -15,8 +15,8 @@
15# under the License. 15# under the License.
16 16
17from neutron_lib import constants as n_const 17from neutron_lib import constants as n_const
18from neutron_lib.plugins import utils as plugin_utils
18 19
19from neutron.plugins.common import utils as p_utils
20 20
21MAX_VLAN_POSTFIX_LEN = 5 21MAX_VLAN_POSTFIX_LEN = 5
22 22
@@ -25,7 +25,6 @@ def get_vlan_device_name(src_dev, vlan):
25 """Generating the vlan device name.""" 25 """Generating the vlan device name."""
26 26
27 # Ensure that independent of the vlan len the same name prefix is used. 27 # Ensure that independent of the vlan len the same name prefix is used.
28 src_dev = p_utils.get_interface_name(src_dev, 28 src_dev = plugin_utils.get_interface_name(
29 max_len=n_const.DEVICE_NAME_MAX_LEN - 29 src_dev, max_len=n_const.DEVICE_NAME_MAX_LEN - MAX_VLAN_POSTFIX_LEN)
30 MAX_VLAN_POSTFIX_LEN)
31 return "%s.%s" % (src_dev, vlan) 30 return "%s.%s" % (src_dev, vlan)
diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
index 2773f01..2687612 100644
--- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
+++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
@@ -30,6 +30,7 @@ from neutron_lib.callbacks import registry
30from neutron_lib.callbacks import resources as callback_resources 30from neutron_lib.callbacks import resources as callback_resources
31from neutron_lib import constants as n_const 31from neutron_lib import constants as n_const
32from neutron_lib import context 32from neutron_lib import context
33from neutron_lib.plugins import utils as plugin_utils
33from neutron_lib.utils import helpers 34from neutron_lib.utils import helpers
34from oslo_config import cfg 35from oslo_config import cfg
35from oslo_log import log as logging 36from oslo_log import log as logging
@@ -55,7 +56,6 @@ from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc
55from neutron.common import config 56from neutron.common import config
56from neutron.common import utils as n_utils 57from neutron.common import utils as n_utils
57from neutron.conf.agent import xenapi_conf 58from neutron.conf.agent import xenapi_conf
58from neutron.plugins.common import utils as p_utils
59from neutron.plugins.ml2.drivers.agent import capabilities 59from neutron.plugins.ml2.drivers.agent import capabilities
60from neutron.plugins.ml2.drivers.l2pop.rpc_manager import l2population_rpc 60from neutron.plugins.ml2.drivers.l2pop.rpc_manager import l2population_rpc
61from neutron.plugins.ml2.drivers.openvswitch.agent.common \ 61from neutron.plugins.ml2.drivers.openvswitch.agent.common \
@@ -1101,9 +1101,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
1101 self.phys_brs[physical_network] = br 1101 self.phys_brs[physical_network] = br
1102 1102
1103 # interconnect physical and integration bridges using veth/patches 1103 # interconnect physical and integration bridges using veth/patches
1104 int_if_name = p_utils.get_interface_name( 1104 int_if_name = plugin_utils.get_interface_name(
1105 bridge, prefix=constants.PEER_INTEGRATION_PREFIX) 1105 bridge, prefix=constants.PEER_INTEGRATION_PREFIX)
1106 phys_if_name = p_utils.get_interface_name( 1106 phys_if_name = plugin_utils.get_interface_name(
1107 bridge, prefix=constants.PEER_PHYSICAL_PREFIX) 1107 bridge, prefix=constants.PEER_PHYSICAL_PREFIX)
1108 # Interface type of port for physical and integration bridges must 1108 # Interface type of port for physical and integration bridges must
1109 # be same, so check only one of them. 1109 # be same, so check only one of them.
diff --git a/neutron/plugins/ml2/drivers/type_tunnel.py b/neutron/plugins/ml2/drivers/type_tunnel.py
index 57c64f9..095ce64 100644
--- a/neutron/plugins/ml2/drivers/type_tunnel.py
+++ b/neutron/plugins/ml2/drivers/type_tunnel.py
@@ -22,6 +22,7 @@ from neutron_lib import constants as p_const
22from neutron_lib import context 22from neutron_lib import context
23from neutron_lib import exceptions as exc 23from neutron_lib import exceptions as exc
24from neutron_lib.plugins.ml2 import api 24from neutron_lib.plugins.ml2 import api
25from neutron_lib.plugins import utils as plugin_utils
25from oslo_config import cfg 26from oslo_config import cfg
26from oslo_db import exception as db_exc 27from oslo_db import exception as db_exc
27from oslo_log import log 28from oslo_log import log
@@ -32,7 +33,6 @@ from sqlalchemy import or_
32from neutron._i18n import _ 33from neutron._i18n import _
33from neutron.db import api as db_api 34from neutron.db import api as db_api
34from neutron.objects import base as base_obj 35from neutron.objects import base as base_obj
35from neutron.plugins.common import utils as plugin_utils
36from neutron.plugins.ml2.drivers import helpers 36from neutron.plugins.ml2.drivers import helpers
37 37
38LOG = log.getLogger(__name__) 38LOG = log.getLogger(__name__)
diff --git a/neutron/plugins/ml2/drivers/type_vlan.py b/neutron/plugins/ml2/drivers/type_vlan.py
index 56ea24f..ab42fac 100644
--- a/neutron/plugins/ml2/drivers/type_vlan.py
+++ b/neutron/plugins/ml2/drivers/type_vlan.py
@@ -19,6 +19,7 @@ from neutron_lib import constants as p_const
19from neutron_lib import context 19from neutron_lib import context
20from neutron_lib import exceptions as exc 20from neutron_lib import exceptions as exc
21from neutron_lib.plugins.ml2 import api 21from neutron_lib.plugins.ml2 import api
22from neutron_lib.plugins import utils as plugin_utils
22from oslo_config import cfg 23from oslo_config import cfg
23from oslo_log import log 24from oslo_log import log
24from six import moves 25from six import moves
@@ -27,7 +28,6 @@ from neutron._i18n import _
27from neutron.conf.plugins.ml2.drivers import driver_type 28from neutron.conf.plugins.ml2.drivers import driver_type
28from neutron.db import api as db_api 29from neutron.db import api as db_api
29from neutron.objects.plugins.ml2 import vlanallocation as vlanalloc 30from neutron.objects.plugins.ml2 import vlanallocation as vlanalloc
30from neutron.plugins.common import utils as plugin_utils
31from neutron.plugins.ml2.drivers import helpers 31from neutron.plugins.ml2.drivers import helpers
32 32
33LOG = log.getLogger(__name__) 33LOG = log.getLogger(__name__)
diff --git a/neutron/plugins/ml2/extensions/dns_integration.py b/neutron/plugins/ml2/extensions/dns_integration.py
index 4c7cced..0834e5c 100644
--- a/neutron/plugins/ml2/extensions/dns_integration.py
+++ b/neutron/plugins/ml2/extensions/dns_integration.py
@@ -22,13 +22,13 @@ from neutron_lib import constants as lib_const
22from neutron_lib.exceptions import dns as dns_exc 22from neutron_lib.exceptions import dns as dns_exc
23from neutron_lib.plugins import directory 23from neutron_lib.plugins import directory
24from neutron_lib.plugins.ml2 import api 24from neutron_lib.plugins.ml2 import api
25from neutron_lib.plugins import utils as plugin_utils
25from oslo_config import cfg 26from oslo_config import cfg
26from oslo_log import log as logging 27from oslo_log import log as logging
27 28
28from neutron.db import segments_db 29from neutron.db import segments_db
29from neutron.objects import network as net_obj 30from neutron.objects import network as net_obj
30from neutron.objects import ports as port_obj 31from neutron.objects import ports as port_obj
31from neutron.plugins.common import utils as plugin_utils
32from neutron.services.externaldns import driver 32from neutron.services.externaldns import driver
33 33
34LOG = logging.getLogger(__name__) 34LOG = logging.getLogger(__name__)
diff --git a/neutron/services/trunk/seg_types/validators.py b/neutron/services/trunk/seg_types/validators.py
index 4ae2d90..33dbcf9 100644
--- a/neutron/services/trunk/seg_types/validators.py
+++ b/neutron/services/trunk/seg_types/validators.py
@@ -12,9 +12,9 @@
12# License for the specific language governing permissions and limitations 12# License for the specific language governing permissions and limitations
13# under the License. 13# under the License.
14 14
15from neutron._i18n import _ 15from neutron_lib.plugins import utils as plugin_utils
16 16
17from neutron.plugins.common import utils 17from neutron._i18n import _
18from neutron.services.trunk import constants as trunk_consts 18from neutron.services.trunk import constants as trunk_consts
19 19
20# Base map of segmentation types supported with their respective validator 20# Base map of segmentation types supported with their respective validator
@@ -23,7 +23,7 @@ from neutron.services.trunk import constants as trunk_consts
23# and respective validator, however this is a configuration that may be 23# and respective validator, however this is a configuration that may be
24# supported only in single-driver deployments. 24# supported only in single-driver deployments.
25_supported = { 25_supported = {
26 trunk_consts.VLAN: utils.is_valid_vlan_tag, 26 trunk_consts.VLAN: plugin_utils.is_valid_vlan_tag,
27} 27}
28 28
29 29
diff --git a/neutron/tests/unit/common/test_utils.py b/neutron/tests/unit/common/test_utils.py
index 97e7786..a89b4f1 100644
--- a/neutron/tests/unit/common/test_utils.py
+++ b/neutron/tests/unit/common/test_utils.py
@@ -22,7 +22,6 @@ import eventlet
22import mock 22import mock
23import netaddr 23import netaddr
24from neutron_lib import constants 24from neutron_lib import constants
25from neutron_lib import exceptions as exc
26from oslo_log import log as logging 25from oslo_log import log as logging
27import six 26import six
28import testscenarios 27import testscenarios
@@ -30,7 +29,6 @@ import testtools
30 29
31from neutron.common import constants as common_constants 30from neutron.common import constants as common_constants
32from neutron.common import utils 31from neutron.common import utils
33from neutron.plugins.common import utils as plugin_utils
34from neutron.tests import base 32from neutron.tests import base
35from neutron.tests.unit import tests 33from neutron.tests.unit import tests
36 34
@@ -94,306 +92,6 @@ def _port_rule_masking(port_min, port_max):
94 return current.get_list() 92 return current.get_list()
95 93
96 94
97class TestParseTunnelRangesMixin(object):
98 TUN_MIN = None
99 TUN_MAX = None
100 TYPE = None
101 _err_prefix = "Invalid network tunnel range: '%d:%d' - "
102 _err_suffix = "%s is not a valid %s identifier."
103 _err_range = "End of tunnel range is less than start of tunnel range."
104
105 def _build_invalid_tunnel_range_msg(self, t_range_tuple, n):
106 bad_id = t_range_tuple[n - 1]
107 return (self._err_prefix % t_range_tuple) + (self._err_suffix
108 % (bad_id, self.TYPE))
109
110 def _build_range_reversed_msg(self, t_range_tuple):
111 return (self._err_prefix % t_range_tuple) + self._err_range
112
113 def _verify_range(self, tunnel_range):
114 return plugin_utils.verify_tunnel_range(tunnel_range, self.TYPE)
115
116 def _check_range_valid_ranges(self, tunnel_range):
117 self.assertIsNone(self._verify_range(tunnel_range))
118
119 def _check_range_invalid_ranges(self, bad_range, which):
120 expected_msg = self._build_invalid_tunnel_range_msg(bad_range, which)
121 err = self.assertRaises(exc.NetworkTunnelRangeError,
122 self._verify_range, bad_range)
123 self.assertEqual(expected_msg, str(err))
124
125 def _check_range_reversed(self, bad_range):
126 err = self.assertRaises(exc.NetworkTunnelRangeError,
127 self._verify_range, bad_range)
128 expected_msg = self._build_range_reversed_msg(bad_range)
129 self.assertEqual(expected_msg, str(err))
130
131 def test_range_tunnel_id_valid(self):
132 self._check_range_valid_ranges((self.TUN_MIN, self.TUN_MAX))
133
134 def test_range_tunnel_id_invalid(self):
135 self._check_range_invalid_ranges((-1, self.TUN_MAX), 1)
136 self._check_range_invalid_ranges((self.TUN_MIN,
137 self.TUN_MAX + 1), 2)
138 self._check_range_invalid_ranges((self.TUN_MIN - 1,
139 self.TUN_MAX + 1), 1)
140
141 def test_range_tunnel_id_reversed(self):
142 self._check_range_reversed((self.TUN_MAX, self.TUN_MIN))
143
144
145class TestGreTunnelRangeVerifyValid(TestParseTunnelRangesMixin,
146 base.BaseTestCase):
147 TUN_MIN = constants.MIN_GRE_ID
148 TUN_MAX = constants.MAX_GRE_ID
149 TYPE = constants.TYPE_GRE
150
151
152class TestVxlanTunnelRangeVerifyValid(TestParseTunnelRangesMixin,
153 base.BaseTestCase):
154 TUN_MIN = constants.MIN_VXLAN_VNI
155 TUN_MAX = constants.MAX_VXLAN_VNI
156 TYPE = constants.TYPE_VXLAN
157
158
159class UtilTestParseVlanRanges(base.BaseTestCase):
160 _err_prefix = "Invalid network VLAN range: '"
161 _err_bad_count = "' - 'Need exactly two values for VLAN range'."
162 _err_bad_vlan = "' - '%s is not a valid VLAN tag'."
163 _err_range = "' - 'End of VLAN range is less than start of VLAN range'."
164
165 def _range_err_bad_count(self, nv_range):
166 return self._err_prefix + nv_range + self._err_bad_count
167
168 def _range_invalid_vlan(self, nv_range, n):
169 vlan = nv_range.split(':')[n]
170 return self._err_prefix + nv_range + (self._err_bad_vlan % vlan)
171
172 def _nrange_invalid_vlan(self, nv_range, n):
173 vlan = nv_range.split(':')[n]
174 v_range = ':'.join(nv_range.split(':')[1:])
175 return self._err_prefix + v_range + (self._err_bad_vlan % vlan)
176
177 def _vrange_invalid_vlan(self, v_range_tuple, n):
178 vlan = v_range_tuple[n - 1]
179 v_range_str = '%d:%d' % v_range_tuple
180 return self._err_prefix + v_range_str + (self._err_bad_vlan % vlan)
181
182 def _vrange_invalid(self, v_range_tuple):
183 v_range_str = '%d:%d' % v_range_tuple
184 return self._err_prefix + v_range_str + self._err_range
185
186
187class TestVlanNetworkNameValid(base.BaseTestCase):
188 def parse_vlan_ranges(self, vlan_range):
189 return plugin_utils.parse_network_vlan_ranges(vlan_range)
190
191 def test_validate_provider_phynet_name_mixed(self):
192 self.assertRaises(exc.PhysicalNetworkNameError,
193 self.parse_vlan_ranges,
194 ['', ':23:30', 'physnet1',
195 'tenant_net:100:200'])
196
197 def test_validate_provider_phynet_name_bad(self):
198 self.assertRaises(exc.PhysicalNetworkNameError,
199 self.parse_vlan_ranges,
200 [':1:34'])
201
202
203class TestVlanRangeVerifyValid(UtilTestParseVlanRanges):
204 def verify_range(self, vlan_range):
205 return plugin_utils.verify_vlan_range(vlan_range)
206
207 def test_range_valid_ranges(self):
208 self.assertIsNone(self.verify_range((1, 2)))
209 self.assertIsNone(self.verify_range((1, 1999)))
210 self.assertIsNone(self.verify_range((100, 100)))
211 self.assertIsNone(self.verify_range((100, 200)))
212 self.assertIsNone(self.verify_range((4001, 4094)))
213 self.assertIsNone(self.verify_range((1, 4094)))
214
215 def check_one_vlan_invalid(self, bad_range, which):
216 expected_msg = self._vrange_invalid_vlan(bad_range, which)
217 err = self.assertRaises(exc.NetworkVlanRangeError,
218 self.verify_range, bad_range)
219 self.assertEqual(str(err), expected_msg)
220
221 def test_range_first_vlan_invalid_negative(self):
222 self.check_one_vlan_invalid((-1, 199), 1)
223
224 def test_range_first_vlan_invalid_zero(self):
225 self.check_one_vlan_invalid((0, 199), 1)
226
227 def test_range_first_vlan_invalid_limit_plus_one(self):
228 self.check_one_vlan_invalid((4095, 199), 1)
229
230 def test_range_first_vlan_invalid_too_big(self):
231 self.check_one_vlan_invalid((9999, 199), 1)
232
233 def test_range_second_vlan_invalid_negative(self):
234 self.check_one_vlan_invalid((299, -1), 2)
235
236 def test_range_second_vlan_invalid_zero(self):
237 self.check_one_vlan_invalid((299, 0), 2)
238
239 def test_range_second_vlan_invalid_limit_plus_one(self):
240 self.check_one_vlan_invalid((299, 4095), 2)
241
242 def test_range_second_vlan_invalid_too_big(self):
243 self.check_one_vlan_invalid((299, 9999), 2)
244
245 def test_range_both_vlans_invalid_01(self):
246 self.check_one_vlan_invalid((-1, 0), 1)
247
248 def test_range_both_vlans_invalid_02(self):
249 self.check_one_vlan_invalid((0, 4095), 1)
250
251 def test_range_both_vlans_invalid_03(self):
252 self.check_one_vlan_invalid((4095, 9999), 1)
253
254 def test_range_both_vlans_invalid_04(self):
255 self.check_one_vlan_invalid((9999, -1), 1)
256
257 def test_range_reversed(self):
258 bad_range = (95, 10)
259 expected_msg = self._vrange_invalid(bad_range)
260 err = self.assertRaises(exc.NetworkVlanRangeError,
261 self.verify_range, bad_range)
262 self.assertEqual(str(err), expected_msg)
263
264
265class TestParseOneVlanRange(UtilTestParseVlanRanges):
266 def parse_one(self, cfg_entry):
267 return plugin_utils.parse_network_vlan_range(cfg_entry)
268
269 def test_parse_one_net_no_vlan_range(self):
270 config_str = "net1"
271 expected_networks = ("net1", None)
272 self.assertEqual(expected_networks, self.parse_one(config_str))
273
274 def test_parse_one_net_and_vlan_range(self):
275 config_str = "net1:100:199"
276 expected_networks = ("net1", (100, 199))
277 self.assertEqual(expected_networks, self.parse_one(config_str))
278
279 def test_parse_one_net_incomplete_range(self):
280 config_str = "net1:100"
281 expected_msg = self._range_err_bad_count(config_str)
282 err = self.assertRaises(exc.NetworkVlanRangeError,
283 self.parse_one, config_str)
284 self.assertEqual(expected_msg, str(err))
285
286 def test_parse_one_net_range_too_many(self):
287 config_str = "net1:100:150:200"
288 expected_msg = self._range_err_bad_count(config_str)
289 err = self.assertRaises(exc.NetworkVlanRangeError,
290 self.parse_one, config_str)
291 self.assertEqual(expected_msg, str(err))
292
293 def test_parse_one_net_vlan1_not_int(self):
294 config_str = "net1:foo:199"
295 expected_msg = self._range_invalid_vlan(config_str, 1)
296 err = self.assertRaises(exc.NetworkVlanRangeError,
297 self.parse_one, config_str)
298 self.assertEqual(expected_msg, str(err))
299
300 def test_parse_one_net_vlan2_not_int(self):
301 config_str = "net1:100:bar"
302 expected_msg = self._range_invalid_vlan(config_str, 2)
303 err = self.assertRaises(exc.NetworkVlanRangeError,
304 self.parse_one, config_str)
305 self.assertEqual(expected_msg, str(err))
306
307 def test_parse_one_net_and_max_range(self):
308 config_str = "net1:1:4094"
309 expected_networks = ("net1", (1, 4094))
310 self.assertEqual(expected_networks, self.parse_one(config_str))
311
312 def test_parse_one_net_range_bad_vlan1(self):
313 config_str = "net1:9000:150"
314 expected_msg = self._nrange_invalid_vlan(config_str, 1)
315 err = self.assertRaises(exc.NetworkVlanRangeError,
316 self.parse_one, config_str)
317 self.assertEqual(expected_msg, str(err))
318
319 def test_parse_one_net_range_bad_vlan2(self):
320 config_str = "net1:4000:4999"
321 expected_msg = self._nrange_invalid_vlan(config_str, 2)
322 err = self.assertRaises(exc.NetworkVlanRangeError,
323 self.parse_one, config_str)
324 self.assertEqual(expected_msg, str(err))
325
326
327class TestParseVlanRangeList(UtilTestParseVlanRanges):
328 def parse_list(self, cfg_entries):
329 return plugin_utils.parse_network_vlan_ranges(cfg_entries)
330
331 def test_parse_list_one_net_no_vlan_range(self):
332 config_list = ["net1"]
333 expected_networks = {"net1": []}
334 self.assertEqual(expected_networks, self.parse_list(config_list))
335
336 def test_parse_list_one_net_vlan_range(self):
337 config_list = ["net1:100:199"]
338 expected_networks = {"net1": [(100, 199)]}
339 self.assertEqual(expected_networks, self.parse_list(config_list))
340
341 def test_parse_two_nets_no_vlan_range(self):
342 config_list = ["net1",
343 "net2"]
344 expected_networks = {"net1": [],
345 "net2": []}
346 self.assertEqual(expected_networks, self.parse_list(config_list))
347
348 def test_parse_two_nets_range_and_no_range(self):
349 config_list = ["net1:100:199",
350 "net2"]
351 expected_networks = {"net1": [(100, 199)],
352 "net2": []}
353 self.assertEqual(expected_networks, self.parse_list(config_list))
354
355 def test_parse_two_nets_no_range_and_range(self):
356 config_list = ["net1",
357 "net2:200:299"]
358 expected_networks = {"net1": [],
359 "net2": [(200, 299)]}
360 self.assertEqual(expected_networks, self.parse_list(config_list))
361
362 def test_parse_two_nets_bad_vlan_range1(self):
363 config_list = ["net1:100",
364 "net2:200:299"]
365 expected_msg = self._range_err_bad_count(config_list[0])
366 err = self.assertRaises(exc.NetworkVlanRangeError,
367 self.parse_list, config_list)
368 self.assertEqual(expected_msg, str(err))
369
370 def test_parse_two_nets_vlan_not_int2(self):
371 config_list = ["net1:100:199",
372 "net2:200:0x200"]
373 expected_msg = self._range_invalid_vlan(config_list[1], 2)
374 err = self.assertRaises(exc.NetworkVlanRangeError,
375 self.parse_list, config_list)
376 self.assertEqual(expected_msg, str(err))
377
378 def test_parse_two_nets_and_append_1_2(self):
379 config_list = ["net1:100:199",
380 "net1:1000:1099",
381 "net2:200:299"]
382 expected_networks = {"net1": [(100, 199),
383 (1000, 1099)],
384 "net2": [(200, 299)]}
385 self.assertEqual(expected_networks, self.parse_list(config_list))
386
387 def test_parse_two_nets_and_append_1_3(self):
388 config_list = ["net1:100:199",
389 "net2:200:299",
390 "net1:1000:1099"]
391 expected_networks = {"net1": [(100, 199),
392 (1000, 1099)],
393 "net2": [(200, 299)]}
394 self.assertEqual(expected_networks, self.parse_list(config_list))
395
396
397class TestExceptionLogger(base.BaseTestCase): 95class TestExceptionLogger(base.BaseTestCase):
398 def test_normal_call(self): 96 def test_normal_call(self):
399 result = "Result" 97 result = "Result"
diff --git a/neutron/tests/unit/plugins/common/test_utils.py b/neutron/tests/unit/plugins/common/test_utils.py
index 4ce6faf..5148b3e 100644
--- a/neutron/tests/unit/plugins/common/test_utils.py
+++ b/neutron/tests/unit/plugins/common/test_utils.py
@@ -17,10 +17,10 @@ import hashlib
17import mock 17import mock
18from neutron_lib import constants 18from neutron_lib import constants
19from neutron_lib import exceptions 19from neutron_lib import exceptions
20from neutron_lib.plugins import utils
20import testtools 21import testtools
21 22
22from neutron.db import l3_db 23from neutron.db import l3_db
23from neutron.plugins.common import utils
24from neutron.tests import base 24from neutron.tests import base
25 25
26LONG_NAME1 = "A_REALLY_LONG_INTERFACE_NAME1" 26LONG_NAME1 = "A_REALLY_LONG_INTERFACE_NAME1"
diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py
index 4abcf3a..ce7f899 100644
--- a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py
+++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py
@@ -18,12 +18,12 @@ from neutron_lib import constants as p_const
18from neutron_lib import context 18from neutron_lib import context
19from neutron_lib import exceptions as exc 19from neutron_lib import exceptions as exc
20from neutron_lib.plugins.ml2 import api 20from neutron_lib.plugins.ml2 import api
21from neutron_lib.plugins import utils as plugin_utils
21from oslo_config import cfg 22from oslo_config import cfg
22from testtools import matchers 23from testtools import matchers
23 24
24from neutron.db import api as db_api 25from neutron.db import api as db_api
25from neutron.objects.plugins.ml2 import vlanallocation as vlan_alloc_obj 26from neutron.objects.plugins.ml2 import vlanallocation as vlan_alloc_obj
26from neutron.plugins.common import utils as plugin_utils
27from neutron.plugins.ml2.drivers import type_vlan 27from neutron.plugins.ml2.drivers import type_vlan
28from neutron.tests.unit import testlib_api 28from neutron.tests.unit import testlib_api
29 29
diff --git a/neutron/tests/unit/services/trunk/test_rules.py b/neutron/tests/unit/services/trunk/test_rules.py
index f804bcd..b3b6394 100644
--- a/neutron/tests/unit/services/trunk/test_rules.py
+++ b/neutron/tests/unit/services/trunk/test_rules.py
@@ -21,9 +21,9 @@ from neutron_lib.api.definitions import trunk as trunk_api
21from neutron_lib import exceptions as n_exc 21from neutron_lib import exceptions as n_exc
22from neutron_lib.plugins import directory 22from neutron_lib.plugins import directory
23from neutron_lib.plugins.ml2 import api 23from neutron_lib.plugins.ml2 import api
24from neutron_lib.plugins import utils as plugin_utils
24from oslo_utils import uuidutils 25from oslo_utils import uuidutils
25 26
26from neutron.plugins.common import utils
27from neutron.services.trunk import constants 27from neutron.services.trunk import constants
28from neutron.services.trunk import drivers 28from neutron.services.trunk import drivers
29from neutron.services.trunk import exceptions as trunk_exc 29from neutron.services.trunk import exceptions as trunk_exc
@@ -39,7 +39,8 @@ class SubPortsValidatorTestCase(base.BaseTestCase):
39 39
40 def setUp(self): 40 def setUp(self):
41 super(SubPortsValidatorTestCase, self).setUp() 41 super(SubPortsValidatorTestCase, self).setUp()
42 self.segmentation_types = {constants.VLAN: utils.is_valid_vlan_tag} 42 self.segmentation_types = {
43 constants.VLAN: plugin_utils.is_valid_vlan_tag}
43 self.context = mock.ANY 44 self.context = mock.ANY
44 45
45 mock.patch.object(rules.SubPortsValidator, '_get_port_mtu', 46 mock.patch.object(rules.SubPortsValidator, '_get_port_mtu',
@@ -130,7 +131,8 @@ class SubPortsValidatorPrepareTestCase(base.BaseTestCase):
130 131
131 def setUp(self): 132 def setUp(self):
132 super(SubPortsValidatorPrepareTestCase, self).setUp() 133 super(SubPortsValidatorPrepareTestCase, self).setUp()
133 self.segmentation_types = {constants.VLAN: utils.is_valid_vlan_tag} 134 self.segmentation_types = {
135 constants.VLAN: plugin_utils.is_valid_vlan_tag}
134 self.context = mock.ANY 136 self.context = mock.ANY
135 137
136 mock.patch.object(rules.SubPortsValidator, '_get_port_mtu', 138 mock.patch.object(rules.SubPortsValidator, '_get_port_mtu',
@@ -150,7 +152,8 @@ class SubPortsValidatorMtuSanityTestCase(test_plugin.Ml2PluginV2TestCase):
150 152
151 def setUp(self): 153 def setUp(self):
152 super(SubPortsValidatorMtuSanityTestCase, self).setUp() 154 super(SubPortsValidatorMtuSanityTestCase, self).setUp()
153 self.segmentation_types = {constants.VLAN: utils.is_valid_vlan_tag} 155 self.segmentation_types = {
156 constants.VLAN: plugin_utils.is_valid_vlan_tag}
154 157
155 def test_validate_subport_mtu_same_as_trunk(self): 158 def test_validate_subport_mtu_same_as_trunk(self):
156 self._test_validate_subport_trunk_mtu(1500, 1500) 159 self._test_validate_subport_trunk_mtu(1500, 1500)
@@ -230,7 +233,7 @@ class TrunkPortValidatorTestCase(test_plugin.Ml2PluginV2TestCase):
230 trunk_plugin.TrunkPlugin, 'check_compatibility').start() 233 trunk_plugin.TrunkPlugin, 'check_compatibility').start()
231 self.trunk_plugin = trunk_plugin.TrunkPlugin() 234 self.trunk_plugin = trunk_plugin.TrunkPlugin()
232 self.trunk_plugin.add_segmentation_type(constants.VLAN, 235 self.trunk_plugin.add_segmentation_type(constants.VLAN,
233 utils.is_valid_vlan_tag) 236 plugin_utils.is_valid_vlan_tag)
234 237
235 def test_validate_port_parent_in_use_by_trunk(self): 238 def test_validate_port_parent_in_use_by_trunk(self):
236 with self.port() as trunk_parent: 239 with self.port() as trunk_parent: