removed redircmd, shcmd, shcmd_result, getaddr, netifstats from VnodeClient
This commit is contained in:
parent
223590c8fb
commit
af7faa85df
5 changed files with 5 additions and 75 deletions
|
@ -17,7 +17,6 @@ from socket import AF_INET, AF_INET6
|
||||||
from core import constants, utils
|
from core import constants, utils
|
||||||
from core.emulator.data import LinkData, NodeData
|
from core.emulator.data import LinkData, NodeData
|
||||||
from core.emulator.enumerations import LinkTypes, NodeTypes
|
from core.emulator.enumerations import LinkTypes, NodeTypes
|
||||||
from core.errors import CoreCommandError
|
|
||||||
from core.nodes import client, ipaddress
|
from core.nodes import client, ipaddress
|
||||||
from core.nodes.interface import CoreInterface, TunTap, Veth
|
from core.nodes.interface import CoreInterface, TunTap, Veth
|
||||||
from core.nodes.netclient import LinuxNetClient, OvsNetClient
|
from core.nodes.netclient import LinuxNetClient, OvsNetClient
|
||||||
|
@ -636,15 +635,8 @@ class CoreNode(CoreNodeBase):
|
||||||
"""
|
"""
|
||||||
source = os.path.abspath(source)
|
source = os.path.abspath(source)
|
||||||
logging.debug("node(%s) mounting: %s at %s", self.name, source, target)
|
logging.debug("node(%s) mounting: %s at %s", self.name, source, target)
|
||||||
cmd = 'mkdir -p "%s" && %s -n --bind "%s" "%s"' % (
|
self.client.check_cmd(["mkdir", "-p", target])
|
||||||
target,
|
self.client.check_cmd([constants.MOUNT_BIN, "-n", "--bind", source, target])
|
||||||
constants.MOUNT_BIN,
|
|
||||||
source,
|
|
||||||
target,
|
|
||||||
)
|
|
||||||
status, output = self.client.shcmd_result(cmd)
|
|
||||||
if status:
|
|
||||||
raise CoreCommandError(status, cmd, output)
|
|
||||||
self._mounts.append((source, target))
|
self._mounts.append((source, target))
|
||||||
|
|
||||||
def newifindex(self):
|
def newifindex(self):
|
||||||
|
@ -901,11 +893,9 @@ class CoreNode(CoreNodeBase):
|
||||||
"""
|
"""
|
||||||
logging.info("adding file from %s to %s", srcname, filename)
|
logging.info("adding file from %s to %s", srcname, filename)
|
||||||
directory = os.path.dirname(filename)
|
directory = os.path.dirname(filename)
|
||||||
|
self.client.check_cmd(["mkdir", "-p", directory])
|
||||||
cmd = 'mkdir -p "%s" && mv "%s" "%s" && sync' % (directory, srcname, filename)
|
self.client.check_cmd(["mv", srcname, filename])
|
||||||
status, output = self.client.shcmd_result(cmd)
|
self.client.check_cmd(["sync"])
|
||||||
if status:
|
|
||||||
raise CoreCommandError(status, cmd, output)
|
|
||||||
|
|
||||||
def hostfilename(self, filename):
|
def hostfilename(self, filename):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -145,36 +145,6 @@ class VnodeClient(object):
|
||||||
*args
|
*args
|
||||||
)
|
)
|
||||||
|
|
||||||
def redircmd(self, infd, outfd, errfd, args, wait=True):
|
|
||||||
"""
|
|
||||||
Execute a command on a node with standard input, output, and
|
|
||||||
error redirected according to the given file descriptors.
|
|
||||||
|
|
||||||
:param infd: stdin file descriptor
|
|
||||||
:param outfd: stdout file descriptor
|
|
||||||
:param errfd: stderr file descriptor
|
|
||||||
:param list[str]|str args: command arguments
|
|
||||||
:param bool wait: wait flag
|
|
||||||
:return: command status
|
|
||||||
:rtype: int
|
|
||||||
"""
|
|
||||||
self._verify_connection()
|
|
||||||
|
|
||||||
# run command, return process when not waiting
|
|
||||||
args = utils.split_args(args)
|
|
||||||
cmd = self._cmd_args() + args
|
|
||||||
logging.debug("redircmd: %s", cmd)
|
|
||||||
p = Popen(cmd, stdin=infd, stdout=outfd, stderr=errfd)
|
|
||||||
|
|
||||||
if not wait:
|
|
||||||
return p
|
|
||||||
|
|
||||||
# wait for and return exit status
|
|
||||||
status = p.wait()
|
|
||||||
if status:
|
|
||||||
logging.warning("cmd exited with status %s: %s", status, args)
|
|
||||||
return status
|
|
||||||
|
|
||||||
def term(self, sh="/bin/sh"):
|
def term(self, sh="/bin/sh"):
|
||||||
"""
|
"""
|
||||||
Open a terminal on a node.
|
Open a terminal on a node.
|
||||||
|
@ -214,25 +184,3 @@ class VnodeClient(object):
|
||||||
:return: str
|
:return: str
|
||||||
"""
|
"""
|
||||||
return "%s -c %s -- %s" % (constants.VCMD_BIN, self.ctrlchnlname, sh)
|
return "%s -c %s -- %s" % (constants.VCMD_BIN, self.ctrlchnlname, sh)
|
||||||
|
|
||||||
def shcmd(self, cmd, sh="/bin/sh"):
|
|
||||||
"""
|
|
||||||
Execute a shell command.
|
|
||||||
|
|
||||||
:param str cmd: command string
|
|
||||||
:param str sh: shell to run command in
|
|
||||||
:return: command result
|
|
||||||
:rtype: int
|
|
||||||
"""
|
|
||||||
return self.cmd([sh, "-c", cmd])
|
|
||||||
|
|
||||||
def shcmd_result(self, cmd, sh="/bin/sh"):
|
|
||||||
"""
|
|
||||||
Execute a shell command and return the exist status and combined output.
|
|
||||||
|
|
||||||
:param str cmd: shell command to run
|
|
||||||
:param str sh: shell to run command in
|
|
||||||
:return: exist status and combined output
|
|
||||||
:rtype: tuple[int, str]
|
|
||||||
"""
|
|
||||||
return self.cmd_output([sh, "-c", cmd])
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ class DockerClient(object):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.image = image
|
self.image = image
|
||||||
self.pid = None
|
self.pid = None
|
||||||
self._addr = {}
|
|
||||||
|
|
||||||
def create_container(self):
|
def create_container(self):
|
||||||
utils.check_cmd(
|
utils.check_cmd(
|
||||||
|
|
|
@ -14,7 +14,6 @@ class LxdClient(object):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.image = image
|
self.image = image
|
||||||
self.pid = None
|
self.pid = None
|
||||||
self._addr = {}
|
|
||||||
|
|
||||||
def create_container(self):
|
def create_container(self):
|
||||||
utils.check_cmd(
|
utils.check_cmd(
|
||||||
|
|
|
@ -4,7 +4,6 @@ Unit tests for testing basic CORE networks.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import subprocess
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -109,10 +108,6 @@ class TestCore:
|
||||||
p, stdin, stdout, stderr = client.popen(command)
|
p, stdin, stdout, stderr = client.popen(command)
|
||||||
assert not p.wait()
|
assert not p.wait()
|
||||||
assert not client.icmd(command)
|
assert not client.icmd(command)
|
||||||
assert not client.redircmd(
|
|
||||||
subprocess.PIPE, subprocess.PIPE, subprocess.PIPE, command
|
|
||||||
)
|
|
||||||
assert not client.shcmd(command[0])
|
|
||||||
|
|
||||||
# check various command using command line
|
# check various command using command line
|
||||||
assert not client.cmd(command)
|
assert not client.cmd(command)
|
||||||
|
@ -121,7 +116,6 @@ class TestCore:
|
||||||
p, stdin, stdout, stderr = client.popen(command)
|
p, stdin, stdout, stderr = client.popen(command)
|
||||||
assert not p.wait()
|
assert not p.wait()
|
||||||
assert not client.icmd(command)
|
assert not client.icmd(command)
|
||||||
assert not client.shcmd(command[0])
|
|
||||||
|
|
||||||
# check module methods
|
# check module methods
|
||||||
assert createclients(session.session_dir)
|
assert createclients(session.session_dir)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue