summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorÉdouard Thuleau <edouard.thuleau@orange.com>2012-11-27 17:15:34 +0100
committerÉdouard Thuleau <edouard.thuleau@orange.com>2012-12-07 18:13:22 +0100
commit40fcbcb8852cad03eec345106772292fa08b25dc (patch)
tree1f2d1991259a67e688033f685b1fd58797632317 /nova/tests
parent87e609ca8e038c89de7853c2461088ebad645f9e (diff)
Remove unused bridge interfaces
If a network gateway of multi hosted network is unsed by any VM on the host, we tear down it. It is implemented only with the VLAN manager. Fixes LP bug #1084651 Change-Id: Ia7e399de5b8ddf6ec252d38dfbb8762c4f14e3a5
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/network/test_linux_net.py27
-rw-r--r--nova/tests/test_db_api.py17
2 files changed, 44 insertions, 0 deletions
diff --git a/nova/tests/network/test_linux_net.py b/nova/tests/network/test_linux_net.py
index 55a9c7777..68aaa6251 100644
--- a/nova/tests/network/test_linux_net.py
+++ b/nova/tests/network/test_linux_net.py
@@ -494,6 +494,33 @@ class LinuxNetworkTestCase(test.TestCase):
for inp in expected_inputs:
self.assertTrue(inp in inputs[0])
+ executes = []
+ inputs = []
+
+ @classmethod
+ def fake_remove(_self, bridge, gateway):
+ return
+
+ self.stubs.Set(linux_net.LinuxBridgeInterfaceDriver,
+ 'remove_bridge', fake_remove)
+
+ driver.unplug(network)
+ expected = [
+ ('ebtables', '-D', 'INPUT', '-p', 'ARP', '-i', iface,
+ '--arp-ip-dst', dhcp, '-j', 'DROP'),
+ ('ebtables', '-D', 'OUTPUT', '-p', 'ARP', '-o', iface,
+ '--arp-ip-src', dhcp, '-j', 'DROP'),
+ ('iptables-save', '-c', '-t', 'filter'),
+ ('iptables-restore', '-c'),
+ ('iptables-save', '-c', '-t', 'nat'),
+ ('iptables-restore', '-c'),
+ ('ip6tables-save', '-c', '-t', 'filter'),
+ ('ip6tables-restore', '-c'),
+ ]
+ self.assertEqual(executes, expected)
+ for inp in expected_inputs:
+ self.assertFalse(inp in inputs[0])
+
def _test_initialize_gateway(self, existing, expected, routes=''):
self.flags(fake_network=False)
executes = []
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py
index f2124c021..29bce8bf5 100644
--- a/nova/tests/test_db_api.py
+++ b/nova/tests/test_db_api.py
@@ -582,6 +582,23 @@ class DbApiTestCase(test.TestCase):
data = db.network_get_all_by_host(ctxt, 'foo')
self.assertEqual(len(data), 3)
+ def test_network_in_use_on_host(self):
+ ctxt = context.get_admin_context()
+
+ values = {'host': 'foo', 'hostname': 'myname'}
+ instance = db.instance_create(ctxt, values)
+ values = {'address': 'bar', 'instance_uuid': instance['uuid']}
+ vif = db.virtual_interface_create(ctxt, values)
+ values = {'address': 'baz',
+ 'network_id': 1,
+ 'allocated': True,
+ 'instance_uuid': instance['uuid'],
+ 'virtual_interface_id': vif['id']}
+ db.fixed_ip_create(ctxt, values)
+
+ self.assertEqual(db.network_in_use_on_host(ctxt, 1, 'foo'), True)
+ self.assertEqual(db.network_in_use_on_host(ctxt, 1, 'bar'), False)
+
def _timeout_test(self, ctxt, timeout, multi_host):
values = {'host': 'foo'}
instance = db.instance_create(ctxt, values)