initial changes to convert all commands to be string based for consistency

This commit is contained in:
Blake Harnden 2019-10-11 16:36:57 -07:00
parent 69772f993c
commit 02ef91242e
21 changed files with 145 additions and 256 deletions

View file

@ -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
)

View file

@ -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"):

View file

@ -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):

View file

@ -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):

View file

@ -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

View file

@ -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] != "/":

View file

@ -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))

View file

@ -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)