From d4fcdd0282977c32e9e7870c10e74dced9f1a34b Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 9 Feb 2012 18:00:36 -0800 Subject: [PATCH] Handling bad status returns better. --- devstack/components/db.py | 5 ++++- devstack/components/horizon.py | 2 ++ devstack/components/rabbit.py | 5 ++++- devstack/libvirt.py | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/devstack/components/db.py b/devstack/components/db.py index 4fc46bdf..5be2f294 100644 --- a/devstack/components/db.py +++ b/devstack/components/db.py @@ -279,9 +279,12 @@ class DBRuntime(comp.EmptyRuntime): def status(self): statuscmd = self._get_run_actions('status', excp.StatusException) - (sysout, stderr) = sh.execute(*statuscmd, + run_result = sh.execute(*statuscmd, check_exit_code=False, run_as_root=True) + if not run_result: + return comp.STATUS_UNKNOWN + (sysout, stderr) = run_result combined = str(sysout) + str(stderr) combined = combined.lower() if combined.find("running") != -1: diff --git a/devstack/components/horizon.py b/devstack/components/horizon.py index 6aae114a..40d7dec4 100644 --- a/devstack/components/horizon.py +++ b/devstack/components/horizon.py @@ -311,6 +311,8 @@ class HorizonRuntime(comp.EmptyRuntime): 'cmd': APACHE_STATUS_CMD, }) run_result = utils.execute_template(*cmds, params=mp, check_exit_code=False) + if not run_result or not run_result[0]: + return comp.STATUS_UNKNOWN (sysout, stderr) = run_result[0] combined = str(sysout) + str(stderr) combined = combined.lower() diff --git a/devstack/components/rabbit.py b/devstack/components/rabbit.py index ed84a99a..dc142b3c 100644 --- a/devstack/components/rabbit.py +++ b/devstack/components/rabbit.py @@ -102,9 +102,12 @@ class RabbitRuntime(comp.EmptyRuntime): def status(self): #this has got to be the worst status output #i have ever seen (its like a weird mix json+crap) - (sysout, stderr) = sh.execute(*STATUS_CMD, + run_result = sh.execute(*STATUS_CMD, check_exit_code=False, run_as_root=True) + if not run_result: + return comp.STATUS_UNKNOWN + (sysout, stderr) = run_result combined = str(sysout) + str(stderr) combined = combined.lower() if combined.find('nodedown') != -1 or combined.find("unable to connect to node") != -1: diff --git a/devstack/libvirt.py b/devstack/libvirt.py index 376c3cef..f713bdb1 100644 --- a/devstack/libvirt.py +++ b/devstack/libvirt.py @@ -79,6 +79,8 @@ def _status(distro): result = utils.execute_template(*cmds, check_exit_code=False, params=mp) + if not result or not result[0]: + return _DEAD (sysout, stderr) = result[0] combined = str(sysout) + str(stderr) combined = combined.lower()