]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: allow passing a fail_msg param to process.run
authorAndrew Schoen <aschoen@redhat.com>
Thu, 18 Jan 2018 20:25:46 +0000 (14:25 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Thu, 18 Jan 2018 20:25:46 +0000 (14:25 -0600)
This will allow the user to provide a more detailed error message
on why the command failed.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
src/ceph-volume/ceph_volume/process.py

index 7bc97a99b2039be367708308ad3dd33cba3bfdcc..de935a3f96182fc9ad8361ebcfe7bf92a75ad1c3 100644 (file)
@@ -96,9 +96,11 @@ def run(command, **kw):
 
     :param command: The command to pass in to the remote subprocess.Popen as a list
     :param stop_on_error: If a nonzero exit status is return, it raises a ``RuntimeError``
+    :param fail_msg: If a nonzero exit status is returned this message will be included in the log
     """
     stop_on_error = kw.pop('stop_on_error', True)
     command_msg = obfuscate(command, kw.pop('obfuscate', None))
+    fail_msg = kw.pop('fail_msg', None)
     logger.info(command_msg)
     terminal.write(command_msg)
     terminal_logging = kw.pop('terminal_logging', True)
@@ -127,6 +129,10 @@ def run(command, **kw):
     returncode = process.wait()
     if returncode != 0:
         msg = "command returned non-zero exit status: %s" % returncode
+        if fail_msg:
+            logger.warning(fail_msg)
+            if terminal_logging:
+                terminal.warning(fail_msg)
         if stop_on_error:
             raise RuntimeError(msg)
         else: