Fix lb doesn't remove vxlan int. if no int. map
LinuxBridge agent doesn't remove vxlan interfaces if interface_mappings is not set. Fixes bug: 1240742 Change-Id: I163f1ac8cbd46b8d8836152e2be8cb7608a8ca22
This commit is contained in:
parent
806a6cd064
commit
f39c8965d9
@ -418,6 +418,11 @@ class LinuxBridgeManager:
|
|||||||
interfaces_on_bridge = self.get_interfaces_on_bridge(bridge_name)
|
interfaces_on_bridge = self.get_interfaces_on_bridge(bridge_name)
|
||||||
for interface in interfaces_on_bridge:
|
for interface in interfaces_on_bridge:
|
||||||
self.remove_interface(bridge_name, interface)
|
self.remove_interface(bridge_name, interface)
|
||||||
|
|
||||||
|
if interface.startswith(VXLAN_INTERFACE_PREFIX):
|
||||||
|
self.delete_vxlan(interface)
|
||||||
|
continue
|
||||||
|
|
||||||
for physical_interface in self.interface_mappings.itervalues():
|
for physical_interface in self.interface_mappings.itervalues():
|
||||||
if physical_interface == interface:
|
if physical_interface == interface:
|
||||||
# This is a flat network => return IP's from bridge to
|
# This is a flat network => return IP's from bridge to
|
||||||
@ -428,8 +433,6 @@ class LinuxBridgeManager:
|
|||||||
ips, gateway)
|
ips, gateway)
|
||||||
elif interface.startswith(physical_interface):
|
elif interface.startswith(physical_interface):
|
||||||
self.delete_vlan(interface)
|
self.delete_vlan(interface)
|
||||||
elif interface.startswith(VXLAN_INTERFACE_PREFIX):
|
|
||||||
self.delete_vxlan(interface)
|
|
||||||
|
|
||||||
LOG.debug(_("Deleting bridge %s"), bridge_name)
|
LOG.debug(_("Deleting bridge %s"), bridge_name)
|
||||||
if utils.execute(['ip', 'link', 'set', bridge_name, 'down'],
|
if utils.execute(['ip', 'link', 'set', bridge_name, 'down'],
|
||||||
|
@ -506,20 +506,44 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
|||||||
mock.patch.object(self.lbm, "get_interface_details"),
|
mock.patch.object(self.lbm, "get_interface_details"),
|
||||||
mock.patch.object(self.lbm, "update_interface_ip_details"),
|
mock.patch.object(self.lbm, "update_interface_ip_details"),
|
||||||
mock.patch.object(self.lbm, "delete_vlan"),
|
mock.patch.object(self.lbm, "delete_vlan"),
|
||||||
|
mock.patch.object(self.lbm, "delete_vxlan"),
|
||||||
mock.patch.object(utils, "execute")
|
mock.patch.object(utils, "execute")
|
||||||
) as (de_fn, getif_fn, remif_fn, if_det_fn,
|
) as (de_fn, getif_fn, remif_fn, if_det_fn,
|
||||||
updif_fn, del_vlan, exec_fn):
|
updif_fn, del_vlan, del_vxlan, exec_fn):
|
||||||
de_fn.return_value = False
|
de_fn.return_value = False
|
||||||
self.lbm.delete_vlan_bridge("br0")
|
self.lbm.delete_vlan_bridge("br0")
|
||||||
self.assertFalse(getif_fn.called)
|
self.assertFalse(getif_fn.called)
|
||||||
|
|
||||||
de_fn.return_value = True
|
de_fn.return_value = True
|
||||||
getif_fn.return_value = ["eth0", "eth1.1", "eth1"]
|
getif_fn.return_value = ["eth0", "eth1.1", "eth1", "vxlan-1002"]
|
||||||
if_det_fn.return_value = ("ips", "gateway")
|
if_det_fn.return_value = ("ips", "gateway")
|
||||||
exec_fn.return_value = False
|
exec_fn.return_value = False
|
||||||
self.lbm.delete_vlan_bridge("br0")
|
self.lbm.delete_vlan_bridge("br0")
|
||||||
updif_fn.assert_called_with("eth1", "br0", "ips", "gateway")
|
updif_fn.assert_called_with("eth1", "br0", "ips", "gateway")
|
||||||
del_vlan.assert_called_with("eth1.1")
|
del_vlan.assert_called_with("eth1.1")
|
||||||
|
del_vxlan.assert_called_with("vxlan-1002")
|
||||||
|
|
||||||
|
def test_delete_vxlan_bridge_no_int_mappings(self):
|
||||||
|
interface_mappings = {}
|
||||||
|
lbm = linuxbridge_neutron_agent.LinuxBridgeManager(
|
||||||
|
interface_mappings, self.root_helper)
|
||||||
|
|
||||||
|
with contextlib.nested(
|
||||||
|
mock.patch.object(lbm, "device_exists"),
|
||||||
|
mock.patch.object(lbm, "get_interfaces_on_bridge"),
|
||||||
|
mock.patch.object(lbm, "remove_interface"),
|
||||||
|
mock.patch.object(lbm, "delete_vxlan"),
|
||||||
|
mock.patch.object(utils, "execute")
|
||||||
|
) as (de_fn, getif_fn, remif_fn, del_vxlan, exec_fn):
|
||||||
|
de_fn.return_value = False
|
||||||
|
lbm.delete_vlan_bridge("br0")
|
||||||
|
self.assertFalse(getif_fn.called)
|
||||||
|
|
||||||
|
de_fn.return_value = True
|
||||||
|
getif_fn.return_value = ["vxlan-1002"]
|
||||||
|
exec_fn.return_value = False
|
||||||
|
lbm.delete_vlan_bridge("br0")
|
||||||
|
del_vxlan.assert_called_with("vxlan-1002")
|
||||||
|
|
||||||
def test_remove_empty_bridges(self):
|
def test_remove_empty_bridges(self):
|
||||||
self.lbm.network_map = {'net1': mock.Mock(), 'net2': mock.Mock()}
|
self.lbm.network_map = {'net1': mock.Mock(), 'net2': mock.Mock()}
|
||||||
|
Loading…
Reference in New Issue
Block a user