From 695fa6ca4467e0cddb8964a4b9cd10a69ec83161 Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Thu, 23 Feb 2012 14:24:38 -0600 Subject: Fixes error if Melange returns no networks If melange returns no networks for the tenant the loop that loads instance from the DB will not run, causing an error. This loop also loads the same instance every iteration, which is inefficient. This small change fixes that. Change-Id: I34d410fae3919e9e3f268d98efd01eecd2ed0a3f --- nova/network/quantum/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/network/quantum/manager.py b/nova/network/quantum/manager.py index 79f278401..c6132056e 100644 --- a/nova/network/quantum/manager.py +++ b/nova/network/quantum/manager.py @@ -287,6 +287,7 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager): project_id = kwargs['project_id'] LOG.debug(_("network allocations for instance %s"), project_id) requested_networks = kwargs.get('requested_networks') + instance = db.instance_get(context, instance_id) net_proj_pairs = self.ipam.get_project_and_global_net_ids(context, project_id) @@ -315,7 +316,6 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager): project_id) # talk to Quantum API to create and attach port. - instance = db.instance_get(context, instance_id) nova_id = self._get_nova_id(instance) # Tell the ipam library to allocate an IP ips = self.ipam.allocate_fixed_ips(context, project_id, -- cgit