updated ebtables to use net_cmd

This commit is contained in:
Blake Harnden 2019-10-09 12:13:26 -07:00
parent 7e45168e77
commit 859f473ba9

View file

@ -3,7 +3,6 @@ Defines network nodes used within core.
""" """
import logging import logging
import os
import socket import socket
import threading import threading
import time import time
@ -165,20 +164,20 @@ class EbtablesQueue(object):
""" """
# save kernel ebtables snapshot to a file # save kernel ebtables snapshot to a file
args = self.ebatomiccmd(["--atomic-save"]) args = self.ebatomiccmd(["--atomic-save"])
utils.check_cmd(args) wlan.net_cmd(args)
# modify the table file using queued ebtables commands # modify the table file using queued ebtables commands
for c in self.cmds: for c in self.cmds:
args = self.ebatomiccmd(c) args = self.ebatomiccmd(c)
utils.check_cmd(args) wlan.net_cmd(args)
self.cmds = [] self.cmds = []
# commit the table file to the kernel # commit the table file to the kernel
args = self.ebatomiccmd(["--atomic-commit"]) args = self.ebatomiccmd(["--atomic-commit"])
utils.check_cmd(args) wlan.net_cmd(args)
try: try:
os.unlink(self.atomic_file) wlan.net_cmd(["rm", "-f", self.atomic_file])
except OSError: except OSError:
logging.exception("error removing atomic file: %s", self.atomic_file) logging.exception("error removing atomic file: %s", self.atomic_file)
@ -312,7 +311,7 @@ class CoreNetwork(CoreNetworkBase):
def net_cmd(self, args, env=None): def net_cmd(self, args, env=None):
""" """
Runs a command that is used to configure and setup the network on the host Runs a command that is used to configure and setup the network on the host
system. system and all configured distributed servers.
:param list[str]|str args: command to run :param list[str]|str args: command to run
:param dict env: environment to run command with :param dict env: environment to run command with
@ -341,7 +340,7 @@ class CoreNetwork(CoreNetworkBase):
# create a new ebtables chain for this bridge # create a new ebtables chain for this bridge
ebtablescmds( ebtablescmds(
utils.check_cmd, self.net_cmd,
[ [
[constants.EBTABLES_BIN, "-N", self.brname, "-P", self.policy], [constants.EBTABLES_BIN, "-N", self.brname, "-P", self.policy],
[ [
@ -372,7 +371,7 @@ class CoreNetwork(CoreNetworkBase):
try: try:
self.net_client.delete_bridge(self.brname) self.net_client.delete_bridge(self.brname)
ebtablescmds( ebtablescmds(
utils.check_cmd, self.net_cmd,
[ [
[ [
constants.EBTABLES_BIN, constants.EBTABLES_BIN,
@ -844,7 +843,6 @@ class CtrlNet(CoreNetwork):
if self.assign_address: if self.assign_address:
addrlist = ["%s/%s" % (addr, self.prefix.prefixlen)] addrlist = ["%s/%s" % (addr, self.prefix.prefixlen)]
self.addrconfig(addrlist=addrlist) self.addrconfig(addrlist=addrlist)
logging.info("address %s", addr)
if self.updown_script: if self.updown_script:
logging.info( logging.info(