From a22d6d6a95246875de9f2a7d1bda1f762bfef846 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Fri, 17 Dec 2021 17:45:14 +0100 Subject: [PATCH] Use ovs constants from neutron-lib Ovs constants were moved from neutron to neutron_lib some time ago. This patch switches to use them from neutron-lib already. That decision was agreed during the Neutron team meeting. See [1] for details. [1] https://meetings.opendev.org/meetings/networking/2021/networking.2021-11-09-14.00.log.html#l-83 Requires: https://review.opendev.org/c/openstack/neutron-lib/+/834908 Change-Id: I2fd1954bec6a52856195190441d77ac8b7d97055 --- neutron/agent/common/ovs_lib.py | 43 +++++---- neutron/agent/common/polling.py | 6 +- neutron/agent/l2/extensions/fdb_population.py | 3 +- neutron/agent/l2/extensions/local_ip.py | 3 +- neutron/agent/linux/interface.py | 3 +- .../linux/openvswitch_firewall/firewall.py | 3 +- .../agent/linux/openvswitch_firewall/rules.py | 3 +- neutron/agent/ovsdb/impl_idl.py | 4 +- neutron/cmd/destroy_patch_ports.py | 9 +- neutron/cmd/sanity/checks.py | 3 +- neutron/conf/plugins/ml2/drivers/ovs_conf.py | 14 +-- .../agent/openflow/native/br_dvr_process.py | 3 +- .../agent/openflow/native/br_int.py | 2 +- .../agent/openflow/native/br_phys.py | 3 +- .../agent/openflow/native/br_tun.py | 2 +- .../agent/openflow/native/ovs_bridge.py | 3 +- .../agent/ovs_dvr_neutron_agent.py | 71 +++++++------- .../openvswitch/agent/ovs_neutron_agent.py | 93 +++++++++---------- .../mech_driver/mech_openvswitch.py | 17 ++-- .../drivers/openvswitch/ovs_firewall_log.py | 3 +- .../openvswitch/agent/ovsdb_handler.py | 3 +- .../trunk/drivers/openvswitch/driver.py | 3 +- neutron/tests/common/conn_testers.py | 3 +- neutron/tests/fullstack/test_logging.py | 3 +- neutron/tests/fullstack/test_qos.py | 3 +- .../functional/agent/common/test_ovs_lib.py | 3 +- neutron/tests/functional/agent/l2/base.py | 4 +- .../functional/agent/test_l2_ovs_agent.py | 16 ++-- .../tests/functional/agent/test_ovs_flows.py | 6 +- .../tests/functional/agent/test_ovs_lib.py | 3 +- .../cmd/test_destroy_patch_ports.py | 8 +- .../tests/functional/cmd/test_ovs_cleanup.py | 5 +- .../services/logapi/test_logging.py | 3 +- .../tests/unit/agent/common/test_ovs_lib.py | 3 +- .../l2/extensions/test_fdb_population.py | 3 +- .../unit/agent/l2/extensions/test_local_ip.py | 3 +- .../unit/agent/l2/extensions/test_qos.py | 8 +- .../openvswitch_firewall/test_firewall.py | 3 +- .../linux/openvswitch_firewall/test_rules.py | 3 +- .../tests/unit/agent/linux/test_interface.py | 3 +- .../openflow/native/ovs_bridge_test_base.py | 12 +-- .../agent/openflow/native/test_br_int.py | 17 ++-- .../agent/openflow/native/test_br_phys.py | 4 +- .../agent/openflow/native/test_br_tun.py | 4 +- .../agent/test_ovs_neutron_agent.py | 65 ++++++------- .../openvswitch/agent/test_ovs_tunnel.py | 22 ++--- .../mech_driver/test_mech_openvswitch.py | 3 +- .../logapi/agent/test_log_extension.py | 6 +- .../openvswitch/test_ovs_firewall_log.py | 3 +- .../trunk/drivers/openvswitch/test_driver.py | 3 +- 50 files changed, 250 insertions(+), 269 deletions(-) diff --git a/neutron/agent/common/ovs_lib.py b/neutron/agent/common/ovs_lib.py index 21359220fc9..8eb53f6a11d 100644 --- a/neutron/agent/common/ovs_lib.py +++ b/neutron/agent/common/ovs_lib.py @@ -22,6 +22,7 @@ import uuid from neutron_lib import constants as p_const from neutron_lib import exceptions +from neutron_lib.plugins.ml2 import ovs_constants from neutron_lib.services.qos import constants as qos_constants from oslo_config import cfg from oslo_log import log as logging @@ -40,8 +41,6 @@ from neutron.agent.ovsdb import impl_idl from neutron.common import _constants as common_constants from neutron.common import utils as common_utils from neutron.conf.agent import ovs_conf -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants from neutron.plugins.ml2.drivers.openvswitch.agent.common \ import exceptions as ovs_exc @@ -156,7 +155,7 @@ class BaseOVS(object): raise def add_bridge(self, bridge_name, - datapath_type=constants.OVS_DATAPATH_SYSTEM): + datapath_type=ovs_constants.OVS_DATAPATH_SYSTEM): br = OVSBridge(bridge_name, datapath_type=datapath_type) br.create() return br @@ -225,12 +224,12 @@ class BaseOVS(object): # Map from version string to on-the-wire protocol version encoding: OF_PROTOCOL_TO_VERSION = { - constants.OPENFLOW10: 1, - constants.OPENFLOW11: 2, - constants.OPENFLOW12: 3, - constants.OPENFLOW13: 4, - constants.OPENFLOW14: 5, - constants.OPENFLOW15: 6, + ovs_constants.OPENFLOW10: 1, + ovs_constants.OPENFLOW11: 2, + ovs_constants.OPENFLOW12: 3, + ovs_constants.OPENFLOW13: 4, + ovs_constants.OPENFLOW14: 5, + ovs_constants.OPENFLOW15: 6, } @@ -244,18 +243,21 @@ def version_from_protocol(protocol): class OVSBridge(BaseOVS): - def __init__(self, br_name, datapath_type=constants.OVS_DATAPATH_SYSTEM): + def __init__(self, br_name, + datapath_type=ovs_constants.OVS_DATAPATH_SYSTEM): super(OVSBridge, self).__init__() self.br_name = br_name self.datapath_type = datapath_type self._default_cookie = generate_random_cookie() - self._highest_protocol_needed = constants.OPENFLOW10 + self._highest_protocol_needed = ovs_constants.OPENFLOW10 self._min_bw_qos_id = uuidutils.generate_uuid() # TODO(jlibosva): Revert initial_protocols once launchpad bug 1852221 # is fixed and new openvswitch containing the fix is # released. self.initial_protocols = { - constants.OPENFLOW10, constants.OPENFLOW13, constants.OPENFLOW14} + ovs_constants.OPENFLOW10, + ovs_constants.OPENFLOW13, + ovs_constants.OPENFLOW14} self.initial_protocols.add(self._highest_protocol_needed) self._flows_per_port = cfg.CONF.OVS.openflow_processed_per_port @@ -395,7 +397,7 @@ class OVSBridge(BaseOVS): # may trigger issues on ovs-vswitchd related to the # datapath flow revalidator thread, see lp#1767422 txn.add(self.ovsdb.db_set( - 'Port', port_name, ('tag', constants.DEAD_VLAN_TAG))) + 'Port', port_name, ('tag', ovs_constants.DEAD_VLAN_TAG))) # Just setting 'tag' to 4095 is not enough to prevent any traffic # to/from new port because "access" ports do not have 802.1Q header # and hence are not matched by default 4095-dropping rule. @@ -409,7 +411,7 @@ class OVSBridge(BaseOVS): txn.add(self.ovsdb.db_set( 'Port', port_name, ('vlan_mode', 'trunk'))) txn.add(self.ovsdb.db_set( - 'Port', port_name, ('trunks', constants.DEAD_VLAN_TAG))) + 'Port', port_name, ('trunks', ovs_constants.DEAD_VLAN_TAG))) def delete_port(self, port_name): self.ovsdb.del_port(port_name, self.br_name).execute() @@ -851,12 +853,12 @@ class OVSBridge(BaseOVS): # we can try to use same reg4 for both OF rules, this one and the one # which sets pkt_mark for minimum bandwidth and play with bitmask self.add_flow( - table=constants.LOCAL_SWITCHING, + table=ovs_constants.LOCAL_SWITCHING, reg3=0, priority=200, actions=("set_queue:%s,load:1->NXM_NX_REG3[0]," "resubmit(,%s)" % (QOS_DEFAULT_QUEUE, - constants.LOCAL_SWITCHING))) + ovs_constants.LOCAL_SWITCHING))) def _update_ingress_bw_limit_for_port( self, port_name, max_kbps, max_burst_kbps): @@ -896,7 +898,7 @@ class OVSBridge(BaseOVS): def update_ingress_bw_limit_for_port(self, port_name, max_kbps, max_burst_kbps): port_type = self._get_port_val(port_name, "type") - if port_type in constants.OVS_DPDK_PORT_TYPES: + if port_type in ovs_constants.OVS_DPDK_PORT_TYPES: self._update_ingress_bw_limit_for_dpdk_port( port_name, max_kbps, max_burst_kbps) else: @@ -990,12 +992,13 @@ class OVSBridge(BaseOVS): # load 1 to reg4), then goto table 0 again. The packet will be handled # as usual when the second visit to table 0. self.add_flow( - table=constants.LOCAL_SWITCHING, + table=ovs_constants.LOCAL_SWITCHING, in_port=queue_num, reg4=0, priority=200, actions=("set_field:%s->pkt_mark,load:1->NXM_NX_REG4[0]," - "resubmit(,%s)" % (queue_num, constants.LOCAL_SWITCHING))) + "resubmit(,%s)" % (queue_num, + ovs_constants.LOCAL_SWITCHING))) def set_queue_for_minimum_bandwidth(self, queue_num): # reg4 is used to memoize if queue was set or not. If it is first visit @@ -1015,7 +1018,7 @@ class OVSBridge(BaseOVS): def _unset_pkt_mark_for_minimum_bandwidth(self, queue_num): self.delete_flows( - table=constants.LOCAL_SWITCHING, + table=ovs_constants.LOCAL_SWITCHING, in_port=queue_num, reg4=0) diff --git a/neutron/agent/common/polling.py b/neutron/agent/common/polling.py index dc1adb2aa2b..85e9731fe15 100644 --- a/neutron/agent/common/polling.py +++ b/neutron/agent/common/polling.py @@ -16,13 +16,13 @@ import contextlib import eventlet +from neutron_lib.plugins.ml2 import ovs_constants as ovs_const from oslo_config import cfg from oslo_log import log as logging from neutron.agent.common import async_process from neutron.agent.common import base_polling from neutron.agent.common import ovsdb_monitor -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants LOG = logging.getLogger(__name__) @@ -30,7 +30,7 @@ LOG = logging.getLogger(__name__) @contextlib.contextmanager def get_polling_manager(minimize_polling=False, ovsdb_monitor_respawn_interval=( - constants.DEFAULT_OVSDBMON_RESPAWN), + ovs_const.DEFAULT_OVSDBMON_RESPAWN), bridge_names=None, ovs=None): if minimize_polling: pm = InterfacePollingMinimizer( @@ -51,7 +51,7 @@ class InterfacePollingMinimizer(base_polling.BasePollingManager): def __init__( self, - ovsdb_monitor_respawn_interval=constants.DEFAULT_OVSDBMON_RESPAWN, + ovsdb_monitor_respawn_interval=ovs_const.DEFAULT_OVSDBMON_RESPAWN, bridge_names=None, ovs=None): super(InterfacePollingMinimizer, self).__init__() diff --git a/neutron/agent/l2/extensions/fdb_population.py b/neutron/agent/l2/extensions/fdb_population.py index c0c9c50636d..bd764ec0555 100644 --- a/neutron/agent/l2/extensions/fdb_population.py +++ b/neutron/agent/l2/extensions/fdb_population.py @@ -17,6 +17,7 @@ import sys from neutron_lib.agent import l2_extension from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants from neutron_lib.utils import helpers from oslo_config import cfg from oslo_log import log as logging @@ -27,8 +28,6 @@ from neutron.agent.linux import bridge_lib from neutron.conf.agent import l2_ext_fdb_population from neutron.plugins.ml2.drivers.linuxbridge.agent.common import ( constants as linux_bridge_constants) -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as ovs_constants) l2_ext_fdb_population.register_fdb_population_opts() diff --git a/neutron/agent/l2/extensions/local_ip.py b/neutron/agent/l2/extensions/local_ip.py index bca56f7d109..4cf196f636c 100644 --- a/neutron/agent/l2/extensions/local_ip.py +++ b/neutron/agent/l2/extensions/local_ip.py @@ -21,6 +21,7 @@ from neutron_lib.agent import l2_extension from neutron_lib.callbacks import events as lib_events from neutron_lib.callbacks import registry as lib_registry from neutron_lib import context as lib_ctx +from neutron_lib.plugins.ml2 import ovs_constants from os_ken.lib.packet import ether_types from os_ken.lib.packet import in_proto as ip_proto from oslo_config import cfg @@ -32,8 +33,6 @@ from neutron.api.rpc.callbacks import resources from neutron.api.rpc.handlers import resources_rpc from neutron.plugins.ml2.drivers.openvswitch.agent import ( ovs_neutron_agent as ovs_agent) -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as ovs_constants) LOG = logging.getLogger(__name__) diff --git a/neutron/agent/linux/interface.py b/neutron/agent/linux/interface.py index 41d50ee4b21..3470182f366 100644 --- a/neutron/agent/linux/interface.py +++ b/neutron/agent/linux/interface.py @@ -20,6 +20,7 @@ import netaddr from neutron_lib.agent.linux import interface from neutron_lib import constants from neutron_lib import exceptions +from neutron_lib.plugins.ml2 import ovs_constants as ovs_const from oslo_log import log as logging from oslo_utils import excutils from pyroute2.netlink import exceptions \ @@ -29,8 +30,6 @@ from neutron.agent.common import ovs_lib from neutron.agent.linux import ip_lib from neutron.common import utils from neutron.conf.plugins.ml2.drivers import ovs_conf -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants as ovs_const from neutron.privileged.agent.linux import ethtool LOG = logging.getLogger(__name__) diff --git a/neutron/agent/linux/openvswitch_firewall/firewall.py b/neutron/agent/linux/openvswitch_firewall/firewall.py index 627b1c5d65b..9abec13c7ae 100644 --- a/neutron/agent/linux/openvswitch_firewall/firewall.py +++ b/neutron/agent/linux/openvswitch_firewall/firewall.py @@ -25,6 +25,7 @@ from neutron_lib.callbacks import events as callbacks_events from neutron_lib.callbacks import registry as callbacks_registry from neutron_lib.callbacks import resources as callbacks_resources from neutron_lib import constants as lib_const +from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from neutron_lib.plugins import utils as p_utils from neutron_lib.utils import helpers from oslo_config import cfg @@ -39,8 +40,6 @@ from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts from neutron.agent.linux.openvswitch_firewall import exceptions from neutron.agent.linux.openvswitch_firewall import iptables from neutron.agent.linux.openvswitch_firewall import rules -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \ - as ovs_consts LOG = logging.getLogger(__name__) CONJ_ID_REGEX = re.compile(r"conj_id=(\d+),") diff --git a/neutron/agent/linux/openvswitch_firewall/rules.py b/neutron/agent/linux/openvswitch_firewall/rules.py index ef59be5b3dd..f592e22f974 100644 --- a/neutron/agent/linux/openvswitch_firewall/rules.py +++ b/neutron/agent/linux/openvswitch_firewall/rules.py @@ -17,12 +17,11 @@ import collections import netaddr from neutron_lib import constants as n_consts +from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from neutron._i18n import _ from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts from neutron.common import utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \ - as ovs_consts CT_STATES = [ ovsfw_consts.OF_STATE_ESTABLISHED_NOT_REPLY, diff --git a/neutron/agent/ovsdb/impl_idl.py b/neutron/agent/ovsdb/impl_idl.py index 17f4e608939..3f82abcc1ee 100644 --- a/neutron/agent/ovsdb/impl_idl.py +++ b/neutron/agent/ovsdb/impl_idl.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib.plugins.ml2 import ovs_constants from oslo_config import cfg from ovsdbapp.backend.ovs_idl import command from ovsdbapp.backend.ovs_idl import connection @@ -22,7 +23,6 @@ from ovsdbapp.schema.open_vswitch import impl_idl from neutron.agent.ovsdb.native import connection as n_connection from neutron.common import utils from neutron.conf.agent import ovs_conf -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants ovs_conf.register_ovs_agent_opts() @@ -62,7 +62,7 @@ class OvsCleanup(command.BaseCommand): # Deletable defined as "looks like vif port and not set to skip delete" if self.all_ports: return True - if constants.SKIP_CLEANUP in port.external_ids: + if ovs_constants.SKIP_CLEANUP in port.external_ids: return False if not all(field in port.external_ids for field in ('iface-id', 'attached-mac')): diff --git a/neutron/cmd/destroy_patch_ports.py b/neutron/cmd/destroy_patch_ports.py index 2fa6dc4acda..62401fbe206 100644 --- a/neutron/cmd/destroy_patch_ports.py +++ b/neutron/cmd/destroy_patch_ports.py @@ -15,6 +15,7 @@ import sys +from neutron_lib.plugins.ml2 import ovs_constants from neutron_lib.plugins import utils as p_utils from neutron_lib.utils import helpers from oslo_config import cfg @@ -24,16 +25,15 @@ from neutron.agent.common import ovs_lib from neutron.common import config as common_config from neutron.conf.agent import common as agent_config from neutron.conf.plugins.ml2.drivers import ovs_conf -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants LOG = logging.getLogger(__name__) def get_patch_port_names(bridge_name): int_if_name = p_utils.get_interface_name( - bridge_name, prefix=constants.PEER_INTEGRATION_PREFIX) + bridge_name, prefix=ovs_constants.PEER_INTEGRATION_PREFIX) phys_if_name = p_utils.get_interface_name( - bridge_name, prefix=constants.PEER_PHYSICAL_PREFIX) + bridge_name, prefix=ovs_constants.PEER_PHYSICAL_PREFIX) return int_if_name, phys_if_name @@ -74,7 +74,8 @@ class PatchPortCleaner(object): """ LOG.debug("Get configured flows for integration bridge %s", self.int_br.br_name) - return bool(self.int_br.dump_flows_for(table=constants.CANARY_TABLE)) + return bool( + self.int_br.dump_flows_for(table=ovs_constants.CANARY_TABLE)) def main(): diff --git a/neutron/cmd/sanity/checks.py b/neutron/cmd/sanity/checks.py index 819c9b4dcf3..ba6b14fd84b 100644 --- a/neutron/cmd/sanity/checks.py +++ b/neutron/cmd/sanity/checks.py @@ -21,6 +21,7 @@ import tempfile import netaddr from neutron_lib import constants as n_consts from neutron_lib import exceptions +from neutron_lib.plugins.ml2 import ovs_constants as ovs_const from neutron_lib.utils import helpers from oslo_config import cfg from oslo_log import log as logging @@ -36,8 +37,6 @@ from neutron.agent.linux import keepalived from neutron.agent.linux import utils as agent_utils from neutron.common import utils as common_utils from neutron.conf.agent.l3 import config as l3_config -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants as ovs_const from neutron.privileged.agent.linux import dhcp as priv_dhcp LOG = logging.getLogger(__name__) diff --git a/neutron/conf/plugins/ml2/drivers/ovs_conf.py b/neutron/conf/plugins/ml2/drivers/ovs_conf.py index f585bcbfd82..f6bc332f509 100644 --- a/neutron/conf/plugins/ml2/drivers/ovs_conf.py +++ b/neutron/conf/plugins/ml2/drivers/ovs_conf.py @@ -13,12 +13,11 @@ # under the License. from neutron_lib import constants as n_const +from neutron_lib.plugins.ml2 import ovs_constants from oslo_config import cfg from neutron._i18n import _ from neutron.conf.agent import common -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants DEFAULT_BRIDGE_MAPPINGS = [] @@ -149,13 +148,14 @@ ovs_opts = [ "See also: " "https://docs.openstack.org/api-ref/placement/" "#update-resource-provider-inventories")), - cfg.StrOpt('datapath_type', default=constants.OVS_DATAPATH_SYSTEM, - choices=[constants.OVS_DATAPATH_SYSTEM, - constants.OVS_DATAPATH_NETDEV], + cfg.StrOpt('datapath_type', default=ovs_constants.OVS_DATAPATH_SYSTEM, + choices=[ovs_constants.OVS_DATAPATH_SYSTEM, + ovs_constants.OVS_DATAPATH_NETDEV], help=_("OVS datapath to use. 'system' is the default value and " "corresponds to the kernel datapath. To enable the " "userspace datapath set this value to 'netdev'.")), - cfg.StrOpt('vhostuser_socket_dir', default=constants.VHOST_USER_SOCKET_DIR, + cfg.StrOpt('vhostuser_socket_dir', + default=ovs_constants.VHOST_USER_SOCKET_DIR, help=_("OVS vhost-user socket directory.")), cfg.IPOpt('of_listen_address', default='127.0.0.1', help=_("Address to listen on for OpenFlow connections.")), @@ -188,7 +188,7 @@ agent_opts = [ help=_("Minimize polling by monitoring ovsdb for interface " "changes.")), cfg.IntOpt('ovsdb_monitor_respawn_interval', - default=constants.DEFAULT_OVSDBMON_RESPAWN, + default=ovs_constants.DEFAULT_OVSDBMON_RESPAWN, help=_("The number of seconds to wait before respawning the " "ovsdb monitor after losing communication with it.")), cfg.ListOpt('tunnel_types', default=DEFAULT_TUNNEL_TYPES, diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_dvr_process.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_dvr_process.py index c447be76d61..46dfc84f0f4 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_dvr_process.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_dvr_process.py @@ -14,13 +14,12 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib.plugins.ml2 import ovs_constants as constants from os_ken.lib.packet import arp from os_ken.lib.packet import ether_types from os_ken.lib.packet import icmpv6 from os_ken.lib.packet import in_proto -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants - class OVSDVRInterfaceMixin(object): diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_int.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_int.py index e79b12436aa..904268882d2 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_int.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_int.py @@ -23,12 +23,12 @@ import netaddr from neutron_lib import constants as lib_consts +from neutron_lib.plugins.ml2 import ovs_constants as constants from os_ken.lib.packet import ether_types from os_ken.lib.packet import icmpv6 from os_ken.lib.packet import in_proto from oslo_log import log as logging -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ import br_dvr_process from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_phys.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_phys.py index 50aa0b73192..9199720af73 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_phys.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_phys.py @@ -14,7 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants +from neutron_lib.plugins.ml2 import ovs_constants as constants + from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ import br_dvr_process from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_tun.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_tun.py index 8bdf38c9215..921254e6fe9 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_tun.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_tun.py @@ -15,9 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib.plugins.ml2 import ovs_constants as constants from os_ken.lib.packet import ether_types -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ import br_dvr_process from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_bridge.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_bridge.py index 28a7f3add30..3cf32142764 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_bridge.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_bridge.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from os_ken.lib.packet import arp from os_ken.lib.packet import ether_types from oslo_log import log as logging @@ -22,8 +23,6 @@ from oslo_utils import excutils from neutron._i18n import _ from neutron.agent.common import ovs_lib from neutron.common import ipv6_utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \ - as ovs_consts from neutron.plugins.ml2.drivers.openvswitch.agent.openflow \ import br_cookie from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py index be0d5349932..b30895ad5e5 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py @@ -18,6 +18,7 @@ import sys import netaddr from neutron_lib import constants as n_const +from neutron_lib.plugins.ml2 import ovs_constants from oslo_config import cfg from oslo_log import log as logging import oslo_messaging @@ -27,7 +28,6 @@ from osprofiler import profiler from neutron.agent.common import ovs_lib from neutron.agent.linux.openvswitch_firewall import firewall as ovs_firewall from neutron.common import utils as n_utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants LOG = logging.getLogger(__name__) @@ -35,7 +35,7 @@ LOG = logging.getLogger(__name__) # A class to represent a DVR-hosted subnet including vif_ports resident on # that subnet class LocalDVRSubnetMapping(object): - def __init__(self, subnet, csnat_ofport=constants.OFPORT_INVALID): + def __init__(self, subnet, csnat_ofport=ovs_constants.OFPORT_INVALID): # set of compute ports on this dvr subnet self.compute_ports = {} # set of dvr router interfaces on this subnet @@ -143,8 +143,8 @@ class OVSDVRNeutronAgent(object): def __init__(self, context, plugin_rpc, integ_br, tun_br, bridge_mappings, phys_brs, int_ofports, phys_ofports, - patch_int_ofport=constants.OFPORT_INVALID, - patch_tun_ofport=constants.OFPORT_INVALID, + patch_int_ofport=ovs_constants.OFPORT_INVALID, + patch_tun_ofport=ovs_constants.OFPORT_INVALID, host=None, enable_tunneling=False, enable_distributed_routing=False): self.context = context @@ -247,13 +247,14 @@ class OVSDVRNeutronAgent(object): self.int_br.setup_canary_table() # Insert 'drop' action as the default for Table DVR_TO_SRC_MAC - self.int_br.install_drop(table_id=constants.DVR_TO_SRC_MAC, priority=1) + self.int_br.install_drop( + table_id=ovs_constants.DVR_TO_SRC_MAC, priority=1) - self.int_br.install_drop(table_id=constants.DVR_TO_SRC_MAC_PHYSICAL, - priority=1) + self.int_br.install_drop( + table_id=ovs_constants.DVR_TO_SRC_MAC_PHYSICAL, priority=1) for physical_network in self.bridge_mappings: - self.int_br.install_drop(table_id=constants.LOCAL_SWITCHING, + self.int_br.install_drop(table_id=ovs_constants.LOCAL_SWITCHING, priority=2, in_port=self.int_ofports[ physical_network]) @@ -263,16 +264,16 @@ class OVSDVRNeutronAgent(object): if not self.enable_tunneling: return - self.tun_br.install_goto(dest_table_id=constants.DVR_PROCESS, + self.tun_br.install_goto(dest_table_id=ovs_constants.DVR_PROCESS, priority=1, in_port=self.patch_int_ofport) # table-miss should be sent to learning table - self.tun_br.install_goto(table_id=constants.DVR_NOT_LEARN, - dest_table_id=constants.LEARN_FROM_TUN) + self.tun_br.install_goto(table_id=ovs_constants.DVR_NOT_LEARN, + dest_table_id=ovs_constants.LEARN_FROM_TUN) - self.tun_br.install_goto(table_id=constants.DVR_PROCESS, - dest_table_id=constants.PATCH_LV_TO_TUN) + self.tun_br.install_goto(table_id=ovs_constants.DVR_PROCESS, + dest_table_id=ovs_constants.PATCH_LV_TO_TUN) def setup_dvr_flows_on_phys_br(self, bridge_mappings=None): '''Setup up initial dvr flows into br-phys''' @@ -281,20 +282,20 @@ class OVSDVRNeutronAgent(object): self.phys_brs[physical_network].install_goto( in_port=self.phys_ofports[physical_network], priority=2, - dest_table_id=constants.DVR_PROCESS_PHYSICAL) + dest_table_id=ovs_constants.DVR_PROCESS_PHYSICAL) self.phys_brs[physical_network].install_goto( priority=1, - dest_table_id=constants.DVR_NOT_LEARN_PHYSICAL) + dest_table_id=ovs_constants.DVR_NOT_LEARN_PHYSICAL) self.phys_brs[physical_network].install_goto( - table_id=constants.DVR_PROCESS_PHYSICAL, + table_id=ovs_constants.DVR_PROCESS_PHYSICAL, priority=0, - dest_table_id=constants.LOCAL_VLAN_TRANSLATION) + dest_table_id=ovs_constants.LOCAL_VLAN_TRANSLATION) self.phys_brs[physical_network].install_drop( - table_id=constants.LOCAL_VLAN_TRANSLATION, + table_id=ovs_constants.LOCAL_VLAN_TRANSLATION, in_port=self.phys_ofports[physical_network], priority=2) self.phys_brs[physical_network].install_normal( - table_id=constants.DVR_NOT_LEARN_PHYSICAL, + table_id=ovs_constants.DVR_NOT_LEARN_PHYSICAL, priority=1) def _add_dvr_mac_for_phys_br(self, physical_network, mac): @@ -427,7 +428,7 @@ class OVSDVRNeutronAgent(object): ldm.set_dvr_owned(True) vlan_to_use = lvm.vlan - if lvm.network_type in constants.DVR_PHYSICAL_NETWORK_TYPES: + if lvm.network_type in ovs_constants.DVR_PHYSICAL_NETWORK_TYPES: vlan_to_use = lvm.segmentation_id subnet_info = ldm.get_subnet_info() @@ -488,11 +489,11 @@ class OVSDVRNeutronAgent(object): dvr_mac=self.dvr_mac_address, rtr_port=port.ofport) - if lvm.network_type in constants.DVR_PHYSICAL_NETWORK_TYPES: + if lvm.network_type in ovs_constants.DVR_PHYSICAL_NETWORK_TYPES: # TODO(vivek) remove the IPv6 related flows once SNAT is not # used for IPv6 DVR. br = self.phys_brs[lvm.physical_network] - if lvm.network_type in constants.TUNNEL_NETWORK_TYPES: + if lvm.network_type in ovs_constants.TUNNEL_NETWORK_TYPES: br = self.tun_br # TODO(vivek) remove the IPv6 related flows once SNAT is not # used for IPv6 DVR. @@ -558,7 +559,7 @@ class OVSDVRNeutronAgent(object): ovsport.add_subnet(subnet_uuid) self.local_ports[port.vif_id] = ovsport vlan_to_use = lvm.vlan - if lvm.network_type in constants.DVR_PHYSICAL_NETWORK_TYPES: + if lvm.network_type in ovs_constants.DVR_PHYSICAL_NETWORK_TYPES: vlan_to_use = lvm.segmentation_id # create a rule for this vm port self.int_br.install_dvr_to_src_mac( @@ -618,7 +619,7 @@ class OVSDVRNeutronAgent(object): ovsport.add_subnet(subnet_uuid) self.local_ports[port.vif_id] = ovsport vlan_to_use = lvm.vlan - if lvm.network_type in constants.DVR_PHYSICAL_NETWORK_TYPES: + if lvm.network_type in ovs_constants.DVR_PHYSICAL_NETWORK_TYPES: vlan_to_use = lvm.segmentation_id self.int_br.install_dvr_to_src_mac( network_type=lvm.network_type, @@ -633,8 +634,8 @@ class OVSDVRNeutronAgent(object): return if (local_vlan_map.network_type not in - (constants.TUNNEL_NETWORK_TYPES + - constants.DVR_PHYSICAL_NETWORK_TYPES)): + (ovs_constants.TUNNEL_NETWORK_TYPES + + ovs_constants.DVR_PHYSICAL_NETWORK_TYPES)): LOG.debug("DVR: Port %s is with network_type %s not supported" " for dvr plumbing", port.vif_id, local_vlan_map.network_type) @@ -676,7 +677,7 @@ class OVSDVRNeutronAgent(object): network_type = lvm.network_type physical_network = lvm.physical_network vlan_to_use = lvm.vlan - if network_type in constants.DVR_PHYSICAL_NETWORK_TYPES: + if network_type in ovs_constants.DVR_PHYSICAL_NETWORK_TYPES: vlan_to_use = lvm.segmentation_id # ensure we process for all the subnets laid on this removed port for sub_uuid in subnet_set: @@ -716,16 +717,16 @@ class OVSDVRNeutronAgent(object): gateway_mac=port.vif_mac, dvr_mac=self.dvr_mac_address, rtr_port=port.ofport) - if (ldm.get_csnat_ofport() == constants.OFPORT_INVALID and + if (ldm.get_csnat_ofport() == ovs_constants.OFPORT_INVALID and len(ldm.get_dvr_ofports()) <= 1): # if there is no csnat port for this subnet and if this is # the last dvr port in the subnet, remove this subnet from # local_dvr_map, as no dvr (or) csnat ports available on this # agent anymore self.local_dvr_map.pop(sub_uuid, None) - if network_type in constants.DVR_PHYSICAL_NETWORK_TYPES: + if network_type in ovs_constants.DVR_PHYSICAL_NETWORK_TYPES: br = self.phys_brs[physical_network] - if network_type in constants.TUNNEL_NETWORK_TYPES: + if network_type in ovs_constants.TUNNEL_NETWORK_TYPES: br = self.tun_br if ip_version == 4: if subnet_info['gateway_ip']: @@ -750,9 +751,9 @@ class OVSDVRNeutronAgent(object): target_mac_address=subnet_info['gateway_mac'], orig_mac_address=self.dvr_mac_address) - if lvm.network_type in constants.DVR_PHYSICAL_NETWORK_TYPES: + if lvm.network_type in ovs_constants.DVR_PHYSICAL_NETWORK_TYPES: br = self.phys_brs[physical_network] - if lvm.network_type in constants.TUNNEL_NETWORK_TYPES: + if lvm.network_type in ovs_constants.TUNNEL_NETWORK_TYPES: br = self.tun_br br.delete_dvr_process(vlan_tag=lvm.vlan, vif_mac=port.vif_mac) @@ -772,7 +773,7 @@ class OVSDVRNeutronAgent(object): ldm = self.local_dvr_map[sub_uuid] ldm.remove_compute_ofport(port.vif_id) vlan_to_use = lvm.vlan - if lvm.network_type in constants.DVR_PHYSICAL_NETWORK_TYPES: + if lvm.network_type in ovs_constants.DVR_PHYSICAL_NETWORK_TYPES: vlan_to_use = lvm.segmentation_id # first remove this vm port rule self.int_br.delete_dvr_to_src_mac( @@ -791,9 +792,9 @@ class OVSDVRNeutronAgent(object): if sub_uuid not in self.local_dvr_map: return ldm = self.local_dvr_map[sub_uuid] - ldm.set_csnat_ofport(constants.OFPORT_INVALID) + ldm.set_csnat_ofport(ovs_constants.OFPORT_INVALID) vlan_to_use = lvm.vlan - if lvm.network_type in constants.DVR_PHYSICAL_NETWORK_TYPES: + if lvm.network_type in ovs_constants.DVR_PHYSICAL_NETWORK_TYPES: vlan_to_use = lvm.segmentation_id # then remove csnat port rule self.int_br.delete_dvr_to_src_mac( 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 35aeed6bdc6..2060c8df07d 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -32,6 +32,7 @@ from neutron_lib.callbacks import resources as callback_resources from neutron_lib import constants as n_const from neutron_lib import context from neutron_lib.placement import utils as place_utils +from neutron_lib.plugins.ml2 import ovs_constants as ovs_const from neutron_lib.plugins import utils as plugin_utils from neutron_lib.utils import helpers import os_vif @@ -64,8 +65,6 @@ from neutron.conf.agent import common as agent_config from neutron.conf import service as service_conf from neutron.plugins.ml2.drivers.agent import capabilities from neutron.plugins.ml2.drivers.l2pop.rpc_manager import l2population_rpc -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants from neutron.plugins.ml2.drivers.openvswitch.agent \ import ovs_agent_extension_api as ovs_ext_api from neutron.plugins.ml2.drivers.openvswitch.agent \ @@ -144,7 +143,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, # 1.5 Added binding_activate and binding_deactivate # 1.7 Add support for smartnic ports target = oslo_messaging.Target(version='1.7') - max_device_retries = constants.MAX_DEVICE_RETRIES + max_device_retries = ovs_const.MAX_DEVICE_RETRIES def __init__(self, bridge_classes, ext_manager, conf=None): '''Constructor. @@ -259,7 +258,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, self.minimize_polling = agent_conf.minimize_polling self.ovsdb_monitor_respawn_interval = ( agent_conf.ovsdb_monitor_respawn_interval or - constants.DEFAULT_OVSDBMON_RESPAWN) + ovs_const.DEFAULT_OVSDBMON_RESPAWN) self.local_ip = ovs_conf.local_ip self.tunnel_count = 0 self.vxlan_udp_port = agent_conf.vxlan_udp_port @@ -271,8 +270,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, if agent_conf.dscp else None)) self.tun_br = None - self.patch_int_ofport = constants.OFPORT_INVALID - self.patch_tun_ofport = constants.OFPORT_INVALID + self.patch_int_ofport = ovs_const.OFPORT_INVALID + self.patch_tun_ofport = ovs_const.OFPORT_INVALID if self.enable_tunneling: # The patch_int_ofport and patch_tun_ofport are updated # here inside the call to setup_tunnel_br() @@ -308,7 +307,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, self.phys_brs, self.plugin_rpc) self.ext_manager.initialize( - self.connection, constants.EXTENSION_DRIVER_TYPE, agent_api) + self.connection, ovs_const.EXTENSION_DRIVER_TYPE, agent_api) # In order to keep existed device's local vlan unchanged, # restore local vlan mapping at start @@ -406,7 +405,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, def _report_state(self): # return and skip reporting agent state if OVS is dead - if self.ovs_status == constants.OVS_DEAD: + if self.ovs_status == ovs_const.OVS_DEAD: LOG.error("OVS is down, not reporting state to server") return @@ -466,7 +465,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, continue net_uuid = local_vlan_map.get('net_uuid') if (net_uuid and net_uuid not in self._local_vlan_hints and - local_vlan != constants.DEAD_VLAN_TAG): + local_vlan != ovs_const.DEAD_VLAN_TAG): self.available_local_vlans.remove(local_vlan) self._local_vlan_hints[local_vlan_map['net_uuid']] = local_vlan @@ -534,8 +533,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, break # Define the listening consumers for the agent - consumers = [[constants.TUNNEL, topics.UPDATE], - [constants.TUNNEL, topics.DELETE], + consumers = [[ovs_const.TUNNEL, topics.UPDATE], + [ovs_const.TUNNEL, topics.DELETE], [topics.DVR, topics.UPDATE]] if self.l2_pop: consumers.append([topics.L2POPULATION, topics.UPDATE]) @@ -1006,7 +1005,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, return lvid = lvm.vlan - if network_type in constants.TUNNEL_NETWORK_TYPES: + if network_type in ovs_const.TUNNEL_NETWORK_TYPES: if self.enable_tunneling: # outbound broadcast/multicast ofports = list(self.tun_br_ofports[network_type].values()) @@ -1071,7 +1070,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, "net-id = %(net_uuid)s", {'vlan_id': lvm.vlan, 'net_uuid': net_uuid}) - if lvm.network_type in constants.TUNNEL_NETWORK_TYPES: + if lvm.network_type in ovs_const.TUNNEL_NETWORK_TYPES: if self.enable_tunneling: self.tun_br.reclaim_local_vlan( network_type=lvm.network_type, @@ -1214,7 +1213,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, # When changing the port's tag from DEAD_VLAN_TAG to # something else, also clear port's vlan_mode and trunks, # which were set to make sure all packets are dropped. - if (cur_tag == constants.DEAD_VLAN_TAG and + if (cur_tag == ovs_const.DEAD_VLAN_TAG and port.ofport != ovs_lib.INVALID_OFPORT): txn.add(ovsdb.db_clear( 'Port', port.port_name, 'vlan_mode')) @@ -1230,7 +1229,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, LOG.debug("Setting status for %s to UP", device) devices_up.append(device) if (not tunnels_missing and - lvm.network_type in constants.TUNNEL_NETWORK_TYPES and + lvm.network_type in ovs_const.TUNNEL_NETWORK_TYPES and len(lvm.tun_ofports) == 0): tunnels_missing = True else: @@ -1349,10 +1348,10 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, cur_tag = self.int_br.db_get_val("Port", port.port_name, "tag", log_errors=log_errors) # Port normal vlan tag is set correctly, remove the drop flows - if cur_tag and cur_tag != constants.DEAD_VLAN_TAG: + if cur_tag and cur_tag != ovs_const.DEAD_VLAN_TAG: self.int_br.uninstall_flows( strict=True, - table_id=constants.LOCAL_SWITCHING, + table_id=ovs_const.LOCAL_SWITCHING, priority=2, in_port=port.ofport) @@ -1364,9 +1363,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, # Don't kill a port if it's already dead cur_tag = self.int_br.db_get_val("Port", port.port_name, "tag", log_errors=log_errors) - if cur_tag and cur_tag != constants.DEAD_VLAN_TAG: + if cur_tag and cur_tag != ovs_const.DEAD_VLAN_TAG: self.int_br.set_db_attribute("Port", port.port_name, "tag", - constants.DEAD_VLAN_TAG, + ovs_const.DEAD_VLAN_TAG, log_errors=log_errors) self.int_br.drop_port(in_port=port.ofport) @@ -1558,9 +1557,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, # interconnect physical and integration bridges using veth/patches int_if_name = plugin_utils.get_interface_name( - bridge, prefix=constants.PEER_INTEGRATION_PREFIX) + bridge, prefix=ovs_const.PEER_INTEGRATION_PREFIX) phys_if_name = plugin_utils.get_interface_name( - bridge, prefix=constants.PEER_PHYSICAL_PREFIX) + bridge, prefix=ovs_const.PEER_PHYSICAL_PREFIX) # Interface type of port for physical and integration bridges must # be same, so check only one of them. # Not logging error here, as the interface may not exist yet. @@ -1584,14 +1583,14 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, int_ofport = self.int_br.get_port_ofport(int_if_name) else: int_ofport = self.int_br.add_patch_port( - int_if_name, constants.NONEXISTENT_PEER) + int_if_name, ovs_const.NONEXISTENT_PEER) self.int_br.set_igmp_snooping_flood( int_if_name, self.conf.OVS.igmp_snooping_enable) if br.port_exists(phys_if_name): phys_ofport = br.get_port_ofport(phys_if_name) else: phys_ofport = br.add_patch_port( - phys_if_name, constants.NONEXISTENT_PEER) + phys_if_name, ovs_const.NONEXISTENT_PEER) self.int_ofports[physical_network] = int_ofport self.phys_ofports[physical_network] = phys_ofport @@ -2199,21 +2198,21 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, if self.direct_for_non_openflow_firewall: for physical_network in self.bridge_mappings: self.int_br.install_goto( - table_id=constants.TRANSIENT_TABLE, - dest_table_id=constants.LOCAL_MAC_DIRECT, + table_id=ovs_const.TRANSIENT_TABLE, + dest_table_id=ovs_const.LOCAL_MAC_DIRECT, priority=4, # a bit higher than NORMAL in_port=self.int_ofports[physical_network]) if self.enable_tunneling: self.int_br.install_goto( - table_id=constants.TRANSIENT_TABLE, - dest_table_id=constants.LOCAL_MAC_DIRECT, + table_id=ovs_const.TRANSIENT_TABLE, + dest_table_id=ovs_const.LOCAL_MAC_DIRECT, priority=4, # a bit higher than NORMAL in_port=self.patch_tun_ofport) self.int_br.install_goto( - table_id=constants.LOCAL_MAC_DIRECT, - dest_table_id=constants.TRANSIENT_EGRESS_TABLE) + table_id=ovs_const.LOCAL_MAC_DIRECT, + dest_table_id=ovs_const.TRANSIENT_EGRESS_TABLE) def process_install_ports_egress_flows(self, ports): with self.int_br.deferred(full_ordered=True, @@ -2245,18 +2244,18 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, # Adding the local vlan to register 6 in case of MAC overlapping # in different networks. br_int.add_flow( - table=constants.TRANSIENT_TABLE, + table=ovs_const.TRANSIENT_TABLE, priority=9, in_port=port.ofport, dl_src=port_detail['mac_address'], actions='set_field:{:d}->reg6,' 'resubmit(,{:d})'.format( lvm.vlan, - constants.LOCAL_MAC_DIRECT)) + ovs_const.LOCAL_MAC_DIRECT)) # For packets from patch ports. br_int.add_flow( - table=constants.LOCAL_MAC_DIRECT, + table=ovs_const.LOCAL_MAC_DIRECT, priority=12, dl_vlan=lvm.vlan, dl_dst=port_detail['mac_address'], @@ -2264,7 +2263,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, # For packets from internal ports or VM ports. br_int.add_flow( - table=constants.LOCAL_MAC_DIRECT, + table=ovs_const.LOCAL_MAC_DIRECT, priority=12, reg6=lvm.vlan, dl_dst=port_detail['mac_address'], @@ -2279,11 +2278,11 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, elif lvm.network_type == n_const.TYPE_VLAN: bridge = self.bridge_mappings.get(lvm.physical_network) port_name = plugin_utils.get_interface_name( - bridge, prefix=constants.PEER_INTEGRATION_PREFIX) + bridge, prefix=ovs_const.PEER_INTEGRATION_PREFIX) patch_ofport = self.int_br.get_port_ofport(port_name) if patch_ofport is not None: br_int.add_flow( - table=constants.TRANSIENT_EGRESS_TABLE, + table=ovs_const.TRANSIENT_EGRESS_TABLE, priority=10, dl_src=port_detail['mac_address'], dl_dst="00:00:00:00:00:00/01:00:00:00:00:00", @@ -2298,20 +2297,20 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, return br_int.delete_flows( - table=constants.TRANSIENT_TABLE, + table=ovs_const.TRANSIENT_TABLE, in_port=ofport, dl_src=mac) br_int.delete_flows( - table=constants.LOCAL_MAC_DIRECT, + table=ovs_const.LOCAL_MAC_DIRECT, dl_vlan=vlan, dl_dst=mac) br_int.delete_flows( - table=constants.LOCAL_MAC_DIRECT, + table=ovs_const.LOCAL_MAC_DIRECT, reg6=vlan, dl_dst=mac) br_int.delete_flows( - table=constants.TRANSIENT_EGRESS_TABLE, + table=ovs_const.TRANSIENT_EGRESS_TABLE, dl_src=mac, in_port=ofport) @@ -2422,11 +2421,11 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, status = self.int_br.check_canary_table() except Exception: LOG.exception("Failure while checking for the canary flow") - status = constants.OVS_DEAD - if status == constants.OVS_RESTARTED: + status = ovs_const.OVS_DEAD + if status == ovs_const.OVS_RESTARTED: LOG.warning("OVS is restarted. OVSNeutronAgent will reset " "bridges and recover ports.") - elif status == constants.OVS_DEAD: + elif status == ovs_const.OVS_DEAD: LOG.warning("OVS is dead. OVSNeutronAgent will keep running " "and checking OVS status periodically.") return status @@ -2528,7 +2527,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, failed_devices, failed_ancillary_devices, updated_ports_copy)) - registry.publish(constants.OVSDB_RESOURCE, + registry.publish(ovs_const.OVSDB_RESOURCE, callback_events.AFTER_READ, self, payload=callback_events.EventPayload( @@ -2653,10 +2652,10 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, self.iter_num) self.ovs_status = self.check_ovs_status() bridges_recreated = False - if self.ovs_status == constants.OVS_RESTARTED: + if self.ovs_status == ovs_const.OVS_RESTARTED: self._handle_ovs_restart(polling_manager) tunnel_sync = self.enable_tunneling or tunnel_sync - elif self.ovs_status == constants.OVS_DEAD: + elif self.ovs_status == ovs_const.OVS_DEAD: # Agent doesn't apply any operations when ovs is dead, to # prevent unexpected failure or crash. Sleep and continue # loop in which ovs status will be checked periodically. @@ -2681,7 +2680,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, except Exception: LOG.exception("Error while configuring tunnel endpoints") tunnel_sync = True - ovs_restarted |= (self.ovs_status == constants.OVS_RESTARTED) + ovs_restarted |= (self.ovs_status == ovs_const.OVS_RESTARTED) devices_need_retry = (any(failed_devices.values()) or any(failed_ancillary_devices.values()) or ports_not_ready_yet) @@ -2869,7 +2868,7 @@ def validate_tunnel_config(tunnel_types, local_ip): validate_local_ip(local_ip) for tun in tunnel_types: - if tun not in constants.TUNNEL_NETWORK_TYPES: + if tun not in ovs_const.TUNNEL_NETWORK_TYPES: LOG.error('Invalid tunnel type specified: %s', tun) raise SystemExit(1) diff --git a/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py b/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py index e7dfd9a67d7..1dc9697e4a5 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py +++ b/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py @@ -21,6 +21,7 @@ from neutron_lib.api.definitions import provider_net from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as ovs_const from oslo_config import cfg from oslo_log import log @@ -28,8 +29,6 @@ from neutron._i18n import _ from neutron.agent import securitygroups_rpc from neutron.conf.plugins.ml2.drivers.openvswitch import mech_ovs_conf from neutron.plugins.ml2.drivers import mech_agent -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants as a_const from neutron.services.logapi.drivers.openvswitch import driver as log_driver from neutron.services.qos.drivers.openvswitch import driver as ovs_qos_driver @@ -136,10 +135,10 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): def get_supported_vif_type(self, agent): caps = agent['configurations'].get('ovs_capabilities', {}) if (any(x in caps.get('iface_types', []) for x - in [a_const.OVS_DPDK_VHOST_USER, - a_const.OVS_DPDK_VHOST_USER_CLIENT]) and + in [ovs_const.OVS_DPDK_VHOST_USER, + ovs_const.OVS_DPDK_VHOST_USER_CLIENT]) and agent['configurations'].get('datapath_type') == - a_const.OVS_DATAPATH_NETDEV): + ovs_const.OVS_DATAPATH_NETDEV): return portbindings.VIF_TYPE_VHOST_USER return self.vif_type @@ -153,7 +152,7 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): # NOTE(sean-k-mooney): this function converts the ovs vhost user # driver mode into the qemu vhost user mode. If OVS is the server, # qemu is the client and vice-versa. - if (a_const.OVS_DPDK_VHOST_USER_CLIENT in iface_types): + if (ovs_const.OVS_DPDK_VHOST_USER_CLIENT in iface_types): return portbindings.VHOST_USER_MODE_SERVER return portbindings.VHOST_USER_MODE_CLIENT @@ -176,7 +175,7 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): vif_details[portbindings.VIF_DETAILS_BRIDGE_NAME] = bridge_name registry.publish( - a_const.OVS_BRIDGE_NAME, events.BEFORE_READ, + ovs_const.OVS_BRIDGE_NAME, events.BEFORE_READ, set_bridge_name_inner, payload=events.EventPayload(None, metadata={'port': port})) @@ -198,14 +197,14 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): portbindings.VHOST_USER_OVS_PLUG: True, portbindings.VHOST_USER_SOCKET: sock_path} details[portbindings.OVS_DATAPATH_TYPE] = a_config.get( - 'datapath_type', a_const.OVS_DATAPATH_SYSTEM) + 'datapath_type', ovs_const.OVS_DATAPATH_SYSTEM) return details @staticmethod def agent_vhu_sockpath(agent, port_id): """Return the agent's vhost-user socket path for a given port""" sockdir = agent['configurations'].get('vhostuser_socket_dir', - a_const.VHOST_USER_SOCKET_DIR) + ovs_const.VHOST_USER_SOCKET_DIR) sock_name = (constants.VHOST_USER_DEVICE_PREFIX + port_id)[:14] return os.path.join(sockdir, sock_name) diff --git a/neutron/services/logapi/drivers/openvswitch/ovs_firewall_log.py b/neutron/services/logapi/drivers/openvswitch/ovs_firewall_log.py index e91ee174c40..ff87f252db0 100644 --- a/neutron/services/logapi/drivers/openvswitch/ovs_firewall_log.py +++ b/neutron/services/logapi/drivers/openvswitch/ovs_firewall_log.py @@ -16,6 +16,7 @@ import collections from neutron_lib import constants as lib_const +from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from neutron_lib.services.logapi import constants as log_const from os_ken.base import app_manager from os_ken.lib.packet import packet @@ -27,8 +28,6 @@ from oslo_log import log as logging from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts from neutron.agent.linux.openvswitch_firewall import firewall as ovsfw from neutron.agent.linux.openvswitch_firewall import rules -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \ - as ovs_consts from neutron.services.logapi.agent import log_extension as log_ext from neutron.services.logapi.common import exceptions as log_exc from neutron.services.logapi.drivers.openvswitch import log_oskenapp diff --git a/neutron/services/trunk/drivers/openvswitch/agent/ovsdb_handler.py b/neutron/services/trunk/drivers/openvswitch/agent/ovsdb_handler.py index 3d916caf9b7..4f72cf0a06f 100644 --- a/neutron/services/trunk/drivers/openvswitch/agent/ovsdb_handler.py +++ b/neutron/services/trunk/drivers/openvswitch/agent/ovsdb_handler.py @@ -21,6 +21,7 @@ from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib.callbacks import resources from neutron_lib import context as n_context +from neutron_lib.plugins.ml2 import ovs_constants as ovs_agent_constants from neutron_lib.services.trunk import constants from oslo_concurrency import lockutils from oslo_context import context as o_context @@ -32,8 +33,6 @@ from neutron._i18n import _ from neutron.agent.common import ovs_lib from neutron.api.rpc.handlers import resources_rpc from neutron.common import utils as common_utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants as ovs_agent_constants from neutron.services.trunk.drivers.openvswitch.agent import exceptions from neutron.services.trunk.drivers.openvswitch.agent \ import trunk_manager as tman diff --git a/neutron/services/trunk/drivers/openvswitch/driver.py b/neutron/services/trunk/drivers/openvswitch/driver.py index 53c14035c97..46a33abb117 100644 --- a/neutron/services/trunk/drivers/openvswitch/driver.py +++ b/neutron/services/trunk/drivers/openvswitch/driver.py @@ -15,12 +15,11 @@ from neutron_lib.api.definitions import portbindings from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as agent_consts from neutron_lib.services.trunk import constants as trunk_consts from oslo_config import cfg from oslo_log import log as logging -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as agent_consts) from neutron.services.trunk.drivers import base from neutron.services.trunk.drivers.openvswitch import utils diff --git a/neutron/tests/common/conn_testers.py b/neutron/tests/common/conn_testers.py index 414a5fa7db6..b41d1cdfc5e 100644 --- a/neutron/tests/common/conn_testers.py +++ b/neutron/tests/common/conn_testers.py @@ -17,12 +17,11 @@ import functools import fixtures import netaddr from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from oslo_config import cfg from oslo_utils import uuidutils from neutron.common import utils as common_utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as ovs_consts) from neutron.tests.common import machine_fixtures from neutron.tests.common import net_helpers diff --git a/neutron/tests/fullstack/test_logging.py b/neutron/tests/fullstack/test_logging.py index 07a1a6a9e09..3e9869371a3 100644 --- a/neutron/tests/fullstack/test_logging.py +++ b/neutron/tests/fullstack/test_logging.py @@ -15,11 +15,10 @@ import re from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as ovs_const from oslo_utils import uuidutils from neutron.common import utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as ovs_const) from neutron.tests.common import net_helpers from neutron.tests.fullstack import base from neutron.tests.fullstack.resources import environment diff --git a/neutron/tests/fullstack/test_qos.py b/neutron/tests/fullstack/test_qos.py index 8c04219d6e0..576f2c25945 100644 --- a/neutron/tests/fullstack/test_qos.py +++ b/neutron/tests/fullstack/test_qos.py @@ -15,6 +15,7 @@ import functools from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as ovs_constants from neutron_lib.services.qos import constants as qos_consts from neutronclient.common import exceptions from oslo_utils import uuidutils @@ -33,8 +34,6 @@ from neutron.conf.plugins.ml2.drivers import linuxbridge as \ linuxbridge_agent_config from neutron.plugins.ml2.drivers.linuxbridge.agent import \ linuxbridge_neutron_agent as linuxbridge_agent -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants as ovs_constants from neutron.services.qos.drivers.linuxbridge import driver as lb_drv from neutron.services.qos.drivers.openvswitch import driver as ovs_drv diff --git a/neutron/tests/functional/agent/common/test_ovs_lib.py b/neutron/tests/functional/agent/common/test_ovs_lib.py index 54598f31fc2..d50e75703b0 100644 --- a/neutron/tests/functional/agent/common/test_ovs_lib.py +++ b/neutron/tests/functional/agent/common/test_ovs_lib.py @@ -17,6 +17,7 @@ import functools from unittest import mock from neutron_lib import constants as p_const +from neutron_lib.plugins.ml2 import ovs_constants from neutron_lib.services.qos import constants as qos_constants from oslo_utils import uuidutils from ovsdbapp.backend.ovs_idl import event @@ -24,8 +25,6 @@ from ovsdbapp.backend.ovs_idl import event from neutron.agent.common import ovs_lib from neutron.agent.linux import ip_lib from neutron.common import utils as common_utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants as ovs_constants from neutron.tests.functional import base diff --git a/neutron/tests/functional/agent/l2/base.py b/neutron/tests/functional/agent/l2/base.py index 3a471b45375..a17c9bb167e 100644 --- a/neutron/tests/functional/agent/l2/base.py +++ b/neutron/tests/functional/agent/l2/base.py @@ -20,6 +20,7 @@ from unittest import mock import eventlet import fixtures from neutron_lib import constants as n_const +from neutron_lib.plugins.ml2 import ovs_constants from neutron_lib.utils import net from oslo_config import cfg from oslo_utils import uuidutils @@ -34,7 +35,6 @@ from neutron.conf.agent import ovs_conf as ovs_agent_config from neutron.conf import common as common_config from neutron.conf.plugins.ml2.drivers import agent from neutron.conf.plugins.ml2.drivers import ovs_conf -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent.extension_drivers \ import qos_driver as ovs_qos_driver from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ @@ -228,7 +228,7 @@ class OVSAgentTestFramework(base.BaseOVSLinuxTestCase, OVSOFControllerHelper): utils.wait_until_true( polling_manager._monitor.is_active) agent.check_ovs_status = mock.Mock( - return_value=constants.OVS_NORMAL) + return_value=ovs_constants.OVS_NORMAL) self.agent_thread = eventlet.spawn(agent.rpc_loop, polling_manager) diff --git a/neutron/tests/functional/agent/test_l2_ovs_agent.py b/neutron/tests/functional/agent/test_l2_ovs_agent.py index 391b622c97f..dd938e780e5 100644 --- a/neutron/tests/functional/agent/test_l2_ovs_agent.py +++ b/neutron/tests/functional/agent/test_l2_ovs_agent.py @@ -20,9 +20,9 @@ from unittest import mock from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib.callbacks import resources +from neutron_lib.plugins.ml2 import ovs_constants from neutron.common import utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.tests.common import net_helpers from neutron.tests.functional.agent.l2 import base @@ -70,7 +70,7 @@ class TestOVSAgent(base.OVSAgentTestFramework): lambda: num_ports_with_drop_flows( ofports, self.agent.int_br.dump_flows( - constants.LOCAL_SWITCHING + ovs_constants.LOCAL_SWITCHING )) == len(ofports)) # delete the ports on bridge @@ -83,7 +83,7 @@ class TestOVSAgent(base.OVSAgentTestFramework): num_ports_with_drop_flows( ofports, self.agent.int_br.dump_flows( - constants.LOCAL_SWITCHING + ovs_constants.LOCAL_SWITCHING ) )) @@ -106,15 +106,15 @@ class TestOVSAgent(base.OVSAgentTestFramework): def test_datapath_type_netdev(self): self._check_datapath_type_netdev( - constants.OVS_DATAPATH_NETDEV) + ovs_constants.OVS_DATAPATH_NETDEV) def test_datapath_type_system(self): self._check_datapath_type_netdev( - constants.OVS_DATAPATH_SYSTEM) + ovs_constants.OVS_DATAPATH_SYSTEM) def test_datapath_type_default(self): self._check_datapath_type_netdev( - constants.OVS_DATAPATH_SYSTEM, default=True) + ovs_constants.OVS_DATAPATH_SYSTEM, default=True) def test_resync_devices_set_up_after_exception(self): self.setup_agent_and_ports( @@ -126,7 +126,7 @@ class TestOVSAgent(base.OVSAgentTestFramework): self.setup_agent_and_ports( port_dicts=self.create_test_ports()) self.wait_until_ports_state(self.ports, up=True) - self.agent.check_ovs_status.return_value = constants.OVS_RESTARTED + self.agent.check_ovs_status.return_value = ovs_constants.OVS_RESTARTED # OVS restarted, the agent should reprocess all the ports self.agent.plugin_rpc.update_device_list.reset_mock() self.wait_until_ports_state(self.ports, up=True) @@ -340,7 +340,7 @@ class TestOVSAgent(base.OVSAgentTestFramework): resources.AGENT, events.OVS_RESTARTED) - self.agent.check_ovs_status.return_value = constants.OVS_RESTARTED + self.agent.check_ovs_status.return_value = ovs_constants.OVS_RESTARTED utils.wait_until_true(lambda: callback.call_count, timeout=10) diff --git a/neutron/tests/functional/agent/test_ovs_flows.py b/neutron/tests/functional/agent/test_ovs_flows.py index d779dbbb244..1777dd090f2 100644 --- a/neutron/tests/functional/agent/test_ovs_flows.py +++ b/neutron/tests/functional/agent/test_ovs_flows.py @@ -14,6 +14,7 @@ # under the License. from neutron_lib import constants as n_const +from neutron_lib.plugins.ml2 import ovs_constants from oslo_config import cfg from oslo_serialization import jsonutils from testtools.content import text_content @@ -23,7 +24,6 @@ from neutron.agent.common import utils from neutron.agent.linux import ip_lib from neutron.cmd.sanity import checks from neutron.common import utils as common_utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent \ import ovs_neutron_agent as ovsagt from neutron.tests.common import base as common_base @@ -249,10 +249,10 @@ class ARPSpoofTestCase(OVSAgentTestBase): class CanaryTableTestCase(OVSAgentTestBase): def test_canary_table(self): self.br_int.uninstall_flows(cookie=ovs_lib.COOKIE_ANY) - self.assertEqual(constants.OVS_RESTARTED, + self.assertEqual(ovs_constants.OVS_RESTARTED, self.br_int.check_canary_table()) self.br_int.setup_canary_table() - self.assertEqual(constants.OVS_NORMAL, + self.assertEqual(ovs_constants.OVS_NORMAL, self.br_int.check_canary_table()) diff --git a/neutron/tests/functional/agent/test_ovs_lib.py b/neutron/tests/functional/agent/test_ovs_lib.py index b34b45a657f..5ab48b7b5d5 100644 --- a/neutron/tests/functional/agent/test_ovs_lib.py +++ b/neutron/tests/functional/agent/test_ovs_lib.py @@ -18,14 +18,13 @@ from unittest import mock import uuid from neutron_lib import constants as const +from neutron_lib.plugins.ml2 import ovs_constants as agent_const from oslo_config import cfg from ovsdbapp.backend.ovs_idl import idlutils from neutron.agent.common import ovs_lib from neutron.agent.linux import ip_lib from neutron.common import utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as agent_const) from neutron.tests.common import net_helpers from neutron.tests.functional.agent.linux import base diff --git a/neutron/tests/functional/cmd/test_destroy_patch_ports.py b/neutron/tests/functional/cmd/test_destroy_patch_ports.py index dd62c0e1bc3..3f471bf8385 100644 --- a/neutron/tests/functional/cmd/test_destroy_patch_ports.py +++ b/neutron/tests/functional/cmd/test_destroy_patch_ports.py @@ -14,12 +14,12 @@ # under the License. from neutron_lib import constants as n_const +from neutron_lib.plugins.ml2 import ovs_constants from oslo_config import cfg from neutron.cmd import destroy_patch_ports from neutron.common import utils from neutron.conf.plugins.ml2.drivers import ovs_conf -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.tests.common import net_helpers from neutron.tests.functional import base @@ -53,9 +53,9 @@ class TestDestroyPatchPorts(base.BaseSudoTestCase): int_if_name, phys_if_name = destroy_patch_ports.get_patch_port_names( bridge.br_name) self.int_br.add_patch_port( - int_if_name, constants.NONEXISTENT_PEER) + int_if_name, ovs_constants.NONEXISTENT_PEER) bridge.add_patch_port( - phys_if_name, constants.NONEXISTENT_PEER) + phys_if_name, ovs_constants.NONEXISTENT_PEER) self.int_br.set_db_attribute( 'Interface', int_if_name, 'options', {'peer': phys_if_name}) bridge.set_db_attribute( @@ -86,7 +86,7 @@ class TestDestroyPatchPorts(base.BaseSudoTestCase): cleaner.destroy_patch_ports() def test_destroy_patch_ports_canary_flow_on_int_br(self): - self.int_br.add_flow(table=constants.CANARY_TABLE, actions="drop") + self.int_br.add_flow(table=ovs_constants.CANARY_TABLE, actions="drop") self._assert_has_all_ports() cleaner = destroy_patch_ports.PatchPortCleaner(self.config) cleaner.destroy_patch_ports() diff --git a/neutron/tests/functional/cmd/test_ovs_cleanup.py b/neutron/tests/functional/cmd/test_ovs_cleanup.py index b1cb3c7e201..7fbb66aee99 100644 --- a/neutron/tests/functional/cmd/test_ovs_cleanup.py +++ b/neutron/tests/functional/cmd/test_ovs_cleanup.py @@ -12,10 +12,11 @@ import collections +from neutron_lib.plugins.ml2 import ovs_constants + from neutron.cmd import ovs_cleanup from neutron.common import utils from neutron.conf.agent import cmd -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.tests.common import net_helpers from neutron.tests.functional.agent.linux import base @@ -46,7 +47,7 @@ class TestOVSCLIConfig(base.BaseOVSLinuxTestCase): # set skippable vif to be skipped int_br.ovsdb.db_set( 'Interface', skip[int_br][0], - ('external_ids', {constants.SKIP_CLEANUP: "True"}) + ('external_ids', {ovs_constants.SKIP_CLEANUP: "True"}) ).execute(check_error=True) device_name = utils.get_rand_name() skip[int_br].append(device_name) diff --git a/neutron/tests/functional/services/logapi/test_logging.py b/neutron/tests/functional/services/logapi/test_logging.py index 0a31b973386..57d0e384fcc 100644 --- a/neutron/tests/functional/services/logapi/test_logging.py +++ b/neutron/tests/functional/services/logapi/test_logging.py @@ -18,6 +18,7 @@ from unittest import mock from neutron_lib import constants from neutron_lib import context as neutron_context +from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from oslo_config import cfg from oslo_log import log as logging import testscenarios @@ -25,8 +26,6 @@ import testscenarios from neutron.objects.logapi import logging_resource as log_object from neutron.plugins.ml2.drivers.openvswitch.agent import ( ovs_agent_extension_api as ovs_ext_api) -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as ovs_consts) from neutron.services.logapi.drivers.openvswitch import ( ovs_firewall_log as ovs_fw_log) from neutron.tests.functional.agent import test_firewall diff --git a/neutron/tests/unit/agent/common/test_ovs_lib.py b/neutron/tests/unit/agent/common/test_ovs_lib.py index 302f87add82..b3d37d9c264 100644 --- a/neutron/tests/unit/agent/common/test_ovs_lib.py +++ b/neutron/tests/unit/agent/common/test_ovs_lib.py @@ -16,6 +16,7 @@ import collections from unittest import mock from neutron_lib import exceptions +from neutron_lib.plugins.ml2 import ovs_constants as p_const from oslo_serialization import jsonutils from oslo_utils import uuidutils import tenacity @@ -23,8 +24,6 @@ import testtools from neutron.agent.common import ovs_lib from neutron.agent.common import utils -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants as p_const from neutron.plugins.ml2.drivers.openvswitch.agent.common \ import exceptions as ovs_exc from neutron.tests import base diff --git a/neutron/tests/unit/agent/l2/extensions/test_fdb_population.py b/neutron/tests/unit/agent/l2/extensions/test_fdb_population.py index 177d62141ab..2212e7dd3e5 100644 --- a/neutron/tests/unit/agent/l2/extensions/test_fdb_population.py +++ b/neutron/tests/unit/agent/l2/extensions/test_fdb_population.py @@ -17,6 +17,7 @@ import copy from unittest import mock from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants from neutron_lib.utils import helpers from oslo_config import cfg from pyroute2.netlink import exceptions as netlink_exceptions @@ -26,8 +27,6 @@ from neutron.agent.l2.extensions.fdb_population import ( from neutron.agent.linux import bridge_lib from neutron.plugins.ml2.drivers.linuxbridge.agent.common import ( constants as linux_bridge_constants) -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as ovs_constants) from neutron.tests import base diff --git a/neutron/tests/unit/agent/l2/extensions/test_local_ip.py b/neutron/tests/unit/agent/l2/extensions/test_local_ip.py index 994ba7c7544..ae427981328 100644 --- a/neutron/tests/unit/agent/l2/extensions/test_local_ip.py +++ b/neutron/tests/unit/agent/l2/extensions/test_local_ip.py @@ -19,6 +19,7 @@ import netaddr from neutron_lib.callbacks import events as lib_events from neutron_lib.callbacks import registry as lib_registry from neutron_lib import context +from neutron_lib.plugins.ml2 import ovs_constants from os_ken.lib.packet import ether_types from os_ken.lib.packet import in_proto as ip_proto from oslo_utils import uuidutils @@ -27,8 +28,6 @@ from neutron.agent.l2.extensions import local_ip as local_ip_ext from neutron.api.rpc.callbacks import events from neutron.api.rpc.callbacks import resources from neutron.objects import local_ip as lip_obj -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as ovs_constants) from neutron.plugins.ml2.drivers.openvswitch.agent \ import ovs_agent_extension_api as ovs_ext_api from neutron.tests import base diff --git a/neutron/tests/unit/agent/l2/extensions/test_qos.py b/neutron/tests/unit/agent/l2/extensions/test_qos.py index 03a3d72e623..d5c6d4d5268 100644 --- a/neutron/tests/unit/agent/l2/extensions/test_qos.py +++ b/neutron/tests/unit/agent/l2/extensions/test_qos.py @@ -18,6 +18,7 @@ from unittest import mock from neutron_lib import constants as common_constants from neutron_lib import context from neutron_lib.db import constants as db_consts +from neutron_lib.plugins.ml2 import ovs_constants from neutron_lib.services.qos import constants as qos_consts from oslo_utils import uuidutils @@ -32,7 +33,6 @@ from neutron.objects.qos import policy from neutron.objects.qos import rule from neutron.plugins.ml2.drivers.openvswitch.agent import ( ovs_agent_extension_api as ovs_ext_api) -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native import ( ovs_bridge) from neutron.tests import base @@ -248,7 +248,7 @@ class QosExtensionRpcTestCase(QosExtensionBaseTestCase): def setUp(self): super(QosExtensionRpcTestCase, self).setUp() self.qos_ext.initialize( - self.connection, constants.EXTENSION_DRIVER_TYPE) + self.connection, ovs_constants.EXTENSION_DRIVER_TYPE) self.pull_mock = mock.patch.object( self.qos_ext.resource_rpc, 'pull', @@ -449,7 +449,7 @@ class QosExtensionInitializeTestCase(QosExtensionBaseTestCase): @mock.patch.object(resources_rpc, 'ResourcesPushRpcCallback') def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock): self.qos_ext.initialize( - self.connection, constants.EXTENSION_DRIVER_TYPE) + self.connection, ovs_constants.EXTENSION_DRIVER_TYPE) self.connection.create_consumer.assert_has_calls( [mock.call( resources_rpc.resource_type_versioned_topic(resource_type), @@ -465,7 +465,7 @@ class QosExtensionReflushRulesTestCase(QosExtensionBaseTestCase): def setUp(self): super(QosExtensionReflushRulesTestCase, self).setUp() self.qos_ext.initialize( - self.connection, constants.EXTENSION_DRIVER_TYPE) + self.connection, ovs_constants.EXTENSION_DRIVER_TYPE) self.pull_mock = mock.patch.object( self.qos_ext.resource_rpc, 'pull', diff --git a/neutron/tests/unit/agent/linux/openvswitch_firewall/test_firewall.py b/neutron/tests/unit/agent/linux/openvswitch_firewall/test_firewall.py index f47fe774854..abc3942e49f 100644 --- a/neutron/tests/unit/agent/linux/openvswitch_firewall/test_firewall.py +++ b/neutron/tests/unit/agent/linux/openvswitch_firewall/test_firewall.py @@ -18,6 +18,7 @@ from neutron_lib.callbacks import events as callbacks_events from neutron_lib.callbacks import registry as callbacks_registry from neutron_lib.callbacks import resources as callbacks_resources from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from neutron_lib.utils import helpers from os_ken.ofproto import ofproto_v1_3_parser from oslo_config import cfg @@ -30,8 +31,6 @@ from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts from neutron.agent.linux.openvswitch_firewall import exceptions from neutron.agent.linux.openvswitch_firewall import firewall as ovsfw from neutron.conf.agent import securitygroups_rpc -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \ - as ovs_consts from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ import ovs_bridge from neutron.tests import base diff --git a/neutron/tests/unit/agent/linux/openvswitch_firewall/test_rules.py b/neutron/tests/unit/agent/linux/openvswitch_firewall/test_rules.py index d838f82fb72..88b64544a4d 100644 --- a/neutron/tests/unit/agent/linux/openvswitch_firewall/test_rules.py +++ b/neutron/tests/unit/agent/linux/openvswitch_firewall/test_rules.py @@ -15,12 +15,11 @@ from unittest import mock from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts from neutron.agent.linux.openvswitch_firewall import firewall as ovsfw from neutron.agent.linux.openvswitch_firewall import rules -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \ - as ovs_consts from neutron.tests import base TESTING_VLAN_TAG = 1 diff --git a/neutron/tests/unit/agent/linux/test_interface.py b/neutron/tests/unit/agent/linux/test_interface.py index 00bf1ec8106..e8c929729f7 100644 --- a/neutron/tests/unit/agent/linux/test_interface.py +++ b/neutron/tests/unit/agent/linux/test_interface.py @@ -16,6 +16,7 @@ from unittest import mock from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as ovs_const from oslo_utils import excutils from pyroute2.netlink import exceptions as pyroute2_exc @@ -25,8 +26,6 @@ from neutron.agent.linux import ip_lib from neutron.common import utils from neutron.conf.agent import common as config from neutron.conf.plugins.ml2.drivers import ovs_conf -from neutron.plugins.ml2.drivers.openvswitch.agent.common \ - import constants as ovs_const from neutron.privileged.agent.linux import ethtool from neutron.tests import base diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_bridge_test_base.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_bridge_test_base.py index e9f25666e8a..0bb6383d699 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_bridge_test_base.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_bridge_test_base.py @@ -16,9 +16,9 @@ from unittest import mock +from neutron_lib.plugins.ml2 import ovs_constants from oslo_utils import importutils -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent \ import ovs_test_base @@ -165,7 +165,7 @@ class OVSBridgeTestBase(ovs_test_base.OVSOSKenTestBase): set_controller.assert_called_once_with(["tcp:127.0.0.1:6633"]) set_ccm.assert_called_once_with("out-of-band") add_protocols.assert_called_once_with( - constants.OPENFLOW10, constants.OPENFLOW13) + ovs_constants.OPENFLOW10, ovs_constants.OPENFLOW13) def test_setup_controllers(self): self._test_setup_controllers(existing_controllers=[]) @@ -240,7 +240,7 @@ class OVSDVRProcessTestMixin(object): arp_tpa=gateway_ip, vlan_vid=vlan_tag | ofp.OFPVID_PRESENT), priority=3, - table_id=constants.FLOOD_TO_TUN), + table_id=ovs_constants.FLOOD_TO_TUN), active_bundle=None), ] self.assertEqual(expected, self.mock.mock_calls) @@ -252,7 +252,7 @@ class OVSDVRProcessTestMixin(object): gateway_ip=gateway_ip) (dp, ofp, ofpp) = self._get_dp() expected = [ - call.uninstall_flows(table_id=constants.FLOOD_TO_TUN, + call.uninstall_flows(table_id=ovs_constants.FLOOD_TO_TUN, match=ofpp.OFPMatch( eth_type=self.ether_types.ETH_TYPE_ARP, arp_tpa=gateway_ip, @@ -277,7 +277,7 @@ class OVSDVRProcessTestMixin(object): ip_proto=self.in_proto.IPPROTO_ICMPV6, vlan_vid=vlan_tag | ofp.OFPVID_PRESENT), priority=3, - table_id=constants.FLOOD_TO_TUN), + table_id=ovs_constants.FLOOD_TO_TUN), active_bundle=None), ] self.assertEqual(expected, self.mock.mock_calls) @@ -289,7 +289,7 @@ class OVSDVRProcessTestMixin(object): gateway_mac=gateway_mac) (dp, ofp, ofpp) = self._get_dp() expected = [ - call.uninstall_flows(table_id=constants.FLOOD_TO_TUN, + call.uninstall_flows(table_id=ovs_constants.FLOOD_TO_TUN, match=ofpp.OFPMatch( eth_src=gateway_mac, eth_type=self.ether_types.ETH_TYPE_IPV6, diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_int.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_int.py index a7cc53afad3..477967e0b8f 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_int.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_int.py @@ -17,8 +17,8 @@ from unittest import mock from neutron_lib import constants as p_const +from neutron_lib.plugins.ml2 import ovs_constants -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.native \ import ovs_bridge_test_base @@ -134,7 +134,7 @@ class OVSIntegrationBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase): ], match=ofpp.OFPMatch(), priority=3, - table_id=constants.TRANSIENT_EGRESS_TABLE), + table_id=ovs_constants.TRANSIENT_EGRESS_TABLE), active_bundle=None), call._send_msg(ofpp.OFPFlowMod( dp, cookie=self.stamp, @@ -621,9 +621,9 @@ class OVSIntegrationBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase): def _test_delete_dvr_dst_mac_for_arp(self, network_type): if network_type in (p_const.TYPE_VLAN, p_const.TYPE_FLAT): - table_id = constants.DVR_TO_SRC_MAC_PHYSICAL + table_id = ovs_constants.DVR_TO_SRC_MAC_PHYSICAL else: - table_id = constants.DVR_TO_SRC_MAC + table_id = ovs_constants.DVR_TO_SRC_MAC if network_type == p_const.TYPE_FLAT: vlan_tag = None @@ -733,7 +733,8 @@ class OVSIntegrationBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase): instructions = [ ofpp.OFPInstructionMeter(meter_id, type_=ofp.OFPIT_METER), - ofpp.OFPInstructionGotoTable(table_id=constants.TRANSIENT_TABLE)] + ofpp.OFPInstructionGotoTable( + table_id=ovs_constants.TRANSIENT_TABLE)] expected = [ call._send_msg(ofpp.OFPFlowMod(dp, @@ -741,7 +742,7 @@ class OVSIntegrationBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase): instructions=instructions, match=match, priority=100, - table_id=constants.PACKET_RATE_LIMIT), + table_id=ovs_constants.PACKET_RATE_LIMIT), active_bundle=None) ] self.assertEqual(expected, self.mock.mock_calls) @@ -770,7 +771,7 @@ class OVSIntegrationBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase): expected = [ call.uninstall_flows( - table_id=constants.PACKET_RATE_LIMIT, + table_id=ovs_constants.PACKET_RATE_LIMIT, match=match) ] self.assertEqual(expected, self.mock.mock_calls) @@ -842,7 +843,7 @@ class OVSIntegrationBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase): self.assertEqual(expected, self.mock.mock_calls) def test_setup_local_egress_flows_ofport_invalid(self): - in_port = constants.OFPORT_INVALID + in_port = ovs_constants.OFPORT_INVALID vlan = 3333 self.br.setup_local_egress_flows(in_port=in_port, vlan=vlan) diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_phys.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_phys.py index 0f41d65cf41..09235939470 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_phys.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_phys.py @@ -16,8 +16,8 @@ from unittest import mock -import neutron.plugins.ml2.drivers.openvswitch.agent.common.constants \ - as ovs_const +from neutron_lib.plugins.ml2 import ovs_constants as ovs_const + from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.native \ import ovs_bridge_test_base diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_tun.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_tun.py index eecba6214b8..0b3ab1c894c 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_tun.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_tun.py @@ -16,8 +16,8 @@ from unittest import mock -import neutron.plugins.ml2.drivers.openvswitch.agent.common.constants \ - as ovs_const +from neutron_lib.plugins.ml2 import ovs_constants as ovs_const + from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.native \ import ovs_bridge_test_base diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index e1617971b71..b24134509cc 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -23,6 +23,7 @@ from neutron_lib.agent import constants as agent_consts from neutron_lib.api.definitions import portbindings from neutron_lib.api.definitions import provider_net from neutron_lib import constants as n_const +from neutron_lib.plugins.ml2 import ovs_constants from neutron_lib import rpc as n_rpc import os_vif from os_vif.objects import instance_info as vif_instance_object @@ -42,7 +43,6 @@ from neutron.api.rpc.callbacks import resources from neutron.objects.ports import Port from neutron.objects.ports import PortBinding from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent import ovs_neutron_agent \ as ovs_agent from neutron.tests import base @@ -214,7 +214,7 @@ class TestOvsNeutronAgent(object): def test_datapath_type_system(self): # verify kernel datapath is default - expected = constants.OVS_DATAPATH_SYSTEM + expected = ovs_constants.OVS_DATAPATH_SYSTEM self.assertEqual(expected, self.agent.int_br.datapath_type) def test_datapath_type_netdev(self): @@ -239,7 +239,7 @@ class TestOvsNeutronAgent(object): mock.patch('neutron.agent.rpc.PluginReportStateAPI.' 'has_alive_neutron_server'): # validate setting non default datapath - expected = constants.OVS_DATAPATH_NETDEV + expected = ovs_constants.OVS_DATAPATH_NETDEV cfg.CONF.set_override('datapath_type', expected, group='OVS') @@ -364,13 +364,13 @@ class TestOvsNeutronAgent(object): with mock.patch.object(self.agent, 'int_br') as int_br: int_br.db_get_val.return_value = cur_tag self.agent.port_dead(port) - if cur_tag is None or cur_tag == constants.DEAD_VLAN_TAG: + if cur_tag is None or cur_tag == ovs_constants.DEAD_VLAN_TAG: self.assertFalse(int_br.set_db_attribute.called) self.assertFalse(int_br.drop_port.called) else: int_br.assert_has_calls([ mock.call.set_db_attribute("Port", mock.ANY, "tag", - constants.DEAD_VLAN_TAG, + ovs_constants.DEAD_VLAN_TAG, log_errors=True), mock.call.drop_port(in_port=port.ofport), ]) @@ -379,7 +379,7 @@ class TestOvsNeutronAgent(object): self._test_port_dead() def test_port_dead_with_port_already_dead(self): - self._test_port_dead(constants.DEAD_VLAN_TAG) + self._test_port_dead(ovs_constants.DEAD_VLAN_TAG) def test_port_dead_with_valid_tag(self): self._test_port_dead(cur_tag=1) @@ -667,9 +667,9 @@ class TestOvsNeutronAgent(object): def test_update_retries_map_and_remove_devs_not_to_retry(self): failed_devices_retries_map = { - 'device_not_to_retry': constants.MAX_DEVICE_RETRIES, + 'device_not_to_retry': ovs_constants.MAX_DEVICE_RETRIES, 'device_to_retry': 2, - 'ancillary_not_to_retry': constants.MAX_DEVICE_RETRIES, + 'ancillary_not_to_retry': ovs_constants.MAX_DEVICE_RETRIES, 'ancillary_to_retry': 1} failed_devices = { 'added': set(['device_not_to_retry']), @@ -1242,7 +1242,7 @@ class TestOvsNeutronAgent(object): def test_not_report_state_when_ovs_dead(self): with mock.patch.object(self.agent.state_rpc, "report_state") as report_st: - self.agent.ovs_status = constants.OVS_DEAD + self.agent.ovs_status = ovs_constants.OVS_DEAD self.agent._report_state() report_st.assert_not_called() self.systemd_notify.assert_not_called() @@ -1456,7 +1456,7 @@ class TestOvsNeutronAgent(object): # the main things we care about are that it gets put in the # dead vlan and gets blocked int_br.set_db_attribute.assert_any_call( - 'Port', vif.port_name, 'tag', constants.DEAD_VLAN_TAG, + 'Port', vif.port_name, 'tag', ovs_constants.DEAD_VLAN_TAG, log_errors=False) int_br.drop_port.assert_called_once_with(in_port=vif.ofport) @@ -1581,7 +1581,7 @@ class TestOvsNeutronAgent(object): else: expected_calls += [ mock.call.int_br.add_patch_port( - 'int-br-eth', constants.NONEXISTENT_PEER), + 'int-br-eth', ovs_constants.NONEXISTENT_PEER), ] expected_calls += [ mock.call.int_br.set_igmp_snooping_flood( @@ -1595,7 +1595,7 @@ class TestOvsNeutronAgent(object): else: expected_calls += [ mock.call.phys_br.add_patch_port( - 'phy-br-eth', constants.NONEXISTENT_PEER), + 'phy-br-eth', ovs_constants.NONEXISTENT_PEER), ] expected_calls += [ mock.call.int_br.drop_port(in_port='int_ofport') @@ -1675,7 +1675,7 @@ class TestOvsNeutronAgent(object): else: expected_calls += [ mock.call.int_br.add_patch_port( - 'int-br-eth', constants.NONEXISTENT_PEER), + 'int-br-eth', ovs_constants.NONEXISTENT_PEER), ] expected_calls += [ mock.call.int_br.set_igmp_snooping_flood( @@ -1689,7 +1689,7 @@ class TestOvsNeutronAgent(object): else: expected_calls += [ mock.call.phys_br.add_patch_port( - 'phy-br-eth', constants.NONEXISTENT_PEER), + 'phy-br-eth', ovs_constants.NONEXISTENT_PEER), ] expected_calls += [ mock.call.int_br.drop_port(in_port='int_ofport'), @@ -1984,7 +1984,7 @@ class TestOvsNeutronAgent(object): expected_added_bridges = ( bridges_added if setup_bridges_side_effect else []) with mock.patch.object(self.agent, 'check_ovs_status', - return_value=constants.OVS_NORMAL), \ + return_value=ovs_constants.OVS_NORMAL), \ mock.patch.object(self.agent, '_agent_has_updates', side_effect=TypeError('loop exit')), \ mock.patch.dict(self.agent.bridge_mappings, bridge_mappings, @@ -2024,7 +2024,7 @@ class TestOvsNeutronAgent(object): mock_idl_monitor: self.agent.daemon_loop() mock_get_pm.assert_called_with( - True, constants.DEFAULT_OVSDBMON_RESPAWN, bridge_names=[], + True, ovs_constants.DEFAULT_OVSDBMON_RESPAWN, bridge_names=[], ovs=self.agent.ovs) mock_loop.assert_called_once_with(polling_manager=mock.ANY) mock_idl_monitor.start_bridge_monitor.assert_called() @@ -2326,17 +2326,17 @@ class TestOvsNeutronAgent(object): self.agent.context, self.agent.agent_state, True) def test_ovs_status(self): - self._test_ovs_status(constants.OVS_NORMAL, - constants.OVS_DEAD, - constants.OVS_RESTARTED) + self._test_ovs_status(ovs_constants.OVS_NORMAL, + ovs_constants.OVS_DEAD, + ovs_constants.OVS_RESTARTED) # OVS will not DEAD in some exception, like DBConnectionError. - self._test_ovs_status(constants.OVS_NORMAL, - constants.OVS_RESTARTED) + self._test_ovs_status(ovs_constants.OVS_NORMAL, + ovs_constants.OVS_RESTARTED) def test_ovs_restart_for_ingress_direct_goto_flows(self): with mock.patch.object(self.agent, 'check_ovs_status', - return_value=constants.OVS_RESTARTED), \ + return_value=ovs_constants.OVS_RESTARTED), \ mock.patch.object(self.agent, '_agent_has_updates', side_effect=TypeError('loop exit')), \ @@ -2372,7 +2372,7 @@ class TestOvsNeutronAgent(object): '_check_and_handle_signal') as check_and_handle_signal, \ mock.patch.object(self.agent.ovs.ovsdb, 'idl_monitor'): process_network_ports.side_effect = Exception("Trigger resync") - check_ovs_status.return_value = constants.OVS_NORMAL + check_ovs_status.return_value = ovs_constants.OVS_NORMAL check_and_handle_signal.side_effect = [True, False] self.agent.daemon_loop() self.assertTrue(update_stale.called) @@ -2875,7 +2875,7 @@ class TestOvsNeutronAgentOSKen(TestOvsNeutronAgent, self.agent.cleanup_stale_flows() dump_flows_expected = [ - mock.call(tid) for tid in constants.INT_BR_ALL_TABLES] + mock.call(tid) for tid in ovs_constants.INT_BR_ALL_TABLES] dump_flows.assert_has_calls(dump_flows_expected) expected = [mock.call(cookie=17185, @@ -2883,8 +2883,9 @@ class TestOvsNeutronAgentOSKen(TestOvsNeutronAgent, mock.call(cookie=9029, cookie_mask=uint64_max)] uninstall_flows.assert_has_calls(expected, any_order=True) - self.assertEqual(len(constants.INT_BR_ALL_TABLES) * len(expected), - len(uninstall_flows.mock_calls)) + self.assertEqual( + len(ovs_constants.INT_BR_ALL_TABLES) * len(expected), + len(uninstall_flows.mock_calls)) class AncillaryBridgesTest(object): @@ -4014,12 +4015,12 @@ class TestOvsDvrNeutronAgent(object): expected_on_int_br = [ # setup_dvr_flows_on_integ_br mock.call.setup_canary_table(), - mock.call.install_drop(table_id=constants.DVR_TO_SRC_MAC, + mock.call.install_drop(table_id=ovs_constants.DVR_TO_SRC_MAC, priority=1), mock.call.install_drop( - table_id=constants.DVR_TO_SRC_MAC_PHYSICAL, + table_id=ovs_constants.DVR_TO_SRC_MAC_PHYSICAL, priority=1), - mock.call.install_drop(table_id=constants.LOCAL_SWITCHING, + mock.call.install_drop(table_id=ovs_constants.LOCAL_SWITCHING, priority=2, in_port=ioport), ] @@ -4171,7 +4172,7 @@ class TestOvsDvrNeutronAgent(object): tun_br = mock.create_autospec(self.agent.tun_br) with mock.patch.object(self.agent, 'check_ovs_status', - return_value=constants.OVS_RESTARTED),\ + return_value=ovs_constants.OVS_RESTARTED),\ mock.patch.object(self.agent, '_agent_has_updates', side_effect=TypeError('loop exit')),\ @@ -4198,7 +4199,7 @@ class TestOvsDvrNeutronAgent(object): def _test_scan_ports_failure(self, scan_method_name): with mock.patch.object(self.agent, 'check_ovs_status', - return_value=constants.OVS_RESTARTED),\ + return_value=ovs_constants.OVS_RESTARTED),\ mock.patch.object(self.agent, scan_method_name, side_effect=TypeError('broken')),\ mock.patch.object(self.agent, '_agent_has_updates', @@ -4237,7 +4238,7 @@ class TestOvsDvrNeutronAgent(object): 'physnet1': ex_br_mocks[1]} bridges_added = ['br-ex0'] with mock.patch.object(self.agent, 'check_ovs_status', - return_value=constants.OVS_NORMAL), \ + return_value=ovs_constants.OVS_NORMAL), \ mock.patch.object(self.agent, '_agent_has_updates', side_effect=TypeError('loop exit')), \ mock.patch.dict(self.agent.bridge_mappings, bridge_mappings, diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py index 0bce429767b..c8f2d13b183 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py @@ -19,12 +19,12 @@ import time from unittest import mock from neutron_lib import constants as n_const +from neutron_lib.plugins.ml2 import ovs_constants from oslo_config import cfg from oslo_log import log from neutron.agent.common import ip_lib from neutron.agent.common import ovs_lib -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent \ import ovs_test_base from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent \ @@ -219,14 +219,14 @@ class TunnelTest(object): mock.call.setup_default_table(), mock.call.port_exists('phy-%s' % self.MAP_TUN_BRIDGE), mock.call.add_patch_port('phy-%s' % self.MAP_TUN_BRIDGE, - constants.NONEXISTENT_PEER), + ovs_constants.NONEXISTENT_PEER), ] self.mock_int_bridge_expected += [ mock.call.db_get_val('Interface', 'int-%s' % self.MAP_TUN_BRIDGE, 'type', log_errors=False), mock.call.port_exists('int-%s' % self.MAP_TUN_BRIDGE), mock.call.add_patch_port('int-%s' % self.MAP_TUN_BRIDGE, - constants.NONEXISTENT_PEER), + ovs_constants.NONEXISTENT_PEER), mock.call.set_igmp_snooping_flood('int-%s' % self.MAP_TUN_BRIDGE, igmp_snooping), ] @@ -282,16 +282,16 @@ class TunnelTest(object): self.mock_int_bridge_expected += [ mock.call.install_goto( - dest_table_id=constants.LOCAL_MAC_DIRECT, + dest_table_id=ovs_constants.LOCAL_MAC_DIRECT, in_port=self.MAP_TUN_INT_OFPORT, - priority=4, table_id=constants.TRANSIENT_TABLE), + priority=4, table_id=ovs_constants.TRANSIENT_TABLE), mock.call.install_goto( - dest_table_id=constants.LOCAL_MAC_DIRECT, + dest_table_id=ovs_constants.LOCAL_MAC_DIRECT, in_port=self.TUN_OFPORT, - priority=4, table_id=constants.TRANSIENT_TABLE), + priority=4, table_id=ovs_constants.TRANSIENT_TABLE), mock.call.install_goto( - dest_table_id=constants.TRANSIENT_EGRESS_TABLE, - table_id=constants.LOCAL_MAC_DIRECT), + dest_table_id=ovs_constants.TRANSIENT_EGRESS_TABLE, + table_id=ovs_constants.LOCAL_MAC_DIRECT), ] def _build_agent(self, **config_opts_agent): @@ -537,7 +537,7 @@ class TunnelTest(object): log_errors=True), mock.call.set_db_attribute( 'Port', VIF_PORT.port_name, - 'tag', constants.DEAD_VLAN_TAG, + 'tag', ovs_constants.DEAD_VLAN_TAG, log_errors=True), mock.call.drop_port(in_port=VIF_PORT.ofport), ] @@ -613,7 +613,7 @@ class TunnelTest(object): # No cleanup is expected on ancillary bridge self.ovs_bridges[self.INT_BRIDGE].check_canary_table.return_value = \ - constants.OVS_NORMAL + ovs_constants.OVS_NORMAL with mock.patch.object(log.KeywordArgumentAdapter, 'exception') as log_exception,\ mock.patch.object(self.mod_agent.OVSNeutronAgent, diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py index 7da1c385521..cbd8c82c481 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py @@ -20,11 +20,10 @@ from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib import constants from neutron_lib.plugins.ml2 import api +from neutron_lib.plugins.ml2 import ovs_constants as a_const from oslo_config import cfg from neutron.conf.plugins.ml2.drivers.openvswitch import mech_ovs_conf -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as a_const) from neutron.plugins.ml2.drivers.openvswitch.mech_driver import ( mech_openvswitch) from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base diff --git a/neutron/tests/unit/services/logapi/agent/test_log_extension.py b/neutron/tests/unit/services/logapi/agent/test_log_extension.py index 0f09b61cf30..e7dbf18ef14 100644 --- a/neutron/tests/unit/services/logapi/agent/test_log_extension.py +++ b/neutron/tests/unit/services/logapi/agent/test_log_extension.py @@ -16,6 +16,7 @@ from unittest import mock from neutron_lib import context +from neutron_lib.plugins.ml2 import ovs_constants from oslo_utils import uuidutils from neutron.api.rpc.callbacks.consumer import registry @@ -24,7 +25,6 @@ from neutron.api.rpc.callbacks import resources from neutron.api.rpc.handlers import resources_rpc from neutron.plugins.ml2.drivers.openvswitch.agent import ( ovs_agent_extension_api as ovs_ext_api) -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native import ( ovs_bridge) from neutron.services.logapi.agent import log_extension as log_ext @@ -71,7 +71,7 @@ class LoggingExtensionTestCase(LoggingExtensionBaseTestCase): def setUp(self): super(LoggingExtensionTestCase, self).setUp() self.agent_ext.initialize( - self.connection, constants.EXTENSION_DRIVER_TYPE) + self.connection, ovs_constants.EXTENSION_DRIVER_TYPE) self.log_driver = mock.Mock() log_driver_object = FakeLogDriver() self.log_driver.defer_apply.side_effect = log_driver_object.defer_apply @@ -124,7 +124,7 @@ class LoggingExtensionInitializeTestCase(LoggingExtensionBaseTestCase): @mock.patch.object(resources_rpc, 'ResourcesPushRpcCallback') def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock): self.agent_ext.initialize( - self.connection, constants.EXTENSION_DRIVER_TYPE) + self.connection, ovs_constants.EXTENSION_DRIVER_TYPE) self.connection.create_consumer.assert_has_calls( [mock.call( resources_rpc.resource_type_versioned_topic(resource_type), diff --git a/neutron/tests/unit/services/logapi/drivers/openvswitch/test_ovs_firewall_log.py b/neutron/tests/unit/services/logapi/drivers/openvswitch/test_ovs_firewall_log.py index 13cf4425dfc..bc47954952a 100644 --- a/neutron/tests/unit/services/logapi/drivers/openvswitch/test_ovs_firewall_log.py +++ b/neutron/tests/unit/services/logapi/drivers/openvswitch/test_ovs_firewall_log.py @@ -16,12 +16,11 @@ from unittest import mock from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from oslo_config import cfg from oslo_utils import uuidutils from neutron.objects.logapi import logging_resource as log_object -from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \ - as ovs_consts from neutron.services.logapi.common import exceptions as log_exc from neutron.services.logapi.drivers.openvswitch \ import ovs_firewall_log as ovsfw_log diff --git a/neutron/tests/unit/services/trunk/drivers/openvswitch/test_driver.py b/neutron/tests/unit/services/trunk/drivers/openvswitch/test_driver.py index 3d2ae121eff..6819266cba9 100644 --- a/neutron/tests/unit/services/trunk/drivers/openvswitch/test_driver.py +++ b/neutron/tests/unit/services/trunk/drivers/openvswitch/test_driver.py @@ -16,10 +16,9 @@ from unittest import mock from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib import constants +from neutron_lib.plugins.ml2 import ovs_constants as agent_consts from oslo_config import cfg -from neutron.plugins.ml2.drivers.openvswitch.agent.common import ( - constants as agent_consts) from neutron.services.trunk.drivers.openvswitch import driver from neutron.tests import base