diff --git a/systemvm/debian/opt/cloud/bin/cs/CsHelper.py b/systemvm/debian/opt/cloud/bin/cs/CsHelper.py index 5397038fd1e..241643d9956 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsHelper.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsHelper.py @@ -183,13 +183,19 @@ def get_hostname(): def execute(command): """ Execute command """ - p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - p.wait() - rc = p.returncode + returncode = -1 + try: + logging.info("Executing: %s" % command) + result = subprocess.check_output(command, shell=True) + returncode = 0 + return result.splitlines() + except subprocess.CalledProcessError as e: + logging.error(e) + returncode = e.returncode + finally: + logging.debug("Executed: %s - exitstatus=%s " % (command, returncode)) - logging.debug("Executed: %s - exitstatus=%s " % (command, rc)) - result = p.communicate()[0] - return result.splitlines() + return list() def save_iptables(command, iptables_file):