From a4fd9df8723b6647a79e3e9a5abdd076ba0c5363 Mon Sep 17 00:00:00 2001 From: Mate Lakat Date: Thu, 24 Jan 2013 13:27:40 +0000 Subject: Fix rendering of FixedIpNotFoundForNetworkHost Fixes bug 1104000 With https://review.openstack.org/18319 a small bug was introduced. The exception FixedIpNotFoundForNetworkHost is expecting network_id parameter, and the change modified that parameter to network_uuid. This patch fixes this problem at the raise point. Change-Id: Idc0fa7fcba9ad37b73183f8811376c6c8adada68 --- nova/db/sqlalchemy/api.py | 2 +- nova/tests/test_db_api.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index dff2e6b81..e7b7a47dc 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1245,7 +1245,7 @@ def fixed_ip_get_by_network_host(context, network_id, host): first() if not result: - raise exception.FixedIpNotFoundForNetworkHost(network_uuid=network_id, + raise exception.FixedIpNotFoundForNetworkHost(network_id=network_id, host=host) return result diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index e43a32c19..f9724c35e 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -1510,6 +1510,25 @@ class MigrationTestCase(test.TestCase): self.assertEqual(migration['instance_uuid'], instance['uuid']) +class TestFixedIPGetByNetworkHost(test.TestCase): + def test_not_found_exception(self): + ctxt = context.get_admin_context() + + self.assertRaises( + exception.FixedIpNotFoundForNetworkHost, + db.fixed_ip_get_by_network_host, + ctxt, 1, 'ignore') + + def test_fixed_ip_found(self): + ctxt = context.get_admin_context() + db.fixed_ip_create(ctxt, dict(network_id=1, host='host')) + + fip = db.fixed_ip_get_by_network_host(ctxt, 1, 'host') + + self.assertEquals(1, fip['network_id']) + self.assertEquals('host', fip['host']) + + class TestIpAllocation(test.TestCase): def setUp(self): -- cgit