Update common network type consts to same origin
This patch removes new definitions of common network type constants (TYPE_FLAT, TYPE_LOCAL, etc.) and modifies uses of aforementioned constants to a common place where constants are defined (neutron.plugins.common.constants). This patch does not change values that are equal in value but different in name: NETWORK_TYPE_FLAT vs TYPE_FLAT. A second changeset will be made to handle that case. Unit tests were modified as well when they referred to the constant. Finally, the ovs agent code refers to the OVS plugin constants directly and these had to be changed as well. A TODO flag was put in that file due to use of another plugin specific constant. Network types that were only defined in a single plugin, such as mellanox's infiniband (IB) network type was not carried over to the common constants file. Fixes-bug: #1196170 Change-Id: Ib6bfc8275496a24bf247946d177c734b62ae44bb
This commit is contained in:
@@ -25,6 +25,7 @@ from neutron.agent.linux import ip_lib
|
||||
from neutron.agent.linux import utils
|
||||
from neutron.common import constants
|
||||
from neutron.openstack.common.rpc import common as rpc_common
|
||||
from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.linuxbridge.agent import linuxbridge_neutron_agent
|
||||
from neutron.plugins.linuxbridge.common import constants as lconst
|
||||
from neutron.tests import base
|
||||
@@ -55,7 +56,7 @@ class TestLinuxBridge(base.BaseTestCase):
|
||||
|
||||
def test_ensure_physical_in_bridge_invalid(self):
|
||||
result = self.linux_bridge.ensure_physical_in_bridge('network_id',
|
||||
lconst.TYPE_VLAN,
|
||||
p_const.TYPE_VLAN,
|
||||
'physnetx',
|
||||
7)
|
||||
self.assertFalse(result)
|
||||
@@ -64,14 +65,14 @@ class TestLinuxBridge(base.BaseTestCase):
|
||||
with mock.patch.object(self.linux_bridge,
|
||||
'ensure_flat_bridge') as flat_bridge_func:
|
||||
self.linux_bridge.ensure_physical_in_bridge(
|
||||
'network_id', lconst.TYPE_FLAT, 'physnet1', None)
|
||||
'network_id', p_const.TYPE_FLAT, 'physnet1', None)
|
||||
self.assertTrue(flat_bridge_func.called)
|
||||
|
||||
def test_ensure_physical_in_bridge_vlan(self):
|
||||
with mock.patch.object(self.linux_bridge,
|
||||
'ensure_vlan_bridge') as vlan_bridge_func:
|
||||
self.linux_bridge.ensure_physical_in_bridge(
|
||||
'network_id', lconst.TYPE_VLAN, 'physnet1', 7)
|
||||
'network_id', p_const.TYPE_VLAN, 'physnet1', 7)
|
||||
self.assertTrue(vlan_bridge_func.called)
|
||||
|
||||
def test_ensure_physical_in_bridge_vxlan(self):
|
||||
@@ -433,18 +434,18 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
|
||||
def test_ensure_physical_in_bridge(self):
|
||||
self.assertFalse(
|
||||
self.lbm.ensure_physical_in_bridge("123", lconst.TYPE_VLAN,
|
||||
self.lbm.ensure_physical_in_bridge("123", p_const.TYPE_VLAN,
|
||||
"phys", "1")
|
||||
)
|
||||
with mock.patch.object(self.lbm, "ensure_flat_bridge") as flbr_fn:
|
||||
self.assertTrue(
|
||||
self.lbm.ensure_physical_in_bridge("123", lconst.TYPE_FLAT,
|
||||
self.lbm.ensure_physical_in_bridge("123", p_const.TYPE_FLAT,
|
||||
"physnet1", None)
|
||||
)
|
||||
self.assertTrue(flbr_fn.called)
|
||||
with mock.patch.object(self.lbm, "ensure_vlan_bridge") as vlbr_fn:
|
||||
self.assertTrue(
|
||||
self.lbm.ensure_physical_in_bridge("123", lconst.TYPE_VLAN,
|
||||
self.lbm.ensure_physical_in_bridge("123", p_const.TYPE_VLAN,
|
||||
"physnet1", "1")
|
||||
)
|
||||
self.assertTrue(vlbr_fn.called)
|
||||
@@ -452,7 +453,7 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
with mock.patch.object(self.lbm, "ensure_vxlan_bridge") as vlbr_fn:
|
||||
self.lbm.vxlan_mode = lconst.VXLAN_MCAST
|
||||
self.assertTrue(
|
||||
self.lbm.ensure_physical_in_bridge("123", lconst.TYPE_VXLAN,
|
||||
self.lbm.ensure_physical_in_bridge("123", p_const.TYPE_VXLAN,
|
||||
"physnet1", "1")
|
||||
)
|
||||
self.assertTrue(vlbr_fn.called)
|
||||
@@ -461,7 +462,7 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
with mock.patch.object(self.lbm, "device_exists") as de_fn:
|
||||
de_fn.return_value = False
|
||||
self.assertFalse(
|
||||
self.lbm.add_tap_interface("123", lconst.TYPE_VLAN,
|
||||
self.lbm.add_tap_interface("123", p_const.TYPE_VLAN,
|
||||
"physnet1", "1", "tap1")
|
||||
)
|
||||
|
||||
@@ -474,7 +475,7 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
exec_fn.return_value = False
|
||||
get_br.return_value = True
|
||||
self.assertTrue(self.lbm.add_tap_interface("123",
|
||||
lconst.TYPE_LOCAL,
|
||||
p_const.TYPE_LOCAL,
|
||||
"physnet1", None,
|
||||
"tap1"))
|
||||
en_fn.assert_called_with("123")
|
||||
@@ -482,7 +483,7 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
get_br.return_value = False
|
||||
exec_fn.return_value = True
|
||||
self.assertFalse(self.lbm.add_tap_interface("123",
|
||||
lconst.TYPE_LOCAL,
|
||||
p_const.TYPE_LOCAL,
|
||||
"physnet1", None,
|
||||
"tap1"))
|
||||
|
||||
@@ -490,15 +491,15 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
||||
"ensure_physical_in_bridge") as ens_fn:
|
||||
ens_fn.return_value = False
|
||||
self.assertFalse(self.lbm.add_tap_interface("123",
|
||||
lconst.TYPE_VLAN,
|
||||
p_const.TYPE_VLAN,
|
||||
"physnet1", "1",
|
||||
"tap1"))
|
||||
|
||||
def test_add_interface(self):
|
||||
with mock.patch.object(self.lbm, "add_tap_interface") as add_tap:
|
||||
self.lbm.add_interface("123", lconst.TYPE_VLAN, "physnet-1",
|
||||
self.lbm.add_interface("123", p_const.TYPE_VLAN, "physnet-1",
|
||||
"1", "234")
|
||||
add_tap.assert_called_with("123", lconst.TYPE_VLAN, "physnet-1",
|
||||
add_tap.assert_called_with("123", p_const.TYPE_VLAN, "physnet-1",
|
||||
"1", "tap234")
|
||||
|
||||
def test_delete_vlan_bridge(self):
|
||||
@@ -729,50 +730,50 @@ class TestLinuxBridgeRpcCallbacks(base.BaseTestCase):
|
||||
self.lb_rpc.port_update("unused_context", port=port,
|
||||
vlan_id="1", physical_network="physnet1")
|
||||
self.assertFalse(reffw_fn.called)
|
||||
addif_fn.assert_called_with(port["network_id"], lconst.TYPE_VLAN,
|
||||
addif_fn.assert_called_with(port["network_id"], p_const.TYPE_VLAN,
|
||||
"physnet1", "1", port["id"])
|
||||
|
||||
self.lb_rpc.port_update("unused_context", port=port,
|
||||
network_type=lconst.TYPE_VLAN,
|
||||
network_type=p_const.TYPE_VLAN,
|
||||
segmentation_id="2",
|
||||
physical_network="physnet1")
|
||||
self.assertFalse(reffw_fn.called)
|
||||
addif_fn.assert_called_with(port["network_id"], lconst.TYPE_VLAN,
|
||||
addif_fn.assert_called_with(port["network_id"], p_const.TYPE_VLAN,
|
||||
"physnet1", "2", port["id"])
|
||||
|
||||
self.lb_rpc.port_update("unused_context", port=port,
|
||||
vlan_id=lconst.FLAT_VLAN_ID,
|
||||
physical_network="physnet1")
|
||||
self.assertFalse(reffw_fn.called)
|
||||
addif_fn.assert_called_with(port["network_id"], lconst.TYPE_FLAT,
|
||||
addif_fn.assert_called_with(port["network_id"], p_const.TYPE_FLAT,
|
||||
"physnet1", None, port["id"])
|
||||
|
||||
self.lb_rpc.port_update("unused_context", port=port,
|
||||
network_type=lconst.TYPE_FLAT,
|
||||
network_type=p_const.TYPE_FLAT,
|
||||
segmentation_id=None,
|
||||
physical_network="physnet1")
|
||||
self.assertFalse(reffw_fn.called)
|
||||
addif_fn.assert_called_with(port["network_id"], lconst.TYPE_FLAT,
|
||||
addif_fn.assert_called_with(port["network_id"], p_const.TYPE_FLAT,
|
||||
"physnet1", None, port["id"])
|
||||
|
||||
self.lb_rpc.port_update("unused_context", port=port,
|
||||
vlan_id=lconst.LOCAL_VLAN_ID,
|
||||
physical_network=None)
|
||||
self.assertFalse(reffw_fn.called)
|
||||
addif_fn.assert_called_with(port["network_id"], lconst.TYPE_LOCAL,
|
||||
addif_fn.assert_called_with(port["network_id"], p_const.TYPE_LOCAL,
|
||||
None, None, port["id"])
|
||||
|
||||
self.lb_rpc.port_update("unused_context", port=port,
|
||||
network_type=lconst.TYPE_LOCAL,
|
||||
network_type=p_const.TYPE_LOCAL,
|
||||
segmentation_id=None,
|
||||
physical_network=None)
|
||||
self.assertFalse(reffw_fn.called)
|
||||
addif_fn.assert_called_with(port["network_id"], lconst.TYPE_LOCAL,
|
||||
addif_fn.assert_called_with(port["network_id"], p_const.TYPE_LOCAL,
|
||||
None, None, port["id"])
|
||||
|
||||
addif_fn.return_value = True
|
||||
self.lb_rpc.port_update("unused_context", port=port,
|
||||
network_type=lconst.TYPE_LOCAL,
|
||||
network_type=p_const.TYPE_LOCAL,
|
||||
segmentation_id=None,
|
||||
physical_network=None)
|
||||
rpc_obj.update_device_up.assert_called_with(
|
||||
@@ -784,7 +785,7 @@ class TestLinuxBridgeRpcCallbacks(base.BaseTestCase):
|
||||
|
||||
addif_fn.return_value = False
|
||||
self.lb_rpc.port_update("unused_context", port=port,
|
||||
network_type=lconst.TYPE_LOCAL,
|
||||
network_type=p_const.TYPE_LOCAL,
|
||||
segmentation_id=None,
|
||||
physical_network=None)
|
||||
rpc_obj.update_device_down.assert_called_with(
|
||||
|
||||
Reference in New Issue
Block a user