from neutron.openstack.common import excutils
from neutron.openstack.common import jsonutils
from neutron.openstack.common import log as logging
-from neutron.plugins.common import constants as p_const
-# TODO(JLH) Should we remove the explicit include of the ovs plugin here
-from neutron.plugins.openvswitch.common import constants
+from neutron.plugins.common import constants
# Default timeout for ovs-vsctl command
DEFAULT_OVS_VSCTL_TIMEOUT = 10
+
+# Special return value for an invalid OVS ofport
+INVALID_OFPORT = '-1'
+
OPTS = [
cfg.IntOpt('ovs_vsctl_timeout',
default=DEFAULT_OVS_VSCTL_TIMEOUT,
int(ofport)
return ofport
except (ValueError, TypeError):
- return constants.INVALID_OFPORT
+ return INVALID_OFPORT
def get_datapath_id(self):
return self.db_get_val('Bridge',
return DeferredOVSBridge(self, **kwargs)
def add_tunnel_port(self, port_name, remote_ip, local_ip,
- tunnel_type=p_const.TYPE_GRE,
+ tunnel_type=constants.TYPE_GRE,
vxlan_udp_port=constants.VXLAN_UDP_PORT,
dont_fragment=True):
vsctl_command = ["--", "--may-exist", "add-port", self.br_name,
port_name]
vsctl_command.extend(["--", "set", "Interface", port_name,
"type=%s" % tunnel_type])
- if tunnel_type == p_const.TYPE_VXLAN:
+ if tunnel_type == constants.TYPE_VXLAN:
# Only set the VXLAN UDP port if it's not the default
if vxlan_udp_port != constants.VXLAN_UDP_PORT:
vsctl_command.append("options:dst_port=%s" % vxlan_udp_port)
"options:out_key=flow"])
self.run_vsctl(vsctl_command)
ofport = self.get_port_ofport(port_name)
- if (tunnel_type == p_const.TYPE_VXLAN and
- ofport == constants.INVALID_OFPORT):
+ if (tunnel_type == constants.TYPE_VXLAN and
+ ofport == INVALID_OFPORT):
LOG.error(_('Unable to create VXLAN tunnel port. Please ensure '
'that an openvswitch version that supports VXLAN is '
'installed.'))
name = "vxlantest-" + utils.get_random_string(6)
with ovs_lib.OVSBridge(name, root_helper) as br:
port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
- return port != ovs_const.INVALID_OFPORT
+ return port != ovs_lib.INVALID_OFPORT
def patch_supported(root_helper):
patch_name = "peertest1-" + seed
with ovs_lib.OVSBridge(name, root_helper) as br:
port = br.add_patch_port(patch_name, peer_name)
- return port != ovs_const.INVALID_OFPORT
+ return port != ovs_lib.INVALID_OFPORT
def nova_notify_supported():
TYPE_VXLAN = 'vxlan'
TYPE_VLAN = 'vlan'
TYPE_NONE = 'none'
+
+# Values for network_type
+VXLAN_UDP_PORT = 4789
from oslo.config import cfg
from neutron.agent.common import config
+from neutron.plugins.common import constants as p_const
from neutron.plugins.openvswitch.common import constants
cfg.ListOpt('tunnel_types', default=DEFAULT_TUNNEL_TYPES,
help=_("Network types supported by the agent "
"(gre and/or vxlan)")),
- cfg.IntOpt('vxlan_udp_port', default=constants.VXLAN_UDP_PORT,
+ cfg.IntOpt('vxlan_udp_port', default=p_const.VXLAN_UDP_PORT,
help=_("The UDP port to use for VXLAN tunnels.")),
cfg.IntOpt('veth_mtu',
help=_("MTU size of veth interfaces")),
# Topic for tunnel notifications between the plugin and agent
TUNNEL = 'tunnel'
-# Values for network_type
-VXLAN_UDP_PORT = 4789
-
# Name prefixes for veth device or patch port pair linking the integration
# bridge with the physical bridge for a physical network
PEER_INTEGRATION_PREFIX = 'int-'
# The default respawn interval for the ovsdb monitor
DEFAULT_OVSDBMON_RESPAWN = 30
-# Special return value for an invalid OVS ofport
-INVALID_OFPORT = '-1'
-
# Represent invalid OF Port
OFPORT_INVALID = -1
from neutron.common import exceptions
from neutron.openstack.common import jsonutils
from neutron.openstack.common import uuidutils
-from neutron.plugins.common import constants as p_const
-from neutron.plugins.openvswitch.common import constants as const
+from neutron.plugins.common import constants
from neutron.tests import base
from neutron.tests import tools
self._test_get_port_ofport("6", "6")
def test_get_port_ofport_returns_invalid_ofport_for_non_int(self):
- self._test_get_port_ofport("[]", const.INVALID_OFPORT)
+ self._test_get_port_ofport("[]", ovs_lib.INVALID_OFPORT)
def test_get_port_ofport_returns_invalid_ofport_for_none(self):
- self._test_get_port_ofport(None, const.INVALID_OFPORT)
+ self._test_get_port_ofport(None, ovs_lib.INVALID_OFPORT)
def test_get_datapath_id(self):
datapath_id = '"0000b67f4fbcc149"'
command = ["ovs-vsctl", self.TO, '--', "--may-exist", "add-port",
self.BR_NAME, pname]
command.extend(["--", "set", "Interface", pname])
- command.extend(["type=" + p_const.TYPE_VXLAN,
+ command.extend(["type=" + constants.TYPE_VXLAN,
"options:dst_port=" + vxlan_udp_port,
"options:df_default=false",
"options:remote_ip=" + remote_ip,
self.assertEqual(
self.br.add_tunnel_port(pname, remote_ip, local_ip,
- p_const.TYPE_VXLAN, vxlan_udp_port,
+ constants.TYPE_VXLAN, vxlan_udp_port,
dont_fragment),
ofport)