From bef4ae509256683fefe8785ce62ef2e423009653 Mon Sep 17 00:00:00 2001 From: Unmesh Gurjar Date: Wed, 19 Oct 2011 14:44:01 +0530 Subject: Fix lp:861160 -- newly created network has no uuid Implemented code review changes. Fixed issue causing pep8 build failure. Change-Id: If2cc0e23be8d4e1558a10fa86e6ba4cdec61b7d1 --- Authors | 1 + nova/db/sqlalchemy/api.py | 1 + nova/tests/test_db_api.py | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/Authors b/Authors index fc0edd3af..8bb807041 100644 --- a/Authors +++ b/Authors @@ -122,6 +122,7 @@ Todd Willey Trey Morris Troy Toman Tushar Patil +Unmesh Gurjar Vasiliy Shlykov Vishvananda Ishaya Vivek Y S diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 47efb9019..b49ae1801 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1792,6 +1792,7 @@ def network_count_reserved_ips(context, network_id): @require_admin_context def network_create_safe(context, values): network_ref = models.Network() + network_ref['uuid'] = str(utils.gen_uuid()) network_ref.update(values) try: network_ref.save() diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 6f6269e52..590505a23 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -147,3 +147,12 @@ class DbApiTestCase(test.TestCase): results = db.instance_get_all_hung_in_rebooting(ctxt, 10) self.assertEqual(0, len(results)) db.instance_update(ctxt, instance.id, {"task_state": None}) + + def test_network_create_safe(self): + ctxt = context.get_admin_context() + values = {'host': 'localhost', 'project_id': 'project1'} + network = db.network_create_safe(ctxt, values) + self.assertNotEqual(None, network.uuid) + self.assertEqual(36, len(network.uuid)) + db_network = db.network_get(ctxt, network.id) + self.assertEqual(network.uuid, db_network.uuid) -- cgit