]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move internal.vm_setup to its own module
authorZack Cerza <zack@redhat.com>
Thu, 17 Mar 2016 21:47:13 +0000 (15:47 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 1 Nov 2016 22:46:54 +0000 (16:46 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/task/internal/__init__.py
teuthology/task/internal/vm_setup.py [new file with mode: 0644]

index 89bcef96502ef592014f363d4205bd66d922272f..475d68e700f78bfd4412c8cd4cdcacb60f4039e8 100644 (file)
@@ -19,8 +19,6 @@ from teuthology.config import config as teuth_config
 from teuthology.exceptions import VersionNotFoundError
 from teuthology.job_status import get_status, set_status
 from teuthology.orchestra import cluster, remote, run
-from teuthology.parallel import parallel
-from teuthology.task import ansible
 
 log = logging.getLogger(__name__)
 
@@ -632,45 +630,3 @@ def syslog(ctx, config):
                 wait=False,
             ),
         )
-
-
-def vm_setup(ctx, config):
-    """
-    Look for virtual machines and handle their initialization
-    """
-    all_tasks = [x.keys()[0] for x in ctx.config['tasks']]
-    need_ansible = False
-    if 'kernel' in all_tasks and 'ansible.cephlab' not in all_tasks:
-        need_ansible = True
-    ansible_hosts = set()
-    with parallel():
-        editinfo = os.path.join(os.path.dirname(__file__), 'edit_sudoers.sh')
-        for rem in ctx.cluster.remotes.iterkeys():
-            if misc.is_vm(rem.shortname):
-                ansible_hosts.add(rem.shortname)
-                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',
-                            '-o', 'StrictHostKeyChecking=no',
-                            '-t', '-t',
-                            str(rem),
-                            'sudo',
-                            'sh'
-                        ],
-                        stdin=p1.stdout, stdout=subprocess.PIPE
-                    )
-                    _, err = p2.communicate()
-                    if err:
-                        log.error("Edit of /etc/sudoers failed: %s", err)
-    if need_ansible and ansible_hosts:
-        log.info("Running ansible on %s", list(ansible_hosts))
-        ansible_config = dict(
-            hosts=list(ansible_hosts),
-        )
-        with ansible.CephLab(ctx, config=ansible_config):
-            pass
diff --git a/teuthology/task/internal/vm_setup.py b/teuthology/task/internal/vm_setup.py
new file mode 100644 (file)
index 0000000..91eece3
--- /dev/null
@@ -0,0 +1,54 @@
+import logging
+import os
+import subprocess
+
+from cStringIO import StringIO
+
+from teuthology import misc
+
+from teuthology.parallel import parallel
+from teuthology.task import ansible
+
+log = logging.getLogger(__name__)
+
+
+def vm_setup(ctx, config):
+    """
+    Look for virtual machines and handle their initialization
+    """
+    all_tasks = [x.keys()[0] for x in ctx.config['tasks']]
+    need_ansible = False
+    if 'kernel' in all_tasks and 'ansible.cephlab' not in all_tasks:
+        need_ansible = True
+    ansible_hosts = set()
+    with parallel():
+        editinfo = os.path.join(os.path.dirname(__file__), 'edit_sudoers.sh')
+        for rem in ctx.cluster.remotes.iterkeys():
+            if misc.is_vm(rem.shortname):
+                ansible_hosts.add(rem.shortname)
+                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',
+                            '-o', 'StrictHostKeyChecking=no',
+                            '-t', '-t',
+                            str(rem),
+                            'sudo',
+                            'sh'
+                        ],
+                        stdin=p1.stdout, stdout=subprocess.PIPE
+                    )
+                    _, err = p2.communicate()
+                    if err:
+                        log.error("Edit of /etc/sudoers failed: %s", err)
+    if need_ansible and ansible_hosts:
+        log.info("Running ansible on %s", list(ansible_hosts))
+        ansible_config = dict(
+            hosts=list(ansible_hosts),
+        )
+        with ansible.CephLab(ctx, config=ansible_config):
+            pass