]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Discriminate loaded extensions using their alias
authorSalvatore Orlando <salv.orlando@gmail.com>
Mon, 2 Feb 2015 17:08:17 +0000 (09:08 -0800)
committerSalvatore Orlando <salv.orlando@gmail.com>
Mon, 2 Feb 2015 17:17:33 +0000 (09:17 -0800)
This patch simply changes the logic for discriminating which
extensions have already been loaded using the extension alias
rather than the module name.

This will avoid failures already observed in unit tests occurring
if two extension modules happen to have the same module file name
even if they're unrelated.

This change cannot be unit-tested as the neutron unit test
framework is currently lacking a mechanism to mock and validate
extension loading from the file system.

Closes-Bug: #1417180

Change-Id: Ia214a7c5b1127dbbec3c81023fdbc48d7fadf18f

neutron/api/extensions.py

index b1294e155ea201915e8027008370098e9617d528..ea045b5ec81dc4cd2613755b71783f4b4d85ce8a 100644 (file)
@@ -546,7 +546,6 @@ class ExtensionManager(object):
                                  mod_name)
                         continue
                     mod = imp.load_source(mod_name, ext_path)
-                    loaded.append(mod_name)
                     ext_name = mod_name[0].upper() + mod_name[1:]
                     new_ext_class = getattr(mod, ext_name, None)
                     if not new_ext_class:
@@ -557,6 +556,7 @@ class ExtensionManager(object):
                         continue
                     new_ext = new_ext_class()
                     self.add_extension(new_ext)
+                    loaded.append(new_ext_class.get_alias())
             except Exception as exception:
                 LOG.warn(_LW("Extension file %(f)s wasn't loaded due to "
                              "%(exception)s"),