removed VnodeClient.icmd and VnodeClient.term
This commit is contained in:
parent
b5d71bab82
commit
69772f993c
3 changed files with 2 additions and 85 deletions
|
@ -4,8 +4,6 @@ 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 os
|
||||
|
||||
from core import constants, utils
|
||||
|
||||
|
||||
|
@ -69,56 +67,6 @@ class VnodeClient(object):
|
|||
args = self._cmd_args() + args
|
||||
return utils.check_cmd(args, wait=wait)
|
||||
|
||||
def icmd(self, args):
|
||||
"""
|
||||
Execute an icmd against a node.
|
||||
|
||||
:param list[str]|str args: command arguments
|
||||
:return: command result
|
||||
:rtype: int
|
||||
"""
|
||||
args = utils.split_args(args)
|
||||
return os.spawnlp(
|
||||
os.P_WAIT,
|
||||
constants.VCMD_BIN,
|
||||
constants.VCMD_BIN,
|
||||
"-c",
|
||||
self.ctrlchnlname,
|
||||
"--",
|
||||
*args
|
||||
)
|
||||
|
||||
def term(self, sh="/bin/sh"):
|
||||
"""
|
||||
Open a terminal on a node.
|
||||
|
||||
:param str sh: shell to open terminal with
|
||||
:return: terminal command result
|
||||
:rtype: int
|
||||
"""
|
||||
args = (
|
||||
"xterm",
|
||||
"-ut",
|
||||
"-title",
|
||||
self.name,
|
||||
"-e",
|
||||
constants.VCMD_BIN,
|
||||
"-c",
|
||||
self.ctrlchnlname,
|
||||
"--",
|
||||
sh,
|
||||
)
|
||||
if "SUDO_USER" in os.environ:
|
||||
args = (
|
||||
"su",
|
||||
"-s",
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"exec " + " ".join(map(lambda x: "'%s'" % x, args)),
|
||||
os.environ["SUDO_USER"],
|
||||
)
|
||||
return os.spawnvp(os.P_NOWAIT, args[0], args)
|
||||
|
||||
def termcmdstring(self, sh="/bin/sh"):
|
||||
"""
|
||||
Create a terminal command string.
|
||||
|
|
|
@ -40,10 +40,6 @@ def example(options):
|
|||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# start a shell on the first node
|
||||
node = session.get_node(2)
|
||||
node.client.term("bash")
|
||||
|
||||
# shutdown session
|
||||
input("press enter to exit...")
|
||||
coreemu.shutdown()
|
||||
|
|
|
@ -3,7 +3,6 @@ Unit tests for testing basic CORE networks.
|
|||
"""
|
||||
|
||||
import os
|
||||
import stat
|
||||
import threading
|
||||
|
||||
import pytest
|
||||
|
@ -12,31 +11,12 @@ from core.emulator.emudata import NodeOptions
|
|||
from core.emulator.enumerations import MessageFlags, NodeTypes
|
||||
from core.errors import CoreCommandError
|
||||
from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility
|
||||
from core.nodes.client import VnodeClient
|
||||
|
||||
_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||
_MOBILITY_FILE = os.path.join(_PATH, "mobility.scen")
|
||||
_WIRED = [NodeTypes.PEER_TO_PEER, NodeTypes.HUB, NodeTypes.SWITCH]
|
||||
|
||||
|
||||
def createclients(sessiondir, clientcls=VnodeClient, cmdchnlfilterfunc=None):
|
||||
"""
|
||||
Create clients
|
||||
|
||||
:param str sessiondir: session directory to create clients
|
||||
:param class clientcls: class to create clients from
|
||||
:param func cmdchnlfilterfunc: command channel filter function
|
||||
:return: list of created clients
|
||||
:rtype: list
|
||||
"""
|
||||
direntries = map(lambda x: os.path.join(sessiondir, x), os.listdir(sessiondir))
|
||||
cmdchnls = list(filter(lambda x: stat.S_ISSOCK(os.stat(x).st_mode), direntries))
|
||||
if cmdchnlfilterfunc:
|
||||
cmdchnls = list(filter(cmdchnlfilterfunc, cmdchnls))
|
||||
cmdchnls.sort()
|
||||
return map(lambda x: clientcls(os.path.basename(x), x), cmdchnls)
|
||||
|
||||
|
||||
def ping(from_node, to_node, ip_prefixes):
|
||||
address = ip_prefixes.ip4_address(to_node)
|
||||
try:
|
||||
|
@ -106,15 +86,8 @@ class TestCore:
|
|||
# check we are connected
|
||||
assert client.connected()
|
||||
|
||||
# check various command using vcmd module
|
||||
command = ["ls"]
|
||||
assert not client.icmd(command)
|
||||
|
||||
# check various command using command line
|
||||
assert not client.icmd(command)
|
||||
|
||||
# check module methods
|
||||
assert createclients(session.session_dir)
|
||||
# validate command
|
||||
assert client.check_cmd("echo hello") == "hello"
|
||||
|
||||
def test_netif(self, session, ip_prefixes):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue