]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
remove explicit include of the ovs plugin
authorPrasoon Telang <prasoontelang@gmail.com>
Fri, 29 Aug 2014 13:55:35 +0000 (19:25 +0530)
committerPrasoon Telang <prasoontelang@gmail.com>
Fri, 29 Aug 2014 13:55:35 +0000 (19:25 +0530)
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

neutron/agent/linux/ovs_lib.py
neutron/cmd/sanity/checks.py
neutron/plugins/common/constants.py
neutron/plugins/openvswitch/common/config.py
neutron/plugins/openvswitch/common/constants.py
neutron/tests/unit/agent/linux/test_ovs_lib.py

index a99a013ec364c06d1fa730227ed88c50073b2845..2013ba170c60cbfa36ef0fd787acaa34d1d41ddc 100644 (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.'))
index 68cf32f226e2290d646d47f073090547a0ec84e0..da3766355915b63b866c26384b74b662b6654f4d 100644 (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():
index 1e56ed1de7522e766a8985f3a46f5a02961ba08e..10d2902d8bff4622a9b893600b0a4d639ec5c188 100644 (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
index 026d487c2ba8e97a77ad0c5feb996bca8986b3e5..09316b3716f0696270812e2a5385798beb37c49a 100644 (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")),
index 5fe702484ddce3dacd315eb3fae5c25e14556a66..4842a74c7c72533c6b3876cb7f7d9ca2dad3b3b7 100644 (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
 
index 88ae4baf210b1f370319995a6861b083886cc5d5..3fbf8137825dc121b6ff85fe5d1db6c23cfcd0f2 100644 (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)