removed VnodeClient.popen
This commit is contained in:
parent
fc7a161221
commit
b5d71bab82
4 changed files with 3 additions and 32 deletions
|
@ -579,7 +579,6 @@ class CoreNode(CoreNodeBase):
|
||||||
:raises CoreCommandError: when a non-zero exit status occurs
|
:raises CoreCommandError: when a non-zero exit status occurs
|
||||||
"""
|
"""
|
||||||
if self.server is None:
|
if self.server is None:
|
||||||
logging.info("node(%s) cmd: %s", self.name, args)
|
|
||||||
return self.client.check_cmd(args, wait=wait)
|
return self.client.check_cmd(args, wait=wait)
|
||||||
else:
|
else:
|
||||||
args = self.client._cmd_args() + args
|
args = self.client._cmd_args() + args
|
||||||
|
|
|
@ -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.
|
The control channel can be accessed via calls using the vcmd shell.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
from subprocess import PIPE, Popen
|
|
||||||
|
|
||||||
from core import constants, utils
|
from core import constants, utils
|
||||||
from core.errors import CoreCommandError
|
|
||||||
|
|
||||||
|
|
||||||
class VnodeClient(object):
|
class VnodeClient(object):
|
||||||
|
@ -67,31 +64,10 @@ class VnodeClient(object):
|
||||||
:rtype: str
|
:rtype: str
|
||||||
:raises core.CoreCommandError: when there is a non-zero exit status
|
: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()
|
self._verify_connection()
|
||||||
args = utils.split_args(args)
|
args = utils.split_args(args)
|
||||||
cmd = self._cmd_args() + args
|
args = self._cmd_args() + args
|
||||||
logging.debug("popen: %s", cmd)
|
return utils.check_cmd(args, wait=wait)
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)
|
|
||||||
return p, p.stdin, p.stdout, p.stderr
|
|
||||||
|
|
||||||
def icmd(self, args):
|
def icmd(self, args):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -222,7 +222,7 @@ def check_cmd(args, env=None, cwd=None, wait=True):
|
||||||
execute is not found
|
execute is not found
|
||||||
"""
|
"""
|
||||||
args = split_args(args)
|
args = split_args(args)
|
||||||
logging.info("command: %s", args)
|
logging.info("command cwd(%s) wait(%s): %s", cwd, wait, args)
|
||||||
try:
|
try:
|
||||||
p = Popen(args, stdout=PIPE, stderr=PIPE, env=env, cwd=cwd)
|
p = Popen(args, stdout=PIPE, stderr=PIPE, env=env, cwd=cwd)
|
||||||
if wait:
|
if wait:
|
||||||
|
|
|
@ -108,13 +108,9 @@ class TestCore:
|
||||||
|
|
||||||
# check various command using vcmd module
|
# check various command using vcmd module
|
||||||
command = ["ls"]
|
command = ["ls"]
|
||||||
p, stdin, stdout, stderr = client.popen(command)
|
|
||||||
assert not p.wait()
|
|
||||||
assert not client.icmd(command)
|
assert not client.icmd(command)
|
||||||
|
|
||||||
# check various command using command line
|
# check various command using command line
|
||||||
p, stdin, stdout, stderr = client.popen(command)
|
|
||||||
assert not p.wait()
|
|
||||||
assert not client.icmd(command)
|
assert not client.icmd(command)
|
||||||
|
|
||||||
# check module methods
|
# check module methods
|
||||||
|
|
Loading…
Add table
Reference in a new issue