From 57e13de015307981bc6e34c970ad589d5671088f Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Tue, 12 Mar 2013 23:52:29 +0000 Subject: Lazy load CONF.quota_driver. nova.quota is imported before config options are parsed and it looks at CONF.quota_driver on module-load. This changes it so we look at CONF.quota_driver post-module-load. Fixes bug 1154371 Change-Id: Ia2e63a7aeab2234be683ff507e7856d46601a9a8 --- nova/quota.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/nova/quota.py b/nova/quota.py index 3361154dd..a7a3ff078 100644 --- a/nova/quota.py +++ b/nova/quota.py @@ -776,15 +776,20 @@ class QuotaEngine(object): def __init__(self, quota_driver_class=None): """Initialize a Quota object.""" - - if not quota_driver_class: - quota_driver_class = CONF.quota_driver - - if isinstance(quota_driver_class, basestring): - quota_driver_class = importutils.import_object(quota_driver_class) - self._resources = {} - self._driver = quota_driver_class + self._driver_cls = quota_driver_class + self.__driver = None + + @property + def _driver(self): + if self.__driver: + return self.__driver + if not self._driver_cls: + self._driver_cls = CONF.quota_driver + if isinstance(self._driver_cls, basestring): + self._driver_cls = importutils.import_object(self._driver_cls) + self.__driver = self._driver_cls + return self.__driver def __contains__(self, resource): return resource in self._resources -- cgit