]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Run chef before operations that need it. 333/head
authorWarren Usui <warren.usui@inktank.com>
Wed, 17 Sep 2014 03:23:42 +0000 (20:23 -0700)
committerWarren Usui <warren.usui@inktank.com>
Wed, 17 Sep 2014 03:23:42 +0000 (20:23 -0700)
Chef, if it is needed, should be run before kernel tasks
and before all other user defined tasks.  It should not be
run by default.

Fixes: 9495
Signed-off-by: Warren Usui <warren.usui@inktank.com>
teuthology/task/internal.py

index f1744daf0400d9f63dcac1bf5af372d74e393013..546821ca19c07e5ed5df59a1a6b0ddb262280643 100644 (file)
@@ -16,6 +16,7 @@ from teuthology import lock
 from teuthology import misc
 from teuthology import provision
 from teuthology.config import config as teuth_config
+from teuthology.parallel import parallel
 from ..orchestra import cluster, remote, run
 
 log = logging.getLogger(__name__)
@@ -573,16 +574,34 @@ def vm_setup(ctx, config):
     """
     Look for virtual machines and handle their initialization
     """
-    editinfo = os.path.join(os.path.dirname(__file__),'edit_sudoers.sh')
-    for rem in ctx.cluster.remotes.iterkeys():
-        mname = rem.shortname
-        if misc.is_vm(mname):
-            r = rem.run(args=['test', '-e', '/ceph-qa-ready',],
-                    stdout=StringIO(),
-                    check_status=False,)
-            if r.returncode != 0:
-                p1 = subprocess.Popen(['cat', editinfo], stdout=subprocess.PIPE)
-                p2 = subprocess.Popen(['ssh', '-t', '-t', str(rem), 'sudo', 'sh'], stdin=p1.stdout, stdout=subprocess.PIPE)
-                _, err = p2.communicate()
-                if err:
-                    log.info("Edit of /etc/sudoers failed: %s", err)
+    all_tasks = [x.keys()[0] for x in ctx.config['tasks']]
+    need_chef = False
+    if 'chef' in all_tasks or 'kernel' in all_tasks:
+        need_chef = True
+    with parallel() as p:
+        editinfo = os.path.join(os.path.dirname(__file__),'edit_sudoers.sh')
+        for rem in ctx.cluster.remotes.iterkeys():
+            mname = rem.shortname
+            if misc.is_vm(mname):
+                r = rem.run(args=['test', '-e', '/ceph-qa-ready',],
+                        stdout=StringIO(),
+                        check_status=False,)
+                if r.returncode != 0:
+                    p1 = subprocess.Popen(['cat', editinfo], stdout=subprocess.PIPE)
+                    p2 = subprocess.Popen(['ssh', '-t', '-t', str(rem), 'sudo', 'sh'], stdin=p1.stdout, stdout=subprocess.PIPE)
+                    _, err = p2.communicate()
+                    if err:
+                        log.info("Edit of /etc/sudoers failed: %s", err)
+                    if need_chef:
+                        p.spawn(_download_and_run_chef, rem)
+
+def _download_and_run_chef(remote_):
+    """
+    Run ceph_qa_chef.
+    """
+    log.info('Running ceph_qa_chef on %s', remote_)
+    remote_.run(args=['wget', '-q', '-O-',
+            'http://ceph.com/git/?p=ceph-qa-chef.git;a=blob_plain;f=solo/solo-from-scratch;hb=HEAD',
+            run.Raw('|'),
+            'sh',
+        ])