diff options
| author | Soren Hansen <soren@linux2go.dk> | 2011-03-28 20:30:56 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-03-28 20:30:56 +0000 |
| commit | 848c8212a4c9c53f0e2a6b4154fb9504b95db060 (patch) | |
| tree | 94913fdeb0b5dd3af07979c4c6a3b8daa0e87aa5 /nova/api | |
| parent | 616d4dc27d960c2c5a95fb5121d69151cc3638f9 (diff) | |
| parent | 7040eadcc7e86d063c5c69391dedafa181711913 (diff) | |
Toss an __init__ in the test extensions dir. This gets it included in the tarball.
Make extensions code ignore modules whose name starts with '_'.
Warn if an extension doesn't define a class or factory by the right name.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/extensions.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py index 9d98d849a..b9b7f998d 100644 --- a/nova/api/openstack/extensions.py +++ b/nova/api/openstack/extensions.py @@ -317,16 +317,19 @@ class ExtensionManager(object): LOG.audit(_('Loading extension file: %s'), f) mod_name, file_ext = os.path.splitext(os.path.split(f)[-1]) ext_path = os.path.join(self.path, f) - if file_ext.lower() == '.py': + if file_ext.lower() == '.py' and not mod_name.startswith('_'): mod = imp.load_source(mod_name, ext_path) ext_name = mod_name[0].upper() + mod_name[1:] - try: - new_ext = getattr(mod, ext_name)() - self._check_extension(new_ext) - self.extensions[new_ext.get_alias()] = new_ext - except AttributeError as ex: - LOG.exception(_("Exception loading extension: %s"), - unicode(ex)) + new_ext_class = getattr(mod, ext_name, None) + if not new_ext_class: + LOG.warn(_('Did not find expected name ' + '"%(ext_name)" in %(file)s'), + {'ext_name': ext_name, + 'file': ext_path}) + continue + new_ext = new_ext_class() + self._check_extension(new_ext) + self.extensions[new_ext.get_alias()] = new_ext class ResponseExtension(object): |
