From e88a2a616b6d3eda01ae739e542bec54ff82922f Mon Sep 17 00:00:00 2001 From: Andrew Clay Shafer Date: Tue, 14 Feb 2012 01:44:37 -0500 Subject: Prevent Duplicate VLAN IDs Addresses Bug 708278 Add check for duplicates in api.py Add DuplicateVlan to exception.py Add test to raise DuplicateVlan in test_db_api.py Add to Authors Change-Id: I9d68d7b7c886071e38df3c9d7d53724758bdd84c --- nova/tests/test_db_api.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 121120dbf..3353ea737 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -146,6 +146,14 @@ class DbApiTestCase(test.TestCase): db_network = db.network_get(ctxt, network.id) self.assertEqual(network.uuid, db_network.uuid) + def test_network_create_with_duplicate_vlan(self): + ctxt = context.get_admin_context() + values1 = {'host': 'localhost', 'project_id': 'project1', 'vlan': 1} + values2 = {'host': 'something', 'project_id': 'project1', 'vlan': 1} + db.network_create_safe(ctxt, values1) + self.assertRaises(exception.DuplicateVlan, + db.network_create_safe, ctxt, values2) + def test_instance_update_with_instance_id(self): """ test instance_update() works when an instance id is passed """ ctxt = context.get_admin_context() -- cgit