summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoden R <bodenvmw@gmail.com>2018-07-24 15:52:41 -0600
committerBoden R <bodenvmw@gmail.com>2018-07-30 07:10:23 -0600
commitd7942945c9447e5171f979c69c7af6a9623e305d (patch)
tree37a59acbb98e0dcb822b7af659e739297d18440a
parentf7056ef8449f68687be5d62339a2f659f7ca6ad3 (diff)
use get_port_binding_by_status_and_host from lib
The get_port_binding_by_status_and_host function was rehomed into neutron-lib with https://review.openstack.org/#/c/580786/ and released in neutron-lib 1.18.0. This patch consumes the function by removing it in neutron and replacing all uses with lib's version. NeutronLibImpact Change-Id: Iac3246d0eb59709749e0b7e857091447d11a0133
Notes
Notes (review): Code-Review+2: Brian Haley <haleyb.dev@gmail.com> Code-Review+1: Bernard Cafarelli <bcafarel@redhat.com> Code-Review+2: Miguel Lavalle <miguel.lavalle@huawei.com> Workflow+1: Miguel Lavalle <miguel.lavalle@huawei.com> Code-Review+1: Nate Johnston <nate.johnston@redhat.com> Code-Review+2: Slawek Kaplonski <skaplons@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 01 Aug 2018 14:20:56 +0000 Reviewed-on: https://review.openstack.org/585559 Project: openstack/neutron Branch: refs/heads/master
-rw-r--r--neutron/agent/rpc.py2
-rw-r--r--neutron/common/exceptions.py9
-rw-r--r--neutron/common/utils.py35
-rw-r--r--neutron/plugins/ml2/plugin.py24
-rw-r--r--neutron/services/logapi/common/validators.py2
-rw-r--r--neutron/services/qos/drivers/manager.py2
-rw-r--r--neutron/tests/unit/common/test_utils.py32
-rw-r--r--neutron/tests/unit/plugins/ml2/test_plugin.py11
-rw-r--r--neutron/tests/unit/plugins/ml2/test_port_binding.py2
9 files changed, 26 insertions, 93 deletions
diff --git a/neutron/agent/rpc.py b/neutron/agent/rpc.py
index f84eedf..47fc4a6 100644
--- a/neutron/agent/rpc.py
+++ b/neutron/agent/rpc.py
@@ -23,6 +23,7 @@ from neutron_lib.callbacks import events as callback_events
23from neutron_lib.callbacks import registry 23from neutron_lib.callbacks import registry
24from neutron_lib.callbacks import resources as callback_resources 24from neutron_lib.callbacks import resources as callback_resources
25from neutron_lib import constants 25from neutron_lib import constants
26from neutron_lib.plugins import utils
26from oslo_log import log as logging 27from oslo_log import log as logging
27import oslo_messaging 28import oslo_messaging
28from oslo_utils import uuidutils 29from oslo_utils import uuidutils
@@ -31,7 +32,6 @@ from neutron.agent import resource_cache
31from neutron.api.rpc.callbacks import resources 32from neutron.api.rpc.callbacks import resources
32from neutron.common import constants as n_const 33from neutron.common import constants as n_const
33from neutron.common import rpc as n_rpc 34from neutron.common import rpc as n_rpc
34from neutron.common import utils
35from neutron import objects 35from neutron import objects
36 36
37LOG = logging.getLogger(__name__) 37LOG = logging.getLogger(__name__)
diff --git a/neutron/common/exceptions.py b/neutron/common/exceptions.py
index 702a359..865f974 100644
--- a/neutron/common/exceptions.py
+++ b/neutron/common/exceptions.py
@@ -18,6 +18,10 @@ from neutron_lib import exceptions as e
18from neutron._i18n import _ 18from neutron._i18n import _
19 19
20 20
21# TODO(boden): remove rpc shims
22PortBindingNotFound = e.PortBindingNotFound
23
24
21class SubnetPoolNotFound(e.NotFound): 25class SubnetPoolNotFound(e.NotFound):
22 message = _("Subnet pool %(subnetpool_id)s could not be found.") 26 message = _("Subnet pool %(subnetpool_id)s could not be found.")
23 27
@@ -336,11 +340,6 @@ class FailedToAddQdiscToDevice(e.NeutronException):
336 "to device %(device)s.") 340 "to device %(device)s.")
337 341
338 342
339class PortBindingNotFound(e.NotFound):
340 message = _("Binding for port %(port_id)s for host %(host)s could not be "
341 "found.")
342
343
344class PortBindingAlreadyActive(e.Conflict): 343class PortBindingAlreadyActive(e.Conflict):
345 message = _("Binding for port %(port_id)s on host %(host)s is already " 344 message = _("Binding for port %(port_id)s on host %(host)s is already "
346 "active.") 345 "active.")
diff --git a/neutron/common/utils.py b/neutron/common/utils.py
index 9b1efcc..8af9e18 100644
--- a/neutron/common/utils.py
+++ b/neutron/common/utils.py
@@ -33,7 +33,6 @@ import uuid
33import eventlet 33import eventlet
34from eventlet.green import subprocess 34from eventlet.green import subprocess
35import netaddr 35import netaddr
36from neutron_lib.api.definitions import portbindings_extended as pb_ext
37from neutron_lib import constants as n_const 36from neutron_lib import constants as n_const
38from neutron_lib.utils import helpers 37from neutron_lib.utils import helpers
39from oslo_config import cfg 38from oslo_config import cfg
@@ -45,7 +44,6 @@ import six
45import neutron 44import neutron
46from neutron._i18n import _ 45from neutron._i18n import _
47from neutron.api import api_common 46from neutron.api import api_common
48from neutron.common import exceptions
49from neutron.db import api as db_api 47from neutron.db import api as db_api
50 48
51TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" 49TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
@@ -788,39 +786,6 @@ def bits_to_kilobits(value, base):
788 return int((value + (base - 1)) / base) 786 return int((value + (base - 1)) / base)
789 787
790 788
791def get_port_binding_by_status_and_host(bindings, status, host='',
792 raise_if_not_found=False,
793 port_id=None):
794 """Returns from an iterable the binding with the specified status and host.
795
796 The input iterable can contain zero or one binding in status ACTIVE
797 and zero or many bindings in status INACTIVE. As a consequence, to
798 unequivocally retrieve an inactive binding, the caller must specify a non
799 empty value for host. If host is the empty string, the first binding
800 satisfying the specified status will be returned. If no binding is found
801 with the specified status and host, None is returned or PortBindingNotFound
802 is raised if raise_if_not_found is True
803
804 :param bindings: An iterable containing port bindings
805 :param status: The status of the port binding to return. Possible values
806 are ACTIVE or INACTIVE as defined in
807 :file:`neutron_lib/constants.py`.
808 :param host: str representing the host of the binding to return.
809 :param raise_if_not_found: If a binding is not found and this parameter is
810 True, a PortBindingNotFound exception is raised
811 :param port_id: The id of the binding's port
812 :returns: The searched for port binding or None if it is not found
813 :raises: PortBindingNotFound if the binding is not found and
814 raise_if_not_found is True
815 """
816 for binding in bindings:
817 if binding[pb_ext.STATUS] == status:
818 if not host or binding[pb_ext.HOST] == host:
819 return binding
820 if raise_if_not_found:
821 raise exceptions.PortBindingNotFound(port_id=port_id, host=host)
822
823
824def disable_extension_by_service_plugin(core_plugin, service_plugin): 789def disable_extension_by_service_plugin(core_plugin, service_plugin):
825 if ('filter-validation' in core_plugin.supported_extension_aliases and 790 if ('filter-validation' in core_plugin.supported_extension_aliases and
826 not api_common.is_filter_validation_supported(service_plugin)): 791 not api_common.is_filter_validation_supported(service_plugin)):
diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py
index 265dafd..05e11c6 100644
--- a/neutron/plugins/ml2/plugin.py
+++ b/neutron/plugins/ml2/plugin.py
@@ -254,7 +254,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
254 **kwargs): 254 **kwargs):
255 port_id = object_id 255 port_id = object_id
256 port = db.get_port(context, port_id) 256 port = db.get_port(context, port_id)
257 port_binding = utils.get_port_binding_by_status_and_host( 257 port_binding = p_utils.get_port_binding_by_status_and_host(
258 getattr(port, 'port_bindings', []), const.ACTIVE) 258 getattr(port, 'port_bindings', []), const.ACTIVE)
259 if not port or not port_binding: 259 if not port or not port_binding:
260 LOG.debug("Port %s was deleted so its status cannot be updated.", 260 LOG.debug("Port %s was deleted so its status cannot be updated.",
@@ -510,7 +510,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
510 # mechanism driver update_port_*commit() calls. 510 # mechanism driver update_port_*commit() calls.
511 try: 511 try:
512 port_db = self._get_port(plugin_context, port_id) 512 port_db = self._get_port(plugin_context, port_id)
513 cur_binding = utils.get_port_binding_by_status_and_host( 513 cur_binding = p_utils.get_port_binding_by_status_and_host(
514 port_db.port_bindings, const.ACTIVE) 514 port_db.port_bindings, const.ACTIVE)
515 except exc.PortNotFound: 515 except exc.PortNotFound:
516 port_db, cur_binding = None, None 516 port_db, cur_binding = None, None
@@ -558,7 +558,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
558 cur_context_binding = cur_binding 558 cur_context_binding = cur_binding
559 if new_binding.status == const.INACTIVE: 559 if new_binding.status == const.INACTIVE:
560 cur_context_binding = ( 560 cur_context_binding = (
561 utils.get_port_binding_by_status_and_host( 561 p_utils.get_port_binding_by_status_and_host(
562 port_db.port_bindings, const.INACTIVE, 562 port_db.port_bindings, const.INACTIVE,
563 host=new_binding.host)) 563 host=new_binding.host))
564 cur_context = driver_context.PortContext( 564 cur_context = driver_context.PortContext(
@@ -665,7 +665,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
665 @resource_extend.extends([port_def.COLLECTION_NAME]) 665 @resource_extend.extends([port_def.COLLECTION_NAME])
666 def _ml2_extend_port_dict_binding(port_res, port_db): 666 def _ml2_extend_port_dict_binding(port_res, port_db):
667 plugin = directory.get_plugin() 667 plugin = directory.get_plugin()
668 port_binding = utils.get_port_binding_by_status_and_host( 668 port_binding = p_utils.get_port_binding_by_status_and_host(
669 port_db.port_bindings, const.ACTIVE) 669 port_db.port_bindings, const.ACTIVE)
670 # None when called during unit tests for other plugins. 670 # None when called during unit tests for other plugins.
671 if port_binding: 671 if port_binding:
@@ -1339,7 +1339,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
1339 original_port=original_port) 1339 original_port=original_port)
1340 with db_api.context_manager.writer.using(context): 1340 with db_api.context_manager.writer.using(context):
1341 port_db = self._get_port(context, id) 1341 port_db = self._get_port(context, id)
1342 binding = utils.get_port_binding_by_status_and_host( 1342 binding = p_utils.get_port_binding_by_status_and_host(
1343 port_db.port_bindings, const.ACTIVE) 1343 port_db.port_bindings, const.ACTIVE)
1344 if not binding: 1344 if not binding:
1345 raise exc.PortNotFound(port_id=id) 1345 raise exc.PortNotFound(port_id=id)
@@ -1558,7 +1558,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
1558 with db_api.context_manager.writer.using(context): 1558 with db_api.context_manager.writer.using(context):
1559 try: 1559 try:
1560 port_db = self._get_port(context, id) 1560 port_db = self._get_port(context, id)
1561 binding = utils.get_port_binding_by_status_and_host( 1561 binding = p_utils.get_port_binding_by_status_and_host(
1562 port_db.port_bindings, const.ACTIVE, 1562 port_db.port_bindings, const.ACTIVE,
1563 raise_if_not_found=True, port_id=id) 1563 raise_if_not_found=True, port_id=id)
1564 except exc.PortNotFound: 1564 except exc.PortNotFound:
@@ -1678,7 +1678,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
1678 # related attribute port_binding could disappear in 1678 # related attribute port_binding could disappear in
1679 # concurrent port deletion. 1679 # concurrent port deletion.
1680 # It's not an error condition. 1680 # It's not an error condition.
1681 binding = utils.get_port_binding_by_status_and_host( 1681 binding = p_utils.get_port_binding_by_status_and_host(
1682 port_db.port_bindings, const.ACTIVE) 1682 port_db.port_bindings, const.ACTIVE)
1683 if not binding: 1683 if not binding:
1684 LOG.info("Binding info for port %s was not found, " 1684 LOG.info("Binding info for port %s was not found, "
@@ -1722,7 +1722,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
1722 plugin_context, port['id'], host) 1722 plugin_context, port['id'], host)
1723 bindlevelhost_match = host 1723 bindlevelhost_match = host
1724 else: 1724 else:
1725 binding = utils.get_port_binding_by_status_and_host( 1725 binding = p_utils.get_port_binding_by_status_and_host(
1726 port_db.port_bindings, const.ACTIVE) 1726 port_db.port_bindings, const.ACTIVE)
1727 bindlevelhost_match = binding.host if binding else None 1727 bindlevelhost_match = binding.host if binding else None
1728 if not binding: 1728 if not binding:
@@ -1808,7 +1808,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
1808 # listening for db events can modify the port if necessary 1808 # listening for db events can modify the port if necessary
1809 context.session.flush() 1809 context.session.flush()
1810 updated_port = self._make_port_dict(port) 1810 updated_port = self._make_port_dict(port)
1811 binding = utils.get_port_binding_by_status_and_host( 1811 binding = p_utils.get_port_binding_by_status_and_host(
1812 port.port_bindings, const.ACTIVE, raise_if_not_found=True, 1812 port.port_bindings, const.ACTIVE, raise_if_not_found=True,
1813 port_id=port_id) 1813 port_id=port_id)
1814 levels = db.get_binding_levels(context, port.id, binding.host) 1814 levels = db.get_binding_levels(context, port.id, binding.host)
@@ -2061,7 +2061,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
2061 port_id=port_id, host=attrs[pbe_ext.HOST]) 2061 port_id=port_id, host=attrs[pbe_ext.HOST])
2062 status = const.ACTIVE 2062 status = const.ACTIVE
2063 is_active_binding = True 2063 is_active_binding = True
2064 active_binding = utils.get_port_binding_by_status_and_host( 2064 active_binding = p_utils.get_port_binding_by_status_and_host(
2065 port_db.port_bindings, const.ACTIVE) 2065 port_db.port_bindings, const.ACTIVE)
2066 if active_binding: 2066 if active_binding:
2067 status = const.INACTIVE 2067 status = const.INACTIVE
@@ -2173,12 +2173,12 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
2173 port_id = port_id['port_id'] 2173 port_id = port_id['port_id']
2174 port_db = self._get_port(context, port_id) 2174 port_db = self._get_port(context, port_id)
2175 self._validate_compute_port(port_db) 2175 self._validate_compute_port(port_db)
2176 active_binding = utils.get_port_binding_by_status_and_host( 2176 active_binding = p_utils.get_port_binding_by_status_and_host(
2177 port_db.port_bindings, const.ACTIVE) 2177 port_db.port_bindings, const.ACTIVE)
2178 if host == (active_binding and active_binding.host): 2178 if host == (active_binding and active_binding.host):
2179 raise n_exc.PortBindingAlreadyActive(port_id=port_id, 2179 raise n_exc.PortBindingAlreadyActive(port_id=port_id,
2180 host=host) 2180 host=host)
2181 inactive_binding = utils.get_port_binding_by_status_and_host( 2181 inactive_binding = p_utils.get_port_binding_by_status_and_host(
2182 port_db.port_bindings, const.INACTIVE, host=host) 2182 port_db.port_bindings, const.INACTIVE, host=host)
2183 if not inactive_binding or inactive_binding.host != host: 2183 if not inactive_binding or inactive_binding.host != host:
2184 raise n_exc.PortBindingNotFound(port_id=port_id, host=host) 2184 raise n_exc.PortBindingNotFound(port_id=port_id, host=host)
diff --git a/neutron/services/logapi/common/validators.py b/neutron/services/logapi/common/validators.py
index 24cdde5..3301ca6 100644
--- a/neutron/services/logapi/common/validators.py
+++ b/neutron/services/logapi/common/validators.py
@@ -17,10 +17,10 @@ from neutron_lib.api.definitions import portbindings
17from neutron_lib import constants 17from neutron_lib import constants
18from neutron_lib.plugins import constants as plugin_const 18from neutron_lib.plugins import constants as plugin_const
19from neutron_lib.plugins import directory 19from neutron_lib.plugins import directory
20from neutron_lib.plugins import utils
20from oslo_log import log as logging 21from oslo_log import log as logging
21from sqlalchemy.orm import exc as orm_exc 22from sqlalchemy.orm import exc as orm_exc
22 23
23from neutron.common import utils
24from neutron.db import _utils as db_utils 24from neutron.db import _utils as db_utils
25from neutron.db.models import securitygroup as sg_db 25from neutron.db.models import securitygroup as sg_db
26from neutron.objects import ports 26from neutron.objects import ports
diff --git a/neutron/services/qos/drivers/manager.py b/neutron/services/qos/drivers/manager.py
index b6d4d9a..ae45750 100644
--- a/neutron/services/qos/drivers/manager.py
+++ b/neutron/services/qos/drivers/manager.py
@@ -14,6 +14,7 @@ from neutron_lib.api.definitions import portbindings
14from neutron_lib.callbacks import events 14from neutron_lib.callbacks import events
15from neutron_lib.callbacks import registry 15from neutron_lib.callbacks import registry
16from neutron_lib import constants as lib_constants 16from neutron_lib import constants as lib_constants
17from neutron_lib.plugins import utils
17from neutron_lib.services.qos import constants as qos_consts 18from neutron_lib.services.qos import constants as qos_consts
18from oslo_log import log as logging 19from oslo_log import log as logging
19 20
@@ -23,7 +24,6 @@ from neutron.api.rpc.callbacks import resources
23from neutron.api.rpc.handlers import resources_rpc 24from neutron.api.rpc.handlers import resources_rpc
24from neutron.common import constants 25from neutron.common import constants
25from neutron.common import exceptions 26from neutron.common import exceptions
26from neutron.common import utils
27from neutron.objects.qos import policy as policy_object 27from neutron.objects.qos import policy as policy_object
28 28
29 29
diff --git a/neutron/tests/unit/common/test_utils.py b/neutron/tests/unit/common/test_utils.py
index 1d59fee..41ead62 100644
--- a/neutron/tests/unit/common/test_utils.py
+++ b/neutron/tests/unit/common/test_utils.py
@@ -21,18 +21,14 @@ import ddt
21import eventlet 21import eventlet
22import mock 22import mock
23import netaddr 23import netaddr
24from neutron_lib.api.definitions import portbindings_extended as pb_ext
25from neutron_lib import constants 24from neutron_lib import constants
26from oslo_log import log as logging 25from oslo_log import log as logging
27from oslo_utils import uuidutils
28import six 26import six
29import testscenarios 27import testscenarios
30import testtools 28import testtools
31 29
32from neutron.common import constants as common_constants 30from neutron.common import constants as common_constants
33from neutron.common import exceptions
34from neutron.common import utils 31from neutron.common import utils
35from neutron.objects import ports
36from neutron.tests import base 32from neutron.tests import base
37from neutron.tests.unit import tests 33from neutron.tests.unit import tests
38 34
@@ -528,31 +524,3 @@ class TestIECUnitConversions(BaseUnitConversionTest, base.BaseTestCase):
528 expected_kilobits, 524 expected_kilobits,
529 utils.bits_to_kilobits(input_bits, self.base_unit) 525 utils.bits_to_kilobits(input_bits, self.base_unit)
530 ) 526 )
531
532
533class TestGetPortBindingByStatusAndHost(base.BaseTestCase):
534
535 def test_get_port_binding_by_status_and_host(self):
536 bindings = []
537 self.assertIsNone(utils.get_port_binding_by_status_and_host(
538 bindings, constants.INACTIVE))
539 bindings.extend([ports.PortBinding(
540 port_id=uuidutils.generate_uuid(), host='host-1',
541 status=constants.INACTIVE),
542 ports.PortBinding(
543 port_id=uuidutils.generate_uuid(), host='host-2',
544 status=constants.INACTIVE)])
545 self.assertEqual(
546 'host-1', utils.get_port_binding_by_status_and_host(
547 bindings,
548 constants.INACTIVE)[pb_ext.HOST])
549 self.assertEqual(
550 'host-2', utils.get_port_binding_by_status_and_host(
551 bindings,
552 constants.INACTIVE,
553 host='host-2')[pb_ext.HOST])
554 self.assertIsNone(utils.get_port_binding_by_status_and_host(
555 bindings, constants.ACTIVE))
556 self.assertRaises(exceptions.PortBindingNotFound,
557 utils.get_port_binding_by_status_and_host, bindings,
558 constants.ACTIVE, 'host', True, 'port_id')
diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py
index 2dac6f9..d2bb63e 100644
--- a/neutron/tests/unit/plugins/ml2/test_plugin.py
+++ b/neutron/tests/unit/plugins/ml2/test_plugin.py
@@ -35,6 +35,7 @@ from neutron_lib import fixture
35from neutron_lib.plugins import constants as plugin_constants 35from neutron_lib.plugins import constants as plugin_constants
36from neutron_lib.plugins import directory 36from neutron_lib.plugins import directory
37from neutron_lib.plugins.ml2 import api as driver_api 37from neutron_lib.plugins.ml2 import api as driver_api
38from neutron_lib.plugins import utils as p_utils
38from oslo_config import cfg 39from oslo_config import cfg
39from oslo_db import exception as db_exc 40from oslo_db import exception as db_exc
40from oslo_utils import uuidutils 41from oslo_utils import uuidutils
@@ -1810,7 +1811,7 @@ class TestMl2PortBinding(Ml2PluginV2TestCase,
1810 # create a port and delete it so we have an expired mechanism context 1811 # create a port and delete it so we have an expired mechanism context
1811 with self.port() as port: 1812 with self.port() as port:
1812 plugin = directory.get_plugin() 1813 plugin = directory.get_plugin()
1813 binding = utils.get_port_binding_by_status_and_host( 1814 binding = p_utils.get_port_binding_by_status_and_host(
1814 plugin._get_port(self.context, 1815 plugin._get_port(self.context,
1815 port['port']['id']).port_bindings, 1816 port['port']['id']).port_bindings,
1816 constants.ACTIVE) 1817 constants.ACTIVE)
@@ -1833,7 +1834,7 @@ class TestMl2PortBinding(Ml2PluginV2TestCase,
1833 def _create_port_and_bound_context(self, port_vif_type, bound_vif_type): 1834 def _create_port_and_bound_context(self, port_vif_type, bound_vif_type):
1834 with self.port() as port: 1835 with self.port() as port:
1835 plugin = directory.get_plugin() 1836 plugin = directory.get_plugin()
1836 binding = utils.get_port_binding_by_status_and_host( 1837 binding = p_utils.get_port_binding_by_status_and_host(
1837 plugin._get_port(self.context, 1838 plugin._get_port(self.context,
1838 port['port']['id']).port_bindings, 1839 port['port']['id']).port_bindings,
1839 constants.ACTIVE) 1840 constants.ACTIVE)
@@ -1950,7 +1951,7 @@ class TestMl2PortBinding(Ml2PluginV2TestCase,
1950 def test_update_port_binding_host_id_none(self): 1951 def test_update_port_binding_host_id_none(self):
1951 with self.port() as port: 1952 with self.port() as port:
1952 plugin = directory.get_plugin() 1953 plugin = directory.get_plugin()
1953 binding = utils.get_port_binding_by_status_and_host( 1954 binding = p_utils.get_port_binding_by_status_and_host(
1954 plugin._get_port(self.context, 1955 plugin._get_port(self.context,
1955 port['port']['id']).port_bindings, 1956 port['port']['id']).port_bindings,
1956 constants.ACTIVE) 1957 constants.ACTIVE)
@@ -1972,7 +1973,7 @@ class TestMl2PortBinding(Ml2PluginV2TestCase,
1972 def test_update_port_binding_host_id_not_changed(self): 1973 def test_update_port_binding_host_id_not_changed(self):
1973 with self.port() as port: 1974 with self.port() as port:
1974 plugin = directory.get_plugin() 1975 plugin = directory.get_plugin()
1975 binding = utils.get_port_binding_by_status_and_host( 1976 binding = p_utils.get_port_binding_by_status_and_host(
1976 plugin._get_port(self.context, 1977 plugin._get_port(self.context,
1977 port['port']['id']).port_bindings, 1978 port['port']['id']).port_bindings,
1978 constants.ACTIVE) 1979 constants.ACTIVE)
@@ -2961,7 +2962,7 @@ class TestML2Segments(Ml2PluginV2TestCase):
2961 # add writer here to make sure that the following operations are 2962 # add writer here to make sure that the following operations are
2962 # performed in the same session 2963 # performed in the same session
2963 with db_api.context_manager.writer.using(self.context): 2964 with db_api.context_manager.writer.using(self.context):
2964 binding = utils.get_port_binding_by_status_and_host( 2965 binding = p_utils.get_port_binding_by_status_and_host(
2965 plugin._get_port(self.context, 2966 plugin._get_port(self.context,
2966 port['port']['id']).port_bindings, 2967 port['port']['id']).port_bindings,
2967 constants.ACTIVE) 2968 constants.ACTIVE)
diff --git a/neutron/tests/unit/plugins/ml2/test_port_binding.py b/neutron/tests/unit/plugins/ml2/test_port_binding.py
index 41c6027..f6f84f9 100644
--- a/neutron/tests/unit/plugins/ml2/test_port_binding.py
+++ b/neutron/tests/unit/plugins/ml2/test_port_binding.py
@@ -19,12 +19,12 @@ from neutron_lib.api.definitions import portbindings_extended as pbe_ext
19from neutron_lib import constants as const 19from neutron_lib import constants as const
20from neutron_lib import context 20from neutron_lib import context
21from neutron_lib.plugins import directory 21from neutron_lib.plugins import directory
22from neutron_lib.plugins import utils
22from oslo_config import cfg 23from oslo_config import cfg
23from oslo_serialization import jsonutils 24from oslo_serialization import jsonutils
24import webob.exc 25import webob.exc
25 26
26from neutron.common import exceptions 27from neutron.common import exceptions
27from neutron.common import utils
28from neutron.conf.plugins.ml2 import config 28from neutron.conf.plugins.ml2 import config
29from neutron.conf.plugins.ml2.drivers import driver_type 29from neutron.conf.plugins.ml2.drivers import driver_type
30from neutron.plugins.ml2 import driver_context 30from neutron.plugins.ml2 import driver_context