From 84114e426f3973d78fc0f6766f3ad7577349da7a Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Thu, 1 Mar 2012 20:55:53 -0800 Subject: Update fixed_ip_associate to not use relationships * fixed_ip_associate was using the FixedIp.instance and FixedIp.network relationships, which were removed. This change updates the method to use instance_id and network_id instead. * Adds unit tests for fixed_ip_associate * Resolves bug 943029 Change-Id: I0829d110058b8799a520ab68b5fa1b2370b9cc3e --- nova/db/sqlalchemy/api.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'nova/db') diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index b824146a0..e5e277942 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -993,16 +993,12 @@ def fixed_ip_associate(context, address, instance_id, network_id=None, if fixed_ip_ref is None: raise exception.FixedIpNotFoundForNetwork(address=address, network_id=network_id) - if fixed_ip_ref.instance is not None: + if fixed_ip_ref.instance_id: raise exception.FixedIpAlreadyInUse(address=address) - if not fixed_ip_ref.network: - fixed_ip_ref.network = network_get(context, - network_id, - session=session) - fixed_ip_ref.instance = instance_get(context, - instance_id, - session=session) + if not fixed_ip_ref.network_id: + fixed_ip_ref.network_id = network_id + fixed_ip_ref.instance_id = instance_id session.add(fixed_ip_ref) return fixed_ip_ref['address'] -- cgit