]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
provision: invoke downburst with -v and --logfile
authorDan Mick <dan.mick@redhat.com>
Mon, 6 Mar 2017 23:40:05 +0000 (15:40 -0800)
committerDan Mick <dan.mick@redhat.com>
Mon, 6 Mar 2017 23:54:02 +0000 (15:54 -0800)
Verbose output isn't verbose enough to matter, and can be helpful
tracking down weirdness.  Also, log to private file in case
downburst hangs mid-operation, to avoid having to do any
select() madness in teuthology.

Signed-off-by: Dan Mick <dan.mick@redhat.com>
teuthology/provision/__init__.py
teuthology/provision/downburst.py

index 8c81e5bd27db1fc84aa766bea1a5f705c1a1f6f7..b7b535962d93b8b945ca0b8c29f6404626cc80d5 100644 (file)
@@ -6,11 +6,18 @@ from ..misc import decanonicalize_hostname, get_distro, get_distro_version
 import cloud
 import downburst
 import openstack
+import os
 
 
 log = logging.getLogger(__name__)
 
 
+def _logfile(ctx, shortname):
+    if (ctx.config.get('archive_path')):
+        return os.path.join(ctx.config['archive_path'],
+                            shortname + '.downburst.log')
+
+
 def create_if_vm(ctx, machine_name, _downburst=None):
     """
     Use downburst to create a virtual machine
@@ -45,7 +52,8 @@ def create_if_vm(ctx, machine_name, _downburst=None):
 
     dbrst = _downburst or \
         downburst.Downburst(name=machine_name, os_type=os_type,
-                            os_version=os_version, status=status_info)
+                            os_version=os_version, status=status_info,
+                            logfile=_logfile(ctx, shortname))
     return dbrst.create()
 
 
@@ -87,5 +95,6 @@ def destroy_if_vm(ctx, machine_name, user=None, description=None,
 
     dbrst = _downburst or \
         downburst.Downburst(name=machine_name, os_type=None,
-                            os_version=None, status=status_info)
+                            os_version=None, status=status_info,
+                            logfile=_logfile(ctx, shortname))
     return dbrst.destroy()
index b973c6f0b46f9d592ac46d6be6ca00941970d86f..514f38b65ef43ebf7061bb382fa096a60c74af5c 100644 (file)
@@ -42,7 +42,8 @@ class Downburst(object):
     A class that provides methods for creating and destroying virtual machine
     instances using downburst: https://github.com/ceph/downburst
     """
-    def __init__(self, name, os_type, os_version, status=None, user='ubuntu'):
+    def __init__(self, name, os_type, os_version, status=None, user='ubuntu',
+                 logfile=None):
         self.name = name
         self.shortname = decanonicalize_hostname(self.name)
         self.os_type = os_type
@@ -51,6 +52,7 @@ class Downburst(object):
         self.config_path = None
         self.user_path = None
         self.user = user
+        self.logfile = logfile
         self.host = decanonicalize_hostname(self.status['vm_host']['name'])
         self.executable = downburst_executable()
 
@@ -100,15 +102,16 @@ class Downburst(object):
         if not self.user_path:
             raise ValueError("I need a user_path!")
 
-        args = [
-            self.executable,
-            '-c', self.host,
+        args = [self.executable, '-v', '-c', self.host]
+        if self.logfile:
+            args.extend(['-l', self.logfile])
+        args.extend([
             'create',
             '--wait',
             '--meta-data=%s' % self.config_path,
             '--user-data=%s' % self.user_path,
             self.shortname,
-        ]
+        ])
         log.info("Provisioning a {distro} {distroversion} vps".format(
             distro=self.os_type,
             distroversion=self.os_version
@@ -126,7 +129,10 @@ class Downburst(object):
         if not executable:
             log.error("No downburst executable found.")
             return False
-        args = [executable, '-c', self.host, 'destroy', self.shortname]
+        args = [executable, '-v', '-c', self.host]
+        if self.logfile:
+            args.extend(['-l', self.logfile])
+        args.extend(['destroy', self.shortname])
         proc = subprocess.Popen(args, stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,)
         out, err = proc.communicate()