summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2012-10-01 10:30:48 -0700
committerVishvananda Ishaya <vishvananda@gmail.com>2012-10-04 09:49:24 -0700
commit31764456bd4536c920fb1d768fbdebf93e016a8a (patch)
tree1ca740e184677e538e428bb3d7168c0457f0a6f5 /nova/virt
parentb01c148f2fcf68514a276393a6b5a4f79a60f399 (diff)
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
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/firewall.py6
1 files changed, 3 insertions, 3 deletions
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)