]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Correctly find both internal and external tasks
authorZack Cerza <zack@cerza.org>
Fri, 25 Jul 2014 22:07:59 +0000 (16:07 -0600)
committerZack Cerza <zack.cerza@inktank.com>
Wed, 6 Aug 2014 16:06:35 +0000 (10:06 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/run_tasks.py

index ada99d0256795ba545ab8a2364ac729f33c75002..7fdf217faddc4b0c9cbaeb453fffee3848363e94 100644 (file)
@@ -8,6 +8,19 @@ from copy import deepcopy
 log = logging.getLogger(__name__)
 
 
+def import_task(name):
+    internal_pkg = __import__('teuthology.task', globals(), locals(),
+                         [name], 0)
+    if hasattr(internal_pkg, name):
+        return getattr(internal_pkg, name)
+    else:
+        external_pkg = __import__('tasks', globals(), locals(),
+                                  [name], 0)
+    if hasattr(external_pkg, name):
+        return getattr(external_pkg, name)
+    raise ImportError("Could not find task '%'" % name)
+
+
 def run_one_task(taskname, **kwargs):
     submod = taskname
     subtask = 'task'
@@ -17,14 +30,9 @@ def run_one_task(taskname, **kwargs):
     # Teuthology configs may refer to modules like ceph_deploy as ceph-deploy
     submod = submod.replace('-', '_')
 
-    parent = __import__('teuthology.task', globals(), locals(), [submod], 0)
-    try:
-        mod = getattr(parent, submod)
-    except AttributeError:
-        log.error("No task named %s was found", submod)
-        raise
+    task = import_task(submod)
     try:
-        fn = getattr(mod, subtask)
+        fn = getattr(task, subtask)
     except AttributeError:
         log.error("No subtask of %s named %s was found", mod, subtask)
         raise