remove explicit include of the ovs plugin

On installing only neutron-linuxbridge-agent package, the
dhcp cannot start successfully because of the imports from
ovs plugin. This change removes the explicit include of the
ovs plugin from ovs_lib.py. INVALID_OFPORT has been moved to
ovs_lib.py while VXLAN_UDP_PORT has moved to
plugins/common/constants.py. The imports for these 2 constants
in files which uses it has been corrected to new location.

Closes-Bug: #1271449
Change-Id: I6559cb43d1b10b4f926c453a103b12017b59f259
This commit is contained in:
Prasoon Telang 2014-08-29 19:25:35 +05:30
parent 281491fed7
commit 65dde5624b
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 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,
@ -183,7 +185,7 @@ class OVSBridge(BaseOVS):
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',
@ -215,14 +217,14 @@ class OVSBridge(BaseOVS):
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)
@ -234,8 +236,8 @@ class OVSBridge(BaseOVS):
"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.'))

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

View File

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

View File

@ -15,6 +15,7 @@
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
@ -74,7 +75,7 @@ agent_opts = [
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")),

View File

@ -22,9 +22,6 @@ FLAT_VLAN_ID = -1
# 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-'
@ -63,9 +60,6 @@ TUN_TABLE = {p_const.TYPE_GRE: GRE_TUN_TO_LV,
# 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

View File

@ -22,8 +22,7 @@ from neutron.agent.linux import utils
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
@ -355,10 +354,10 @@ class OVS_Lib_Test(base.BaseTestCase):
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"'
@ -488,7 +487,7 @@ class OVS_Lib_Test(base.BaseTestCase):
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,
@ -507,7 +506,7 @@ class OVS_Lib_Test(base.BaseTestCase):
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)