initial changes to convert all commands to be string based for consistency
This commit is contained in:
parent
69772f993c
commit
02ef91242e
21 changed files with 145 additions and 256 deletions
|
@ -10,7 +10,6 @@ from queue import Empty, Queue
|
|||
|
||||
import grpc
|
||||
|
||||
from core import utils
|
||||
from core.api.grpc import core_pb2, core_pb2_grpc
|
||||
from core.emane.nodes import EmaneNet
|
||||
from core.emulator.data import (
|
||||
|
@ -884,8 +883,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session = self.get_session(request.session_id, context)
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
try:
|
||||
args = utils.split_args(request.command)
|
||||
output = node.node_net_cmd(args)
|
||||
output = node.node_net_cmd(request.command)
|
||||
except CoreCommandError as e:
|
||||
output = e.stderr
|
||||
return core_pb2.NodeCommandResponse(output=output)
|
||||
|
|
|
@ -882,7 +882,6 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
|||
return (reply,)
|
||||
else:
|
||||
logging.info("execute message with cmd=%s", command)
|
||||
command = utils.split_args(command)
|
||||
# execute command and send a response
|
||||
if (
|
||||
message.flags & MessageFlags.STRING.value
|
||||
|
|
|
@ -152,10 +152,9 @@ class EmaneManager(ModelManager):
|
|||
"""
|
||||
try:
|
||||
# check for emane
|
||||
args = ["emane", "--version"]
|
||||
args = "emane --version"
|
||||
emane_version = utils.check_cmd(args)
|
||||
logging.info("using EMANE: %s", emane_version)
|
||||
args = " ".join(args)
|
||||
for server in self.session.servers:
|
||||
conn = self.session.servers[server]
|
||||
distributed.remote_cmd(conn, args)
|
||||
|
@ -652,14 +651,6 @@ class EmaneManager(ModelManager):
|
|||
emane_net = self._emane_nets[key]
|
||||
emanexml.build_xml_files(self, emane_net)
|
||||
|
||||
def buildtransportxml(self):
|
||||
"""
|
||||
Calls emanegentransportxml using a platform.xml file to build the transportdaemon*.xml.
|
||||
"""
|
||||
utils.check_cmd(
|
||||
["emanegentransportxml", "platform.xml"], cwd=self.session.session_dir
|
||||
)
|
||||
|
||||
def buildeventservicexml(self):
|
||||
"""
|
||||
Build the libemaneeventservice.xml file if event service options
|
||||
|
@ -705,9 +696,9 @@ class EmaneManager(ModelManager):
|
|||
logging.info("setting user-defined EMANE log level: %d", cfgloglevel)
|
||||
loglevel = str(cfgloglevel)
|
||||
|
||||
emanecmd = ["emane", "-d", "-l", loglevel]
|
||||
emanecmd = "emane -d -l %s" % loglevel
|
||||
if realtime:
|
||||
emanecmd += ("-r",)
|
||||
emanecmd += " -r"
|
||||
|
||||
otagroup, _otaport = self.get_config("otamanagergroup").split(":")
|
||||
otadev = self.get_config("otamanagerdevice")
|
||||
|
@ -750,11 +741,11 @@ class EmaneManager(ModelManager):
|
|||
node.node_net_client.create_route(eventgroup, eventdev)
|
||||
|
||||
# start emane
|
||||
args = emanecmd + [
|
||||
"-f",
|
||||
args = "%s -f %s %s" % (
|
||||
emanecmd,
|
||||
os.path.join(path, "emane%d.log" % n),
|
||||
os.path.join(path, "platform%d.xml" % n),
|
||||
]
|
||||
)
|
||||
output = node.node_net_cmd(args)
|
||||
logging.info("node(%s) emane daemon running: %s", node.name, args)
|
||||
logging.info("node(%s) emane daemon output: %s", node.name, output)
|
||||
|
@ -763,22 +754,22 @@ class EmaneManager(ModelManager):
|
|||
return
|
||||
|
||||
path = self.session.session_dir
|
||||
emanecmd += ["-f", os.path.join(path, "emane.log")]
|
||||
args = emanecmd + [os.path.join(path, "platform.xml")]
|
||||
utils.check_cmd(args, cwd=path)
|
||||
args = " ".join(args)
|
||||
emanecmd += " -f %s" % os.path.join(path, "emane.log")
|
||||
emanecmd += " %s" % os.path.join(path, "platform.xml")
|
||||
utils.check_cmd(emanecmd, cwd=path)
|
||||
for server in self.session.servers:
|
||||
conn = self.session.servers[server]
|
||||
distributed.remote_cmd(conn, args, cwd=path)
|
||||
logging.info("host emane daemon running: %s", args)
|
||||
distributed.remote_cmd(conn, emanecmd, cwd=path)
|
||||
logging.info("host emane daemon running: %s", emanecmd)
|
||||
|
||||
def stopdaemons(self):
|
||||
"""
|
||||
Kill the appropriate EMANE daemons.
|
||||
"""
|
||||
# TODO: we may want to improve this if we had the PIDs from the specific EMANE daemons that we"ve started
|
||||
kill_emaned = ["killall", "-q", "emane"]
|
||||
kill_transortd = ["killall", "-q", "emanetransportd"]
|
||||
# TODO: we may want to improve this if we had the PIDs from the specific EMANE
|
||||
# daemons that we"ve started
|
||||
kill_emaned = "killall -q emane"
|
||||
kill_transortd = "killall -q emanetransportd"
|
||||
stop_emane_on_host = False
|
||||
for node in self.getnodes():
|
||||
if hasattr(node, "transport_type") and node.transport_type == "raw":
|
||||
|
@ -793,8 +784,6 @@ class EmaneManager(ModelManager):
|
|||
try:
|
||||
utils.check_cmd(kill_emaned)
|
||||
utils.check_cmd(kill_transortd)
|
||||
kill_emaned = " ".join(kill_emaned)
|
||||
kill_transortd = " ".join(kill_transortd)
|
||||
for server in self.session.servers:
|
||||
conn = self.session[server]
|
||||
distributed.remote_cmd(conn, kill_emaned)
|
||||
|
|
|
@ -62,4 +62,5 @@ class EmaneTdmaModel(emanemodel.EmaneModel):
|
|||
logging.info(
|
||||
"setting up tdma schedule: schedule(%s) device(%s)", schedule, event_device
|
||||
)
|
||||
utils.check_cmd(["emaneevent-tdmaschedule", "-i", event_device, schedule])
|
||||
args = "emaneevent-tdmaschedule -i %s %s" % (event_device, schedule)
|
||||
utils.check_cmd(args)
|
||||
|
|
|
@ -2044,5 +2044,4 @@ class Session(object):
|
|||
utils.mute_detach(data)
|
||||
else:
|
||||
node = self.get_node(node_id)
|
||||
data = utils.split_args(data)
|
||||
node.node_net_cmd(data, wait=False)
|
||||
|
|
|
@ -1281,7 +1281,7 @@ class Ns2ScriptedMobility(WayPointMobility):
|
|||
if filename is None or filename == "":
|
||||
return
|
||||
filename = self.findfile(filename)
|
||||
args = ["/bin/sh", filename, typestr]
|
||||
args = "/bin/sh %s %s" % (filename, typestr)
|
||||
utils.check_cmd(
|
||||
args, cwd=self.session.session_dir, env=self.session.get_environment()
|
||||
)
|
||||
|
|
|
@ -12,7 +12,8 @@ import threading
|
|||
from builtins import range
|
||||
from socket import AF_INET, AF_INET6
|
||||
|
||||
from core import constants, utils
|
||||
from core import utils
|
||||
from core.constants import MOUNT_BIN, VNODED_BIN
|
||||
from core.emulator import distributed
|
||||
from core.emulator.data import LinkData, NodeData
|
||||
from core.emulator.enumerations import LinkTypes, NodeTypes
|
||||
|
@ -89,7 +90,7 @@ class NodeBase(object):
|
|||
Runs a command that is used to configure and setup the network on the host
|
||||
system.
|
||||
|
||||
:param list[str]|str args: command to run
|
||||
:param str args: command to run
|
||||
:param dict env: environment to run command with
|
||||
:param str cwd: directory to run command in
|
||||
:param bool wait: True to wait for status, False otherwise
|
||||
|
@ -100,7 +101,6 @@ class NodeBase(object):
|
|||
if self.server is None:
|
||||
return utils.check_cmd(args, env, cwd, wait)
|
||||
else:
|
||||
args = " ".join(args)
|
||||
return distributed.remote_cmd(self.server, args, env, cwd, wait)
|
||||
|
||||
def setposition(self, x=None, y=None, z=None):
|
||||
|
@ -269,7 +269,7 @@ class CoreNodeBase(NodeBase):
|
|||
"""
|
||||
if self.nodedir is None:
|
||||
self.nodedir = os.path.join(self.session.session_dir, self.name + ".conf")
|
||||
self.net_cmd(["mkdir", "-p", self.nodedir])
|
||||
self.net_cmd("mkdir -p %s" % self.nodedir)
|
||||
self.tmpnodedir = True
|
||||
else:
|
||||
self.tmpnodedir = False
|
||||
|
@ -285,7 +285,7 @@ class CoreNodeBase(NodeBase):
|
|||
return
|
||||
|
||||
if self.tmpnodedir:
|
||||
self.net_cmd(["rm", "-rf", self.nodedir])
|
||||
self.net_cmd("rm -rf %s" % self.nodedir)
|
||||
|
||||
def addnetif(self, netif, ifindex):
|
||||
"""
|
||||
|
@ -334,7 +334,7 @@ class CoreNodeBase(NodeBase):
|
|||
Attach a network.
|
||||
|
||||
:param int ifindex: interface of index to attach
|
||||
:param core.nodes.interface.CoreInterface net: network to attach
|
||||
:param core.nodes.base.CoreNetworkBase net: network to attach
|
||||
:return: nothing
|
||||
"""
|
||||
if ifindex not in self._netif:
|
||||
|
@ -392,7 +392,7 @@ class CoreNodeBase(NodeBase):
|
|||
Runs a command that is used to configure and setup the network within a
|
||||
node.
|
||||
|
||||
:param list[str]|str args: command to run
|
||||
:param str args: command to run
|
||||
:param bool wait: True to wait for status, False otherwise
|
||||
:return: combined stdout and stderr
|
||||
:rtype: str
|
||||
|
@ -468,7 +468,7 @@ class CoreNode(CoreNodeBase):
|
|||
:rtype: bool
|
||||
"""
|
||||
try:
|
||||
self.net_cmd(["kill", "-0", str(self.pid)])
|
||||
self.net_cmd("kill -0 %s" % self.pid)
|
||||
except CoreCommandError:
|
||||
return False
|
||||
|
||||
|
@ -488,18 +488,11 @@ class CoreNode(CoreNodeBase):
|
|||
raise ValueError("starting a node that is already up")
|
||||
|
||||
# create a new namespace for this node using vnoded
|
||||
vnoded = [
|
||||
constants.VNODED_BIN,
|
||||
"-v",
|
||||
"-c",
|
||||
self.ctrlchnlname,
|
||||
"-l",
|
||||
self.ctrlchnlname + ".log",
|
||||
"-p",
|
||||
self.ctrlchnlname + ".pid",
|
||||
]
|
||||
vnoded = "{cmd} -v -c {name} -l {name}.log -p {name}.pid".format(
|
||||
cmd=VNODED_BIN, name=self.ctrlchnlname
|
||||
)
|
||||
if self.nodedir:
|
||||
vnoded += ["-C", self.nodedir]
|
||||
vnoded += " -C %s" % self.nodedir
|
||||
env = self.session.get_environment(state=False)
|
||||
env["NODE_NUMBER"] = str(self.id)
|
||||
env["NODE_NAME"] = str(self.name)
|
||||
|
@ -548,13 +541,13 @@ class CoreNode(CoreNodeBase):
|
|||
|
||||
# kill node process if present
|
||||
try:
|
||||
self.net_cmd(["kill", "-9", str(self.pid)])
|
||||
self.net_cmd("kill -9 %s" % self.pid)
|
||||
except CoreCommandError:
|
||||
logging.exception("error killing process")
|
||||
|
||||
# remove node directory if present
|
||||
try:
|
||||
self.net_cmd(["rm", "-rf", self.ctrlchnlname])
|
||||
self.net_cmd("rm -rf %s" % self.ctrlchnlname)
|
||||
except CoreCommandError:
|
||||
logging.exception("error removing node directory")
|
||||
|
||||
|
@ -572,7 +565,7 @@ class CoreNode(CoreNodeBase):
|
|||
Runs a command that is used to configure and setup the network within a
|
||||
node.
|
||||
|
||||
:param list[str] args: command to run
|
||||
:param str args: command to run
|
||||
:param bool wait: True to wait for status, False otherwise
|
||||
:return: combined stdout and stderr
|
||||
:rtype: str
|
||||
|
@ -581,8 +574,7 @@ class CoreNode(CoreNodeBase):
|
|||
if self.server is None:
|
||||
return self.client.check_cmd(args, wait=wait)
|
||||
else:
|
||||
args = self.client._cmd_args() + args
|
||||
args = " ".join(args)
|
||||
args = self.client.create_cmd(args)
|
||||
return distributed.remote_cmd(self.server, args, wait=wait)
|
||||
|
||||
def termcmdstring(self, sh="/bin/sh"):
|
||||
|
@ -606,7 +598,7 @@ class CoreNode(CoreNodeBase):
|
|||
hostpath = os.path.join(
|
||||
self.nodedir, os.path.normpath(path).strip("/").replace("/", ".")
|
||||
)
|
||||
self.net_cmd(["mkdir", "-p", hostpath])
|
||||
self.net_cmd("mkdir -p %s" % hostpath)
|
||||
self.mount(hostpath, path)
|
||||
|
||||
def mount(self, source, target):
|
||||
|
@ -620,8 +612,8 @@ class CoreNode(CoreNodeBase):
|
|||
"""
|
||||
source = os.path.abspath(source)
|
||||
logging.debug("node(%s) mounting: %s at %s", self.name, source, target)
|
||||
self.node_net_cmd(["mkdir", "-p", target])
|
||||
self.node_net_cmd([constants.MOUNT_BIN, "-n", "--bind", source, target])
|
||||
self.node_net_cmd("mkdir -p %s" % target)
|
||||
self.node_net_cmd("%s -n --bind %s %s" % (MOUNT_BIN, source, target))
|
||||
self._mounts.append((source, target))
|
||||
|
||||
def newifindex(self):
|
||||
|
@ -881,11 +873,11 @@ class CoreNode(CoreNodeBase):
|
|||
logging.info("adding file from %s to %s", srcname, filename)
|
||||
directory = os.path.dirname(filename)
|
||||
if self.server is None:
|
||||
self.client.check_cmd(["mkdir", "-p", directory])
|
||||
self.client.check_cmd(["mv", srcname, filename])
|
||||
self.client.check_cmd(["sync"])
|
||||
self.client.check_cmd("mkdir -p %s" % directory)
|
||||
self.client.check_cmd("mv %s %s" % (srcname, filename))
|
||||
self.client.check_cmd("sync")
|
||||
else:
|
||||
self.net_cmd(["mkdir", "-p", directory])
|
||||
self.net_cmd("mkdir -p %s" % directory)
|
||||
distributed.remote_put(self.server, srcname, filename)
|
||||
|
||||
def hostfilename(self, filename):
|
||||
|
@ -922,9 +914,9 @@ class CoreNode(CoreNodeBase):
|
|||
open_file.write(contents)
|
||||
os.chmod(open_file.name, mode)
|
||||
else:
|
||||
self.net_cmd(["mkdir", "-m", "%o" % 0o755, "-p", dirname])
|
||||
self.net_cmd("mkdir -m %o -p %s" % (0o755, dirname))
|
||||
distributed.remote_put_temp(self.server, hostfilename, contents)
|
||||
self.net_cmd(["chmod", "%o" % mode, hostfilename])
|
||||
self.net_cmd("chmod %o %s" % (mode, hostfilename))
|
||||
logging.debug(
|
||||
"node(%s) added file: %s; mode: 0%o", self.name, hostfilename, mode
|
||||
)
|
||||
|
@ -947,7 +939,7 @@ class CoreNode(CoreNodeBase):
|
|||
else:
|
||||
distributed.remote_put(self.server, srcfilename, hostfilename)
|
||||
if mode is not None:
|
||||
self.net_cmd(["chmod", "%o" % mode, hostfilename])
|
||||
self.net_cmd("chmod %o %s" % (mode, hostfilename))
|
||||
logging.info(
|
||||
"node(%s) copied file: %s; mode: %s", self.name, hostfilename, mode
|
||||
)
|
||||
|
|
|
@ -5,6 +5,7 @@ The control channel can be accessed via calls using the vcmd shell.
|
|||
"""
|
||||
|
||||
from core import constants, utils
|
||||
from core.constants import VCMD_BIN
|
||||
|
||||
|
||||
class VnodeClient(object):
|
||||
|
@ -49,22 +50,21 @@ class VnodeClient(object):
|
|||
"""
|
||||
pass
|
||||
|
||||
def _cmd_args(self):
|
||||
return [constants.VCMD_BIN, "-c", self.ctrlchnlname, "--"]
|
||||
def create_cmd(self, args):
|
||||
return "%s -c %s -- %s" % (VCMD_BIN, self.ctrlchnlname, args)
|
||||
|
||||
def check_cmd(self, args, wait=True):
|
||||
"""
|
||||
Run command and return exit status and combined stdout and stderr.
|
||||
|
||||
:param list[str]|str args: command to run
|
||||
:param str args: command to run
|
||||
:param bool wait: True to wait for command status, False otherwise
|
||||
:return: combined stdout and stderr
|
||||
:rtype: str
|
||||
:raises core.CoreCommandError: when there is a non-zero exit status
|
||||
"""
|
||||
self._verify_connection()
|
||||
args = utils.split_args(args)
|
||||
args = self._cmd_args() + args
|
||||
args = self.create_cmd(args)
|
||||
return utils.check_cmd(args, wait=wait)
|
||||
|
||||
def termcmdstring(self, sh="/bin/sh"):
|
||||
|
|
|
@ -63,7 +63,6 @@ class DockerClient(object):
|
|||
pid=self.pid,
|
||||
cmd=cmd
|
||||
)
|
||||
logging.info("ns cmd: %s", args)
|
||||
return utils.check_cmd(args, wait=wait)
|
||||
|
||||
def get_pid(self):
|
||||
|
|
|
@ -52,7 +52,7 @@ class CoreInterface(object):
|
|||
"""
|
||||
Runs a command on the host system or distributed servers.
|
||||
|
||||
:param list[str]|str args: command to run
|
||||
:param str args: command to run
|
||||
:param dict env: environment to run command with
|
||||
:param str cwd: directory to run command in
|
||||
:param bool wait: True to wait for status, False otherwise
|
||||
|
@ -63,7 +63,6 @@ class CoreInterface(object):
|
|||
if self.server is None:
|
||||
return utils.check_cmd(args, env, cwd, wait)
|
||||
else:
|
||||
args = " ".join(args)
|
||||
return distributed.remote_cmd(self.server, args, env, cwd, wait)
|
||||
|
||||
def startup(self):
|
||||
|
|
|
@ -19,7 +19,7 @@ class MacAddress(object):
|
|||
"""
|
||||
Creates a MacAddress instance.
|
||||
|
||||
:param str address: mac address
|
||||
:param bytes address: mac address
|
||||
"""
|
||||
self.addr = address
|
||||
|
||||
|
@ -42,7 +42,7 @@ class MacAddress(object):
|
|||
"""
|
||||
if not self.addr:
|
||||
return IpAddress.from_string("::")
|
||||
tmp = struct.unpack("!Q", "\x00\x00" + self.addr)[0]
|
||||
tmp = struct.unpack("!Q", b"\x00\x00" + self.addr)[0]
|
||||
nic = int(tmp) & 0x000000FFFFFF
|
||||
oui = int(tmp) & 0xFFFFFF000000
|
||||
# toggle U/L bit
|
||||
|
@ -88,7 +88,7 @@ class IpAddress(object):
|
|||
Create a IpAddress instance.
|
||||
|
||||
:param int af: address family
|
||||
:param str address: ip address
|
||||
:param bytes address: ip address
|
||||
:return:
|
||||
"""
|
||||
# check if (af, addr) is valid
|
||||
|
|
|
@ -43,25 +43,19 @@ class LxdClient(object):
|
|||
def stop_container(self):
|
||||
utils.check_cmd("lxc delete --force {name}".format(name=self.name))
|
||||
|
||||
def _cmd_args(self, cmd):
|
||||
def create_cmd(self, cmd):
|
||||
return "lxc exec -nT {name} -- {cmd}".format(name=self.name, cmd=cmd)
|
||||
|
||||
def check_cmd(self, cmd, wait):
|
||||
if isinstance(cmd, list):
|
||||
cmd = " ".join(cmd)
|
||||
args = self._cmd_args(cmd)
|
||||
logging.info("lxc cmd output: %s", args)
|
||||
def check_cmd(self, cmd, wait=True):
|
||||
args = self.create_cmd(cmd)
|
||||
return utils.check_cmd(args, wait=wait)
|
||||
|
||||
def _ns_args(self, cmd):
|
||||
def create_ns_cmd(self, cmd):
|
||||
return "nsenter -t {pid} -m -u -i -p -n {cmd}".format(pid=self.pid, cmd=cmd)
|
||||
|
||||
def ns_check_cmd(self, cmd):
|
||||
if isinstance(cmd, list):
|
||||
cmd = " ".join(cmd)
|
||||
args = self._ns_args(cmd)
|
||||
logging.info("ns cmd: %s", args)
|
||||
return utils.check_cmd(args)
|
||||
def ns_check_cmd(self, cmd, wait=True):
|
||||
args = self.create_ns_cmd(cmd)
|
||||
return utils.check_cmd(args, wait=wait)
|
||||
|
||||
def copy_file(self, source, destination):
|
||||
if destination[0] != "/":
|
||||
|
|
|
@ -27,7 +27,7 @@ class LinuxNetClient(object):
|
|||
:param str name: name for hostname
|
||||
:return: nothing
|
||||
"""
|
||||
self.run(["hostname", name])
|
||||
self.run("hostname %s" % name)
|
||||
|
||||
def create_route(self, route, device):
|
||||
"""
|
||||
|
@ -37,7 +37,7 @@ class LinuxNetClient(object):
|
|||
:param str device: device to add route to
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([IP_BIN, "route", "add", route, "dev", device])
|
||||
self.run("%s route add %s dev %s" % (IP_BIN, route, device))
|
||||
|
||||
def device_up(self, device):
|
||||
"""
|
||||
|
@ -46,7 +46,7 @@ class LinuxNetClient(object):
|
|||
:param str device: device to bring up
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([IP_BIN, "link", "set", device, "up"])
|
||||
self.run("%s link set %s up" % (IP_BIN, device))
|
||||
|
||||
def device_down(self, device):
|
||||
"""
|
||||
|
@ -55,7 +55,7 @@ class LinuxNetClient(object):
|
|||
:param str device: device to bring down
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([IP_BIN, "link", "set", device, "down"])
|
||||
self.run("%s link set %s down" % (IP_BIN, device))
|
||||
|
||||
def device_name(self, device, name):
|
||||
"""
|
||||
|
@ -65,7 +65,7 @@ class LinuxNetClient(object):
|
|||
:param str name: name to set
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([IP_BIN, "link", "set", device, "name", name])
|
||||
self.run("%s link set %s name %s" % (IP_BIN, device, name))
|
||||
|
||||
def device_show(self, device):
|
||||
"""
|
||||
|
@ -75,7 +75,7 @@ class LinuxNetClient(object):
|
|||
:return: device information
|
||||
:rtype: str
|
||||
"""
|
||||
return self.run([IP_BIN, "link", "show", device])
|
||||
return self.run("%s link show %s" % (IP_BIN, device))
|
||||
|
||||
def device_ns(self, device, namespace):
|
||||
"""
|
||||
|
@ -85,7 +85,7 @@ class LinuxNetClient(object):
|
|||
:param str namespace: namespace to set device to
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([IP_BIN, "link", "set", device, "netns", namespace])
|
||||
self.run("%s link set %s netns %s" % (IP_BIN, device, namespace))
|
||||
|
||||
def device_flush(self, device):
|
||||
"""
|
||||
|
@ -94,7 +94,7 @@ class LinuxNetClient(object):
|
|||
:param str device: device to flush
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([IP_BIN, "-6", "address", "flush", "dev", device])
|
||||
self.run("%s -6 address flush dev %s" % (IP_BIN, device))
|
||||
|
||||
def device_mac(self, device, mac):
|
||||
"""
|
||||
|
@ -104,7 +104,7 @@ class LinuxNetClient(object):
|
|||
:param str mac: mac to set
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([IP_BIN, "link", "set", "dev", device, "address", mac])
|
||||
self.run("%s link set dev %s address %s" % (IP_BIN, device, mac))
|
||||
|
||||
def delete_device(self, device):
|
||||
"""
|
||||
|
@ -113,7 +113,7 @@ class LinuxNetClient(object):
|
|||
:param str device: device to delete
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([IP_BIN, "link", "delete", device])
|
||||
self.run("%s link delete %s" % (IP_BIN, device))
|
||||
|
||||
def delete_tc(self, device):
|
||||
"""
|
||||
|
@ -122,7 +122,7 @@ class LinuxNetClient(object):
|
|||
:param str device: device to remove tc
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([TC_BIN, "qdisc", "del", "dev", device, "root"])
|
||||
self.run("%s qdisc del dev %s root" % (TC_BIN, device))
|
||||
|
||||
def checksums_off(self, interface_name):
|
||||
"""
|
||||
|
@ -131,7 +131,7 @@ class LinuxNetClient(object):
|
|||
:param str interface_name: interface to update
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([ETHTOOL_BIN, "-K", interface_name, "rx", "off", "tx", "off"])
|
||||
self.run("%s -K %s rx off tx off" % (ETHTOOL_BIN, interface_name))
|
||||
|
||||
def create_address(self, device, address, broadcast=None):
|
||||
"""
|
||||
|
@ -144,19 +144,11 @@ class LinuxNetClient(object):
|
|||
"""
|
||||
if broadcast is not None:
|
||||
self.run(
|
||||
[
|
||||
IP_BIN,
|
||||
"address",
|
||||
"add",
|
||||
address,
|
||||
"broadcast",
|
||||
broadcast,
|
||||
"dev",
|
||||
device,
|
||||
]
|
||||
"%s address add %s broadcast %s dev %s"
|
||||
% (IP_BIN, address, broadcast, device)
|
||||
)
|
||||
else:
|
||||
self.run([IP_BIN, "address", "add", address, "dev", device])
|
||||
self.run("%s address add %s dev %s" % (IP_BIN, address, device))
|
||||
|
||||
def delete_address(self, device, address):
|
||||
"""
|
||||
|
@ -166,7 +158,7 @@ class LinuxNetClient(object):
|
|||
:param str address: address to remove
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([IP_BIN, "address", "delete", address, "dev", device])
|
||||
self.run("%s address delete %s dev %s" % (IP_BIN, address, device))
|
||||
|
||||
def create_veth(self, name, peer):
|
||||
"""
|
||||
|
@ -176,9 +168,7 @@ class LinuxNetClient(object):
|
|||
:param str peer: peer name
|
||||
:return: nothing
|
||||
"""
|
||||
self.run(
|
||||
[IP_BIN, "link", "add", "name", name, "type", "veth", "peer", "name", peer]
|
||||
)
|
||||
self.run("%s link add name %s type veth peer name %s" % (IP_BIN, name, peer))
|
||||
|
||||
def create_gretap(self, device, address, local, ttl, key):
|
||||
"""
|
||||
|
@ -191,13 +181,13 @@ class LinuxNetClient(object):
|
|||
:param str key: key for tap
|
||||
:return: nothing
|
||||
"""
|
||||
cmd = [IP_BIN, "link", "add", device, "type", "gretap", "remote", address]
|
||||
cmd = "%s link add %s type gretap remote %s" % (IP_BIN, device, address)
|
||||
if local is not None:
|
||||
cmd.extend(["local", local])
|
||||
cmd += " local %s" % local
|
||||
if ttl is not None:
|
||||
cmd.extend(["ttl", ttl])
|
||||
cmd += " ttl %s" % ttl
|
||||
if key is not None:
|
||||
cmd.extend(["key", key])
|
||||
cmd += " key %s" % key
|
||||
self.run(cmd)
|
||||
|
||||
def create_bridge(self, name):
|
||||
|
@ -207,9 +197,9 @@ class LinuxNetClient(object):
|
|||
:param str name: bridge name
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([BRCTL_BIN, "addbr", name])
|
||||
self.run([BRCTL_BIN, "stp", name, "off"])
|
||||
self.run([BRCTL_BIN, "setfd", name, "0"])
|
||||
self.run("%s addbr %s" % (BRCTL_BIN, name))
|
||||
self.run("%s stp %s off" % (BRCTL_BIN, name))
|
||||
self.run("%s setfd %s 0" % (BRCTL_BIN, name))
|
||||
self.device_up(name)
|
||||
|
||||
# turn off multicast snooping so forwarding occurs w/o IGMP joins
|
||||
|
@ -226,7 +216,7 @@ class LinuxNetClient(object):
|
|||
:return: nothing
|
||||
"""
|
||||
self.device_down(name)
|
||||
self.run([BRCTL_BIN, "delbr", name])
|
||||
self.run("%s delbr %s" % (BRCTL_BIN, name))
|
||||
|
||||
def create_interface(self, bridge_name, interface_name):
|
||||
"""
|
||||
|
@ -236,7 +226,7 @@ class LinuxNetClient(object):
|
|||
:param str interface_name: interface name
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([BRCTL_BIN, "addif", bridge_name, interface_name])
|
||||
self.run("%s addif %s %s" % (BRCTL_BIN, bridge_name, interface_name))
|
||||
self.device_up(interface_name)
|
||||
|
||||
def delete_interface(self, bridge_name, interface_name):
|
||||
|
@ -247,7 +237,7 @@ class LinuxNetClient(object):
|
|||
:param str interface_name: interface name
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([BRCTL_BIN, "delif", bridge_name, interface_name])
|
||||
self.run("%s delif %s %s" % (BRCTL_BIN, bridge_name, interface_name))
|
||||
|
||||
def existing_bridges(self, _id):
|
||||
"""
|
||||
|
@ -255,7 +245,7 @@ class LinuxNetClient(object):
|
|||
|
||||
:param _id: node id to check bridges for
|
||||
"""
|
||||
output = self.run([BRCTL_BIN, "show"])
|
||||
output = self.run("%s show" % BRCTL_BIN)
|
||||
lines = output.split("\n")
|
||||
for line in lines[1:]:
|
||||
columns = line.split()
|
||||
|
@ -274,7 +264,7 @@ class LinuxNetClient(object):
|
|||
:param str name: bridge name
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([BRCTL_BIN, "setageing", name, "0"])
|
||||
self.run("%s setageing %s 0" % (BRCTL_BIN, name))
|
||||
|
||||
|
||||
class OvsNetClient(LinuxNetClient):
|
||||
|
@ -289,10 +279,10 @@ class OvsNetClient(LinuxNetClient):
|
|||
:param str name: bridge name
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([OVS_BIN, "add-br", name])
|
||||
self.run([OVS_BIN, "set", "bridge", name, "stp_enable=false"])
|
||||
self.run([OVS_BIN, "set", "bridge", name, "other_config:stp-max-age=6"])
|
||||
self.run([OVS_BIN, "set", "bridge", name, "other_config:stp-forward-delay=4"])
|
||||
self.run("%s add-br %s" % (OVS_BIN, name))
|
||||
self.run("%s set bridge %s stp_enable=false" % (OVS_BIN, name))
|
||||
self.run("%s set bridge %s other_config:stp-max-age=6" % (OVS_BIN, name))
|
||||
self.run("%s set bridge %s other_config:stp-forward-delay=4" % (OVS_BIN, name))
|
||||
self.device_up(name)
|
||||
|
||||
def delete_bridge(self, name):
|
||||
|
@ -303,7 +293,7 @@ class OvsNetClient(LinuxNetClient):
|
|||
:return: nothing
|
||||
"""
|
||||
self.device_down(name)
|
||||
self.run([OVS_BIN, "del-br", name])
|
||||
self.run("%s del-br %s" % (OVS_BIN, name))
|
||||
|
||||
def create_interface(self, bridge_name, interface_name):
|
||||
"""
|
||||
|
@ -313,7 +303,7 @@ class OvsNetClient(LinuxNetClient):
|
|||
:param str interface_name: interface name
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([OVS_BIN, "add-port", bridge_name, interface_name])
|
||||
self.run("%s add-port %s %s" % (OVS_BIN, bridge_name, interface_name))
|
||||
self.device_up(interface_name)
|
||||
|
||||
def delete_interface(self, bridge_name, interface_name):
|
||||
|
@ -324,7 +314,7 @@ class OvsNetClient(LinuxNetClient):
|
|||
:param str interface_name: interface name
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([OVS_BIN, "del-port", bridge_name, interface_name])
|
||||
self.run("%s del-port %s %s" % (OVS_BIN, bridge_name, interface_name))
|
||||
|
||||
def existing_bridges(self, _id):
|
||||
"""
|
||||
|
@ -332,7 +322,7 @@ class OvsNetClient(LinuxNetClient):
|
|||
|
||||
:param _id: node id to check bridges for
|
||||
"""
|
||||
output = self.run([OVS_BIN, "list-br"])
|
||||
output = self.run("%s list-br" % OVS_BIN)
|
||||
if output:
|
||||
for line in output.split("\n"):
|
||||
fields = line.split(".")
|
||||
|
@ -347,4 +337,4 @@ class OvsNetClient(LinuxNetClient):
|
|||
:param str name: bridge name
|
||||
:return: nothing
|
||||
"""
|
||||
self.run([OVS_BIN, "set", "bridge", name, "other_config:mac-aging-time=0"])
|
||||
self.run("%s set bridge %s other_config:mac-aging-time=0" % (OVS_BIN, name))
|
||||
|
|
|
@ -9,6 +9,7 @@ import time
|
|||
from socket import AF_INET, AF_INET6
|
||||
|
||||
from core import constants, utils
|
||||
from core.constants import EBTABLES_BIN
|
||||
from core.emulator import distributed
|
||||
from core.emulator.data import LinkData
|
||||
from core.emulator.enumerations import LinkTypes, NodeTypes, RegisterTlvs
|
||||
|
@ -92,14 +93,11 @@ class EbtablesQueue(object):
|
|||
"""
|
||||
Helper for building ebtables atomic file command list.
|
||||
|
||||
:param list[str] cmd: ebtable command
|
||||
:param str cmd: ebtable command
|
||||
:return: ebtable atomic command
|
||||
:rtype: list[str]
|
||||
"""
|
||||
r = [constants.EBTABLES_BIN, "--atomic-file", self.atomic_file]
|
||||
if cmd:
|
||||
r.extend(cmd)
|
||||
return r
|
||||
return "%s --atomic-file %s %s" % (EBTABLES_BIN, self.atomic_file, cmd)
|
||||
|
||||
def lastupdate(self, wlan):
|
||||
"""
|
||||
|
@ -163,7 +161,7 @@ class EbtablesQueue(object):
|
|||
:return: nothing
|
||||
"""
|
||||
# save kernel ebtables snapshot to a file
|
||||
args = self.ebatomiccmd(["--atomic-save"])
|
||||
args = self.ebatomiccmd("--atomic-save")
|
||||
wlan.net_cmd(args)
|
||||
|
||||
# modify the table file using queued ebtables commands
|
||||
|
@ -173,12 +171,12 @@ class EbtablesQueue(object):
|
|||
self.cmds = []
|
||||
|
||||
# commit the table file to the kernel
|
||||
args = self.ebatomiccmd(["--atomic-commit"])
|
||||
args = self.ebatomiccmd("--atomic-commit")
|
||||
wlan.net_cmd(args)
|
||||
|
||||
try:
|
||||
wlan.net_cmd(["rm", "-f", self.atomic_file])
|
||||
except OSError:
|
||||
wlan.net_cmd("rm -f %s" % self.atomic_file)
|
||||
except CoreCommandError:
|
||||
logging.exception("error removing atomic file: %s", self.atomic_file)
|
||||
|
||||
def ebchange(self, wlan):
|
||||
|
@ -200,58 +198,26 @@ class EbtablesQueue(object):
|
|||
"""
|
||||
with wlan._linked_lock:
|
||||
# flush the chain
|
||||
self.cmds.extend([["-F", wlan.brname]])
|
||||
self.cmds.append("-F %s" % wlan.brname)
|
||||
# rebuild the chain
|
||||
for netif1, v in wlan._linked.items():
|
||||
for netif2, linked in v.items():
|
||||
if wlan.policy == "DROP" and linked:
|
||||
self.cmds.extend(
|
||||
[
|
||||
[
|
||||
"-A",
|
||||
wlan.brname,
|
||||
"-i",
|
||||
netif1.localname,
|
||||
"-o",
|
||||
netif2.localname,
|
||||
"-j",
|
||||
"ACCEPT",
|
||||
],
|
||||
[
|
||||
"-A",
|
||||
wlan.brname,
|
||||
"-o",
|
||||
netif1.localname,
|
||||
"-i",
|
||||
netif2.localname,
|
||||
"-j",
|
||||
"ACCEPT",
|
||||
],
|
||||
"-A %s -i %s -o %s -j ACCEPT"
|
||||
% (wlan.brname, netif1.localname, netif2.localname),
|
||||
"-A %s -o %s -i %s -j ACCEPT"
|
||||
% (wlan.brname, netif1.localname, netif2.localname),
|
||||
]
|
||||
)
|
||||
elif wlan.policy == "ACCEPT" and not linked:
|
||||
self.cmds.extend(
|
||||
[
|
||||
[
|
||||
"-A",
|
||||
wlan.brname,
|
||||
"-i",
|
||||
netif1.localname,
|
||||
"-o",
|
||||
netif2.localname,
|
||||
"-j",
|
||||
"DROP",
|
||||
],
|
||||
[
|
||||
"-A",
|
||||
wlan.brname,
|
||||
"-o",
|
||||
netif1.localname,
|
||||
"-i",
|
||||
netif2.localname,
|
||||
"-j",
|
||||
"DROP",
|
||||
],
|
||||
"-A %s -i %s -o %s -j DROP"
|
||||
% (wlan.brname, netif1.localname, netif2.localname),
|
||||
"-A %s -o %s -i %s -j DROP"
|
||||
% (wlan.brname, netif1.localname, netif2.localname),
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -313,7 +279,7 @@ class CoreNetwork(CoreNetworkBase):
|
|||
Runs a command that is used to configure and setup the network on the host
|
||||
system and all configured distributed servers.
|
||||
|
||||
:param list[str]|str args: command to run
|
||||
:param str args: command to run
|
||||
:param dict env: environment to run command with
|
||||
:param str cwd: directory to run command in
|
||||
:param bool wait: True to wait for status, False otherwise
|
||||
|
@ -323,12 +289,9 @@ class CoreNetwork(CoreNetworkBase):
|
|||
"""
|
||||
logging.info("network node(%s) cmd", self.name)
|
||||
output = utils.check_cmd(args, env, cwd, wait)
|
||||
|
||||
args = " ".join(args)
|
||||
for server in self.session.servers:
|
||||
conn = self.session.servers[server]
|
||||
distributed.remote_cmd(conn, args, env, cwd, wait)
|
||||
|
||||
return output
|
||||
|
||||
def startup(self):
|
||||
|
@ -341,21 +304,12 @@ class CoreNetwork(CoreNetworkBase):
|
|||
self.net_client.create_bridge(self.brname)
|
||||
|
||||
# create a new ebtables chain for this bridge
|
||||
ebtablescmds(
|
||||
self.net_cmd,
|
||||
[
|
||||
[constants.EBTABLES_BIN, "-N", self.brname, "-P", self.policy],
|
||||
[
|
||||
constants.EBTABLES_BIN,
|
||||
"-A",
|
||||
"FORWARD",
|
||||
"--logical-in",
|
||||
self.brname,
|
||||
"-j",
|
||||
self.brname,
|
||||
],
|
||||
],
|
||||
)
|
||||
cmds = [
|
||||
"%s -N %s -P %s" % (EBTABLES_BIN, self.brname, self.policy),
|
||||
"%s -A FORWARD --logical-in %s -j %s"
|
||||
% (EBTABLES_BIN, self.brname, self.brname),
|
||||
]
|
||||
ebtablescmds(self.net_cmd, cmds)
|
||||
|
||||
self.up = True
|
||||
|
||||
|
@ -372,21 +326,12 @@ class CoreNetwork(CoreNetworkBase):
|
|||
|
||||
try:
|
||||
self.net_client.delete_bridge(self.brname)
|
||||
ebtablescmds(
|
||||
self.net_cmd,
|
||||
[
|
||||
[
|
||||
constants.EBTABLES_BIN,
|
||||
"-D",
|
||||
"FORWARD",
|
||||
"--logical-in",
|
||||
self.brname,
|
||||
"-j",
|
||||
self.brname,
|
||||
],
|
||||
[constants.EBTABLES_BIN, "-X", self.brname],
|
||||
],
|
||||
)
|
||||
cmds = [
|
||||
"%s -D FORWARD --logical-in %s -j %s"
|
||||
% (EBTABLES_BIN, self.brname, self.brname),
|
||||
"%s -X %s" % (EBTABLES_BIN, self.brname),
|
||||
]
|
||||
ebtablescmds(self.net_cmd, cmds)
|
||||
except CoreCommandError:
|
||||
logging.exception("error during shutdown")
|
||||
|
||||
|
@ -852,7 +797,7 @@ class CtrlNet(CoreNetwork):
|
|||
self.brname,
|
||||
self.updown_script,
|
||||
)
|
||||
self.net_cmd([self.updown_script, self.brname, "startup"])
|
||||
self.net_cmd("%s %s startup" % (self.updown_script, self.brname))
|
||||
|
||||
if self.serverintf:
|
||||
self.net_client.create_interface(self.brname, self.serverintf)
|
||||
|
@ -880,7 +825,7 @@ class CtrlNet(CoreNetwork):
|
|||
self.brname,
|
||||
self.updown_script,
|
||||
)
|
||||
self.net_cmd([self.updown_script, self.brname, "shutdown"])
|
||||
self.net_cmd("%s %s shutdown" % (self.updown_script, self.brname))
|
||||
except CoreCommandError:
|
||||
logging.exception("error issuing shutdown script shutdown")
|
||||
|
||||
|
@ -1064,7 +1009,8 @@ class HubNode(CoreNetwork):
|
|||
:param int _id: node id
|
||||
:param str name: node namee
|
||||
:param bool start: start flag
|
||||
:param str server: remote server node will run on, default is None for localhost
|
||||
:param fabric.connection.Connection server: remote server node will run on,
|
||||
default is None for localhost
|
||||
:raises CoreCommandError: when there is a command exception
|
||||
"""
|
||||
CoreNetwork.__init__(self, session, _id, name, start, server)
|
||||
|
@ -1094,7 +1040,8 @@ class WlanNode(CoreNetwork):
|
|||
:param int _id: node id
|
||||
:param str name: node name
|
||||
:param bool start: start flag
|
||||
:param str server: remote server node will run on, default is None for localhost
|
||||
:param fabric.connection.Connection server: remote server node will run on,
|
||||
default is None for localhost
|
||||
:param policy: wlan policy
|
||||
"""
|
||||
CoreNetwork.__init__(self, session, _id, name, start, server, policy)
|
||||
|
|
|
@ -597,7 +597,6 @@ class CoreServices(object):
|
|||
status = 0
|
||||
for cmd in cmds:
|
||||
logging.debug("validating service(%s) using: %s", service.name, cmd)
|
||||
cmd = utils.split_args(cmd)
|
||||
try:
|
||||
node.node_net_cmd(cmd)
|
||||
except CoreCommandError as e:
|
||||
|
@ -631,7 +630,6 @@ class CoreServices(object):
|
|||
"""
|
||||
status = 0
|
||||
for args in service.shutdown:
|
||||
args = utils.split_args(args)
|
||||
try:
|
||||
node.node_net_cmd(args)
|
||||
except CoreCommandError:
|
||||
|
@ -730,7 +728,6 @@ class CoreServices(object):
|
|||
|
||||
status = 0
|
||||
for cmd in cmds:
|
||||
cmd = utils.split_args(cmd)
|
||||
try:
|
||||
node.node_net_cmd(cmd, wait)
|
||||
except CoreCommandError:
|
||||
|
|
|
@ -415,7 +415,7 @@ class HttpService(UtilService):
|
|||
Detect the apache2 version using the 'a2query' command.
|
||||
"""
|
||||
try:
|
||||
result = utils.check_cmd(["a2query", "-v"])
|
||||
result = utils.check_cmd("a2query -v")
|
||||
status = 0
|
||||
except CoreCommandError as e:
|
||||
status = e.returncode
|
||||
|
|
|
@ -14,8 +14,6 @@ import shlex
|
|||
import sys
|
||||
from subprocess import PIPE, STDOUT, Popen
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
from core.errors import CoreCommandError
|
||||
|
||||
DEVNULL = open(os.devnull, "wb")
|
||||
|
@ -177,20 +175,6 @@ def make_tuple_fromstr(s, value_type):
|
|||
return tuple(value_type(i) for i in values)
|
||||
|
||||
|
||||
def split_args(args):
|
||||
"""
|
||||
Convenience method for splitting potential string commands into a shell-like
|
||||
syntax list.
|
||||
|
||||
:param list/str args: command list or string
|
||||
:return: shell-like syntax list
|
||||
:rtype: list
|
||||
"""
|
||||
if isinstance(args, basestring):
|
||||
args = shlex.split(args)
|
||||
return args
|
||||
|
||||
|
||||
def mute_detach(args, **kwargs):
|
||||
"""
|
||||
Run a muted detached process by forking it.
|
||||
|
@ -200,7 +184,7 @@ def mute_detach(args, **kwargs):
|
|||
:return: process id of the command
|
||||
:rtype: int
|
||||
"""
|
||||
args = split_args(args)
|
||||
args = shlex.split(args)
|
||||
kwargs["preexec_fn"] = _detach_init
|
||||
kwargs["stdout"] = DEVNULL
|
||||
kwargs["stderr"] = STDOUT
|
||||
|
@ -212,7 +196,7 @@ def check_cmd(args, env=None, cwd=None, wait=True):
|
|||
Execute a command on the host and return a tuple containing the exit status and
|
||||
result string. stderr output is folded into the stdout result string.
|
||||
|
||||
:param list[str]|str args: command arguments
|
||||
:param str args: command arguments
|
||||
:param dict env: environment to run command with
|
||||
:param str cwd: directory to run command in
|
||||
:param bool wait: True to wait for status, False otherwise
|
||||
|
@ -221,8 +205,8 @@ def check_cmd(args, env=None, cwd=None, wait=True):
|
|||
:raises CoreCommandError: when there is a non-zero exit status or the file to
|
||||
execute is not found
|
||||
"""
|
||||
args = split_args(args)
|
||||
logging.info("command cwd(%s) wait(%s): %s", cwd, wait, args)
|
||||
args = shlex.split(args)
|
||||
try:
|
||||
p = Popen(args, stdout=PIPE, stderr=PIPE, env=env, cwd=cwd)
|
||||
if wait:
|
||||
|
|
|
@ -3,7 +3,8 @@ import socket
|
|||
|
||||
from lxml import etree
|
||||
|
||||
from core import constants, utils
|
||||
from core import utils
|
||||
from core.constants import IP_BIN
|
||||
from core.emane.nodes import EmaneNet
|
||||
from core.nodes import ipaddress
|
||||
from core.nodes.base import CoreNodeBase
|
||||
|
@ -67,7 +68,7 @@ def get_address_type(address):
|
|||
def get_ipv4_addresses(hostname):
|
||||
if hostname == "localhost":
|
||||
addresses = []
|
||||
args = [constants.IP_BIN, "-o", "-f", "inet", "addr", "show"]
|
||||
args = "%s -o -f inet address show" % IP_BIN
|
||||
output = utils.check_cmd(args)
|
||||
for line in output.split(os.linesep):
|
||||
split = line.split()
|
||||
|
|
|
@ -27,7 +27,7 @@ _DIR = os.path.dirname(os.path.abspath(__file__))
|
|||
def ping(from_node, to_node, ip_prefixes, count=3):
|
||||
address = ip_prefixes.ip4_address(to_node)
|
||||
try:
|
||||
from_node.node_net_cmd(["ping", "-c", str(count), address])
|
||||
from_node.node_net_cmd("ping -c %s %s" % (count, address))
|
||||
status = 0
|
||||
except CoreCommandError as e:
|
||||
status = e.returncode
|
||||
|
|
|
@ -20,7 +20,7 @@ _WIRED = [NodeTypes.PEER_TO_PEER, NodeTypes.HUB, NodeTypes.SWITCH]
|
|||
def ping(from_node, to_node, ip_prefixes):
|
||||
address = ip_prefixes.ip4_address(to_node)
|
||||
try:
|
||||
from_node.node_net_cmd(["ping", "-c", "3", address])
|
||||
from_node.node_net_cmd("ping -c 3 %s" % address)
|
||||
status = 0
|
||||
except CoreCommandError as e:
|
||||
status = e.returncode
|
||||
|
|
|
@ -30,7 +30,7 @@ class TestNodes:
|
|||
assert os.path.exists(node.nodedir)
|
||||
assert node.alive()
|
||||
assert node.up
|
||||
assert node.node_net_cmd(["ip", "addr", "show", "lo"])
|
||||
assert node.node_net_cmd("ip address show lo")
|
||||
|
||||
def test_node_update(self, session):
|
||||
# given
|
||||
|
@ -67,4 +67,4 @@ class TestNodes:
|
|||
# then
|
||||
assert node
|
||||
assert node.up
|
||||
assert utils.check_cmd(["brctl", "show", node.brname])
|
||||
assert utils.check_cmd("brctl show %s" % node.brname)
|
||||
|
|
Loading…
Reference in a new issue