Merge "remove explicit include of the ovs plugin"

This commit is contained in:
Jenkins 2014-08-31 04:30:20 +00:00 committed by Gerrit Code Review
commit fe14ef552a
6 changed files with 22 additions and 23 deletions

View File

@ -24,12 +24,14 @@ from neutron.common import exceptions
from neutron.openstack.common import excutils from neutron.openstack.common import excutils
from neutron.openstack.common import jsonutils from neutron.openstack.common import jsonutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants
# TODO(JLH) Should we remove the explicit include of the ovs plugin here
from neutron.plugins.openvswitch.common import constants
# Default timeout for ovs-vsctl command # Default timeout for ovs-vsctl command
DEFAULT_OVS_VSCTL_TIMEOUT = 10 DEFAULT_OVS_VSCTL_TIMEOUT = 10
# Special return value for an invalid OVS ofport
INVALID_OFPORT = '-1'
OPTS = [ OPTS = [
cfg.IntOpt('ovs_vsctl_timeout', cfg.IntOpt('ovs_vsctl_timeout',
default=DEFAULT_OVS_VSCTL_TIMEOUT, default=DEFAULT_OVS_VSCTL_TIMEOUT,
@ -183,7 +185,7 @@ class OVSBridge(BaseOVS):
int(ofport) int(ofport)
return ofport return ofport
except (ValueError, TypeError): except (ValueError, TypeError):
return constants.INVALID_OFPORT return INVALID_OFPORT
def get_datapath_id(self): def get_datapath_id(self):
return self.db_get_val('Bridge', return self.db_get_val('Bridge',
@ -215,14 +217,14 @@ class OVSBridge(BaseOVS):
return DeferredOVSBridge(self, **kwargs) return DeferredOVSBridge(self, **kwargs)
def add_tunnel_port(self, port_name, remote_ip, local_ip, 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, vxlan_udp_port=constants.VXLAN_UDP_PORT,
dont_fragment=True): dont_fragment=True):
vsctl_command = ["--", "--may-exist", "add-port", self.br_name, vsctl_command = ["--", "--may-exist", "add-port", self.br_name,
port_name] port_name]
vsctl_command.extend(["--", "set", "Interface", port_name, vsctl_command.extend(["--", "set", "Interface", port_name,
"type=%s" % tunnel_type]) "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 # Only set the VXLAN UDP port if it's not the default
if vxlan_udp_port != constants.VXLAN_UDP_PORT: if vxlan_udp_port != constants.VXLAN_UDP_PORT:
vsctl_command.append("options:dst_port=%s" % vxlan_udp_port) vsctl_command.append("options:dst_port=%s" % vxlan_udp_port)
@ -234,8 +236,8 @@ class OVSBridge(BaseOVS):
"options:out_key=flow"]) "options:out_key=flow"])
self.run_vsctl(vsctl_command) self.run_vsctl(vsctl_command)
ofport = self.get_port_ofport(port_name) ofport = self.get_port_ofport(port_name)
if (tunnel_type == p_const.TYPE_VXLAN and if (tunnel_type == constants.TYPE_VXLAN and
ofport == constants.INVALID_OFPORT): ofport == INVALID_OFPORT):
LOG.error(_('Unable to create VXLAN tunnel port. Please ensure ' LOG.error(_('Unable to create VXLAN tunnel port. Please ensure '
'that an openvswitch version that supports VXLAN is ' 'that an openvswitch version that supports VXLAN is '
'installed.')) 'installed.'))

View File

@ -29,7 +29,7 @@ def vxlan_supported(root_helper, from_ip='192.0.2.1', to_ip='192.0.2.2'):
name = "vxlantest-" + utils.get_random_string(6) name = "vxlantest-" + utils.get_random_string(6)
with ovs_lib.OVSBridge(name, root_helper) as br: with ovs_lib.OVSBridge(name, root_helper) as br:
port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN) 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): def patch_supported(root_helper):
@ -39,7 +39,7 @@ def patch_supported(root_helper):
patch_name = "peertest1-" + seed patch_name = "peertest1-" + seed
with ovs_lib.OVSBridge(name, root_helper) as br: with ovs_lib.OVSBridge(name, root_helper) as br:
port = br.add_patch_port(patch_name, peer_name) 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(): def nova_notify_supported():

View File

@ -79,3 +79,6 @@ TYPE_LOCAL = 'local'
TYPE_VXLAN = 'vxlan' TYPE_VXLAN = 'vxlan'
TYPE_VLAN = 'vlan' TYPE_VLAN = 'vlan'
TYPE_NONE = 'none' TYPE_NONE = 'none'
# Values for network_type
VXLAN_UDP_PORT = 4789

View File

@ -15,6 +15,7 @@
from oslo.config import cfg from oslo.config import cfg
from neutron.agent.common import config from neutron.agent.common import config
from neutron.plugins.common import constants as p_const
from neutron.plugins.openvswitch.common import constants from neutron.plugins.openvswitch.common import constants
@ -74,7 +75,7 @@ agent_opts = [
cfg.ListOpt('tunnel_types', default=DEFAULT_TUNNEL_TYPES, cfg.ListOpt('tunnel_types', default=DEFAULT_TUNNEL_TYPES,
help=_("Network types supported by the agent " help=_("Network types supported by the agent "
"(gre and/or vxlan)")), "(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.")), help=_("The UDP port to use for VXLAN tunnels.")),
cfg.IntOpt('veth_mtu', cfg.IntOpt('veth_mtu',
help=_("MTU size of veth interfaces")), help=_("MTU size of veth interfaces")),

View File

@ -22,9 +22,6 @@ FLAT_VLAN_ID = -1
# Topic for tunnel notifications between the plugin and agent # Topic for tunnel notifications between the plugin and agent
TUNNEL = 'tunnel' TUNNEL = 'tunnel'
# Values for network_type
VXLAN_UDP_PORT = 4789
# Name prefixes for veth device or patch port pair linking the integration # Name prefixes for veth device or patch port pair linking the integration
# bridge with the physical bridge for a physical network # bridge with the physical bridge for a physical network
PEER_INTEGRATION_PREFIX = 'int-' PEER_INTEGRATION_PREFIX = 'int-'
@ -63,9 +60,6 @@ TUN_TABLE = {p_const.TYPE_GRE: GRE_TUN_TO_LV,
# The default respawn interval for the ovsdb monitor # The default respawn interval for the ovsdb monitor
DEFAULT_OVSDBMON_RESPAWN = 30 DEFAULT_OVSDBMON_RESPAWN = 30
# Special return value for an invalid OVS ofport
INVALID_OFPORT = '-1'
# Represent invalid OF Port # Represent invalid OF Port
OFPORT_INVALID = -1 OFPORT_INVALID = -1

View File

@ -22,8 +22,7 @@ from neutron.agent.linux import utils
from neutron.common import exceptions from neutron.common import exceptions
from neutron.openstack.common import jsonutils from neutron.openstack.common import jsonutils
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants as p_const from neutron.plugins.common import constants
from neutron.plugins.openvswitch.common import constants as const
from neutron.tests import base from neutron.tests import base
from neutron.tests import tools from neutron.tests import tools
@ -355,10 +354,10 @@ class OVS_Lib_Test(base.BaseTestCase):
self._test_get_port_ofport("6", "6") self._test_get_port_ofport("6", "6")
def test_get_port_ofport_returns_invalid_ofport_for_non_int(self): 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): 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): def test_get_datapath_id(self):
datapath_id = '"0000b67f4fbcc149"' datapath_id = '"0000b67f4fbcc149"'
@ -488,7 +487,7 @@ class OVS_Lib_Test(base.BaseTestCase):
command = ["ovs-vsctl", self.TO, '--', "--may-exist", "add-port", command = ["ovs-vsctl", self.TO, '--', "--may-exist", "add-port",
self.BR_NAME, pname] self.BR_NAME, pname]
command.extend(["--", "set", "Interface", 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:dst_port=" + vxlan_udp_port,
"options:df_default=false", "options:df_default=false",
"options:remote_ip=" + remote_ip, "options:remote_ip=" + remote_ip,
@ -507,7 +506,7 @@ class OVS_Lib_Test(base.BaseTestCase):
self.assertEqual( self.assertEqual(
self.br.add_tunnel_port(pname, remote_ip, local_ip, 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), dont_fragment),
ofport) ofport)