summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavanum Srinivas <dims@linux.vnet.ibm.com>2013-01-26 15:31:15 -0500
committerDavanum Srinivas <dims@linux.vnet.ibm.com>2013-01-26 15:31:15 -0500
commit94e300273c6d0befc6d76d231e9b273d1444674f (patch)
tree452cc91c55dd20c4d5f64dac029fb275bc75618f
parente1ce3878b951ea491548c129453bb84a77205649 (diff)
downloadnova-94e300273c6d0befc6d76d231e9b273d1444674f.tar.gz
nova-94e300273c6d0befc6d76d231e9b273d1444674f.tar.xz
nova-94e300273c6d0befc6d76d231e9b273d1444674f.zip
Don't warn up front about libvirt loading issues in NWFilterFirewall
Use the same technique as in libvirt/driver.py to delay import of libvirt module Change-Id: I500ddde4651f0f747c54533a1a308eee5a87f717
-rw-r--r--nova/virt/libvirt/firewall.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/nova/virt/libvirt/firewall.py b/nova/virt/libvirt/firewall.py
index 3323b8f1d..5b712cf42 100644
--- a/nova/virt/libvirt/firewall.py
+++ b/nova/virt/libvirt/firewall.py
@@ -29,11 +29,7 @@ LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CONF.import_opt('use_ipv6', 'nova.netconf')
-try:
- import libvirt
-except ImportError:
- LOG.warn(_("Libvirt module could not be loaded. NWFilterFirewall will "
- "not work correctly."))
+libvirt = None
class NWFilterFirewall(base_firewall.FirewallDriver):
@@ -47,6 +43,13 @@ class NWFilterFirewall(base_firewall.FirewallDriver):
def __init__(self, virtapi, get_connection, **kwargs):
super(NWFilterFirewall, self).__init__(virtapi)
+ global libvirt
+ if libvirt is None:
+ try:
+ libvirt = __import__('libvirt')
+ except ImportError:
+ LOG.warn(_("Libvirt module could not be loaded. "
+ "NWFilterFirewall will not work correctly."))
self._libvirt_get_connection = get_connection
self.static_filters_configured = False
self.handle_security_groups = False