Circular import between preseed.py and models/node.py

Bug #1373477 reported by Jason Hobbs on 2014-09-24
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Critical
Jason Hobbs

Bug Description

r3070 introduced a circular import between src/maasserver/models/node.py and src/maasserver/preseed.py. For some reason it doesn't show up in the normal unit tests, but it does if you run a subset of the unit tests:

ubuntu@maas-dev:~/upstream$ ./bin/test.maas /home/ubuntu/add-disk-erase-user-data/src/metadataserver/user_data/
nosetests /home/ubuntu/add-disk-erase-user-data/src/metadataserver/user_data/ --exclude=provisioningserver --exclude=maastesting --exclude=maascli --verbosity=1
Creating test database for alias 'default'...
.......E
======================================================================
ERROR: Failure: ImportError (cannot import name get_preseed_type_for)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 411, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/ubuntu/add-disk-erase-user-data/src/metadataserver/user_data/tests/test_user_data.py", line 17, in <module>
    from maasserver.preseed import get_preseed_context
  File "/home/ubuntu/upstream/src/maasserver/preseed.py", line 35, in <module>
    from maasserver.clusterrpc.boot_images import get_boot_images_for
  File "/home/ubuntu/upstream/src/maasserver/clusterrpc/boot_images.py", line 20, in <module>
    from maasserver.models import BootResource
  File "/home/ubuntu/upstream/src/maasserver/models/__init__.py", line 62, in <module>
    from maasserver.models.event import Event
  File "/home/ubuntu/upstream/src/maasserver/models/event.py", line 29, in <module>
    from maasserver.models.node import Node
  File "/home/ubuntu/upstream/src/maasserver/models/node.py", line 101, in <module>
    from maasserver.preseed import get_preseed_type_for
ImportError: cannot import name get_preseed_type_for

----------------------------------------------------------------------
Ran 8 tests in 0.018s

FAILED (errors=1)
Destroying test database for alias 'default'...

Related branches

Changed in maas:
assignee: nobody → Jason Hobbs (jason-hobbs)
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: none → 1.7.0
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers