From 20f98c5785bfc074caaaa5542d19b7f361597e30 Mon Sep 17 00:00:00 2001 From: John Tran Date: Tue, 15 May 2012 10:00:36 -0700 Subject: [PATCH] fixed_ip_get_by_address read_deleted from context Fixes bug 996482. by default fixed_ip_get_by_address always sets read_deleted='yes'. Changed it to accept read_deleted value from context. updated .mailmap to rewrite my old email to new email Change-Id: If94251972df7bbcfdeebc226613edac0a3f41186 (cherry picked from commit c1e54e1968faa23dfa26796fdb8f3f8d9ba79367) --- .mailmap | 1 + Authors | 2 +- nova/db/sqlalchemy/api.py | 2 +- nova/tests/test_db_api.py | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index 38783c9f3bc..0a4ed2432ac 100644 --- a/.mailmap +++ b/.mailmap @@ -80,3 +80,4 @@ + diff --git a/Authors b/Authors index 80b08780926..f01013cde54 100644 --- a/Authors +++ b/Authors @@ -99,7 +99,7 @@ John Dewey John Garbutt John Griffith John Kennedy -John Tran +John Tran Jonathan Bryce Jordan Rinke Joseph Suh diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index affaa86f612..55eec9ec9b9 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1047,7 +1047,7 @@ def fixed_ip_get_all(context, session=None): @require_context def fixed_ip_get_by_address(context, address, session=None): result = model_query(context, models.FixedIp, session=session, - read_deleted="yes").\ + read_deleted=context.read_deleted).\ filter_by(address=address).\ first() if not result: diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 28f35589f59..078b6b50068 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -151,6 +151,8 @@ def test_network_delete_safe(self): db.network_delete_safe, ctxt, network['id']) db.fixed_ip_update(ctxt, address2, {'allocated': False}) network = db.network_delete_safe(ctxt, network['id']) + self.assertRaises(exception.FixedIpNotFoundForAddress, + db.fixed_ip_get_by_address, ctxt, address1) ctxt = ctxt.elevated(read_deleted='yes') fixed_ip = db.fixed_ip_get_by_address(ctxt, address1) self.assertTrue(fixed_ip['deleted'])