load_modules fails if quantum code is in the search path

Bug #1085725 reported by Steve Baker
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Undecided
Zane Bitter
Grizzly
Fix Released
Undecided
Zane Bitter

Bug Description

============================= ERRORS =============================
Traceback (most recent call last):
  File "/usr/lib64/python2.7/unittest/case.py", line 365, in run
    testMethod()
  File "/home/steveb/dev/localstack/heat/.tox/py27/build/nose/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/steveb/dev/localstack/heat/.tox/py27/build/nose/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/steveb/dev/localstack/heat/.tox/py27/build/nose/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/steveb/dev/localstack/heat/heat/tests/test_quantum.py", line 30, in <module>
    from heat.engine.resources.quantum import net
  File "/home/steveb/dev/localstack/heat/heat/engine/resources/__init__.py", line 54, in <module>
    _initialise()
  File "/home/steveb/dev/localstack/heat/heat/engine/resources/__init__.py", line 45, in _initialise
    _register_modules(plugin_loader.load_modules(sys.modules[__name__]))
  File "/home/steveb/dev/localstack/heat/heat/engine/resources/__init__.py", line 38, in _register_modules
    _register_resources(itertools.chain.from_iterable(resource_lists))
  File "/home/steveb/dev/localstack/heat/heat/engine/resources/__init__.py", line 20, in _register_resources
    for res_name, res_class in type_pairs:
  File "/home/steveb/dev/localstack/heat/heat/engine/resources/__init__.py", line 37, in <genexpr>
    resource_lists = (_get_module_resources(m) for m in modules)
  File "/home/steveb/dev/localstack/heat/heat/common/plugin_loader.py", line 84, in load_modules
    module = _import_module(importer, module_name, package)
  File "/home/steveb/dev/localstack/heat/heat/common/plugin_loader.py", line 73, in _import_module
    module = loader.load_module(fullname)
  File "/usr/lib64/python2.7/pkgutil.py", line 246, in load_module
    mod = imp.load_module(fullname, self.file, self.filename, self.etc)
  File "/home/steveb/dev/localstack/quantum/quantum/auth.py", line 20, in <module>
    from quantum import context
ImportError: cannot import name context
-------------------- >> begin captured logging << --------------------
heat.engine.resource: INFO: Registering resource type AWS::AutoScaling::ScalingPolicy
heat.engine.resource: INFO: Registering resource type AWS::AutoScaling::AutoScalingGroup
heat.engine.resource: INFO: Registering resource type AWS::AutoScaling::LaunchConfiguration
heat.engine.resource: INFO: Registering resource type AWS::CloudWatch::Alarm
heat.engine.resource: INFO: Registering resource type AWS::RDS::DBInstance
heat.engine.resource: INFO: Registering resource type AWS::EC2::EIP
heat.engine.resource: INFO: Registering resource type AWS::EC2::EIPAssociation
heat.engine.resource: INFO: Registering resource type AWS::EC2::Instance
heat.engine.resource: INFO: Registering resource type HEAT::HA::Restarter
heat.engine.resource: INFO: Registering resource type AWS::ElasticLoadBalancing::LoadBalancer
heat.common.plugin_loader: ERROR: Failed to import module quantum.auth
--------------------- >> end captured logging << ---------------------

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/17485

Changed in heat:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/17485
Committed: http://github.com/openstack/heat/commit/8a3a8d6fe4a8680126a62f90f619da5093c937e4
Submitter: Jenkins
Branch: master

commit 8a3a8d6fe4a8680126a62f90f619da5093c937e4
Author: Zane Bitter <email address hidden>
Date: Wed Dec 5 11:15:42 2012 +0100

    Fix importing of quantum resources subpackage

    Apparently pkgutil.walk_packages(path) will return packages outside the
    given path if they have the same names as the ones inside - so having a
    quantum subpackage results in importing the global quantum package from
    Quantum itself instead. Fix this by passing a package prefix to give a
    fully qualified name.

    Also make sure that submodules are added as an attribute to their immediate
    parent package, not to some grandparent package with '.'s in the attribute
    name.

    bug 1085725

    Change-Id: Ie571100898a33ed4fe15d1878c7b16db4caf4fa5
    Signed-off-by: Zane Bitter <email address hidden>

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: grizzly-2 → 2013.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.