Fix SimpleReadOnlyNovaManageTest.test_flavor_list CLI test
'nova-manage flavor list' should equal 'nova-manage instance_type list'
Adds an option, merge_stderr, that when enabled redirects stderr to
stdout.
Fix bug 1159914
Change-Id: Icfb93f3fd1f1d6f14a73b4873a6dad36122d3a98
diff --git a/cli/__init__.py b/cli/__init__.py
index 6ffe229..e244811 100644
--- a/cli/__init__.py
+++ b/cli/__init__.py
@@ -60,10 +60,11 @@
return self.cmd_with_auth(
'nova', action, flags, params, admin, fail_ok)
- def nova_manage(self, action, flags='', params='', fail_ok=False):
+ def nova_manage(self, action, flags='', params='', fail_ok=False,
+ merge_stderr=True):
"""Executes nova-manage command for the given action."""
return self.cmd(
- 'nova-manage', action, flags, params, fail_ok)
+ 'nova-manage', action, flags, params, fail_ok, merge_stderr)
def keystone(self, action, flags='', params='', admin=True, fail_ok=False):
"""Executes keystone command for the given action."""
@@ -81,14 +82,19 @@
flags = creds + ' ' + flags
return self.cmd(cmd, action, flags, params, fail_ok)
- def cmd(self, cmd, action, flags='', params='', fail_ok=False):
+ def cmd(self, cmd, action, flags='', params='', fail_ok=False,
+ merge_stderr=True):
+ #TODO(jogo): make merge_stderr default to False.
"""Executes specified command for the given action."""
cmd = ' '.join([CONF.cli.cli_dir + cmd,
flags, action, params])
LOG.info("running: '%s'" % cmd)
cmd = shlex.split(cmd)
try:
- result = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+ if merge_stderr:
+ result = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+ else:
+ result = subprocess.check_output(cmd)
except subprocess.CalledProcessError, e:
LOG.error("command output:\n%s" % e.output)
raise