Move CommandFailed exception to tempest.exceptions
When the CommandFailed exception was added it was only being used by
the CLI tests. However, it is generally useful for anything that is
using subprocess to make external calls. This patch moves it to
tempest.exceptions to make using it simpler for non-cli tests to use
the exception.
Change-Id: Ibf5f1cbbb847d32976b54c4484acfc3c0e3b4f48
diff --git a/tempest/cli/__init__.py b/tempest/cli/__init__.py
index d7b4a16..02f8c05 100644
--- a/tempest/cli/__init__.py
+++ b/tempest/cli/__init__.py
@@ -19,6 +19,7 @@
import tempest.cli.output_parser
from tempest import config
+from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
@@ -130,10 +131,10 @@
cmd, stdout=stdout, stderr=stderr)
result, result_err = proc.communicate()
if not fail_ok and proc.returncode != 0:
- raise CommandFailed(proc.returncode,
- cmd,
- result,
- result_err)
+ raise exceptions.CommandFailed(proc.returncode,
+ cmd,
+ result,
+ result_err)
return result
def assertTableStruct(self, items, field_names):
@@ -146,17 +147,3 @@
self.assertTrue(lines[0].startswith(beginning),
msg=('Beginning of first line has invalid content: %s'
% lines[:3]))
-
-
-class CommandFailed(Exception):
- def __init__(self, returncode, cmd, output, stderr):
- super(CommandFailed, self).__init__()
- self.returncode = returncode
- self.cmd = cmd
- self.stdout = output
- self.stderr = stderr
-
- def __str__(self):
- return ("Command '%s' returned non-zero exit status %d.\n"
- "stdout:\n%s\n"
- "stderr:\n%s" % (self.cmd, self.returncode, self.stdout, self.stderr))