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
changes/20/797120/19
Slawek Kaplonski 1 year ago committed by yatinkarel
parent 0e40dfe862
commit a22d6d6a95

@ -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)

@ -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__()

@ -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()

@ -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__)

@ -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__)

@ -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+),")

@ -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,

@ -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')):

@ -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():

@ -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__)

@ -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,

@ -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):

@ -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 \

@ -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 \

@ -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 \

@ -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 \

@ -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(

@ -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)

@ -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)

@ -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

@ -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

@ -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

@ -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