diff --git a/daemon/core/nodes/base.py b/daemon/core/nodes/base.py index 6a3bebf0..120c53ca 100644 --- a/daemon/core/nodes/base.py +++ b/daemon/core/nodes/base.py @@ -579,7 +579,6 @@ class CoreNode(CoreNodeBase): :raises CoreCommandError: when a non-zero exit status occurs """ if self.server is None: - logging.info("node(%s) cmd: %s", self.name, args) return self.client.check_cmd(args, wait=wait) else: args = self.client._cmd_args() + args diff --git a/daemon/core/nodes/client.py b/daemon/core/nodes/client.py index 3b0b2843..13072c05 100644 --- a/daemon/core/nodes/client.py +++ b/daemon/core/nodes/client.py @@ -4,12 +4,9 @@ over a control channel to the vnoded process running in a network namespace. The control channel can be accessed via calls using the vcmd shell. """ -import logging import os -from subprocess import PIPE, Popen from core import constants, utils -from core.errors import CoreCommandError class VnodeClient(object): @@ -67,31 +64,10 @@ class VnodeClient(object): :rtype: str :raises core.CoreCommandError: when there is a non-zero exit status """ - p, stdin, stdout, stderr = self.popen(args) - stdin.close() - output = stdout.read() + stderr.read() - output = output.decode("utf-8").strip() - stdout.close() - stderr.close() - status = p.wait() - if wait and status != 0: - raise CoreCommandError(status, args, output) - return output - - def popen(self, args): - """ - Execute a popen command against the node. - - :param list[str]|str args: command arguments - :return: popen object, stdin, stdout, and stderr - :rtype: tuple - """ self._verify_connection() args = utils.split_args(args) - cmd = self._cmd_args() + args - logging.debug("popen: %s", cmd) - p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE) - return p, p.stdin, p.stdout, p.stderr + args = self._cmd_args() + args + return utils.check_cmd(args, wait=wait) def icmd(self, args): """ diff --git a/daemon/core/utils.py b/daemon/core/utils.py index df59f9ea..003c7134 100644 --- a/daemon/core/utils.py +++ b/daemon/core/utils.py @@ -222,7 +222,7 @@ def check_cmd(args, env=None, cwd=None, wait=True): execute is not found """ args = split_args(args) - logging.info("command: %s", args) + logging.info("command cwd(%s) wait(%s): %s", cwd, wait, args) try: p = Popen(args, stdout=PIPE, stderr=PIPE, env=env, cwd=cwd) if wait: diff --git a/daemon/tests/test_core.py b/daemon/tests/test_core.py index 7432ee58..4360ba06 100644 --- a/daemon/tests/test_core.py +++ b/daemon/tests/test_core.py @@ -108,13 +108,9 @@ class TestCore: # check various command using vcmd module command = ["ls"] - p, stdin, stdout, stderr = client.popen(command) - assert not p.wait() assert not client.icmd(command) # check various command using command line - p, stdin, stdout, stderr = client.popen(command) - assert not p.wait() assert not client.icmd(command) # check module methods