From 31764456bd4536c920fb1d768fbdebf93e016a8a Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 1 Oct 2012 10:30:48 -0700 Subject: Stop network.api import on network import The nova.network.__init__.py was importing the network.api automatically at import time. This was leading to some silly workarounds (for example in nova/virt/firewall.py) involving late importing nova.network to stop circular imports. It is also causing issues with https://review.openstack.org/#/c/13007/ because quantum api needs to import a flag from network manager which is causing a circular import. This fixes the issue by moving to use the code from volume_api which only imports the api class when the method is called. It cleans up the tests that were stubbing out network.API and also removes the unneeded workarounds. Change-Id: I4c9b372d078ab4398e797335a8de5e9e1077e31f --- nova/virt/firewall.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/firewall.py b/nova/virt/firewall.py index 1da76edeb..eb14a92c5 100644 --- a/nova/virt/firewall.py +++ b/nova/virt/firewall.py @@ -20,6 +20,8 @@ from nova import context from nova import db from nova import flags +from nova import network +from nova.network import linux_net from nova.openstack.common import cfg from nova.openstack.common import importutils from nova.openstack.common import log as logging @@ -138,7 +140,6 @@ class IptablesFirewallDriver(FirewallDriver): """Driver which enforces security groups through iptables rules.""" def __init__(self, **kwargs): - from nova.network import linux_net self.iptables = linux_net.iptables_manager self.instances = {} self.network_infos = {} @@ -392,8 +393,7 @@ class IptablesFirewallDriver(FirewallDriver): # has access to a nw_api handle, # and should be the only one making # making rpc calls. - import nova.network - nw_api = nova.network.API() + nw_api = network.API() for instance in rule['grantee_group']['instances']: nw_info = nw_api.get_instance_nw_info(ctxt, instance) -- cgit