fixed linkconfig parameter name to match other linkconfig signatures

This commit is contained in:
Blake J. Harnden 2018-07-06 14:40:51 -07:00
parent 3fb8ae0439
commit 5b0ed13e78

View file

@ -185,55 +185,55 @@ class OvsNet(PyCoreNet):
ebtables_queue.ebchange(self)
def linkconfig(self, interface, bw=None, delay=None, loss=None, duplicate=None,
def linkconfig(self, netif, bw=None, delay=None, loss=None, duplicate=None,
jitter=None, netif2=None, devname=None):
"""
Configure link parameters by applying tc queuing disciplines on the
interface.
"""
if not devname:
devname = interface.localname
devname = netif.localname
tc = [constants.TC_BIN, "qdisc", "replace", "dev", devname]
parent = ["root"]
# attempt to set bandwidth and update as needed if value changed
bandwidth_changed = interface.setparam("bw", bw)
bandwidth_changed = netif.setparam("bw", bw)
if bandwidth_changed:
# from tc-tbf(8): minimum value for burst is rate / kernel_hz
if bw > 0:
if self.up:
burst = max(2 * interface.mtu, bw / 1000)
burst = max(2 * netif.mtu, bw / 1000)
limit = 0xffff # max IP payload
tbf = ["tbf", "rate", str(bw), "burst", str(burst), "limit", str(limit)]
logger.info("linkconfig: %s" % [tc + parent + ["handle", "1:"] + tbf])
utils.check_cmd(tc + parent + ["handle", "1:"] + tbf)
interface.setparam("has_tbf", True)
elif interface.getparam("has_tbf") and bw <= 0:
netif.setparam("has_tbf", True)
elif netif.getparam("has_tbf") and bw <= 0:
tcd = [] + tc
tcd[2] = "delete"
if self.up:
utils.check_cmd(tcd + parent)
interface.setparam("has_tbf", False)
netif.setparam("has_tbf", False)
# removing the parent removes the child
interface.setparam("has_netem", False)
netif.setparam("has_netem", False)
if interface.getparam("has_tbf"):
if netif.getparam("has_tbf"):
parent = ["parent", "1:1"]
netem = ["netem"]
delay_changed = interface.setparam("delay", delay)
delay_changed = netif.setparam("delay", delay)
if loss is not None:
loss = float(loss)
loss_changed = interface.setparam("loss", loss)
loss_changed = netif.setparam("loss", loss)
if duplicate is not None:
duplicate = float(duplicate)
duplicate_changed = interface.setparam("duplicate", duplicate)
jitter_changed = interface.setparam("jitter", jitter)
duplicate_changed = netif.setparam("duplicate", duplicate)
jitter_changed = netif.setparam("jitter", jitter)
# if nothing changed return
if not any([bandwidth_changed, delay_changed, loss_changed, duplicate_changed, jitter_changed]):
@ -256,7 +256,7 @@ class OvsNet(PyCoreNet):
if delay <= 0 and jitter <= 0 and loss <= 0 and duplicate <= 0:
# possibly remove netem if it exists and parent queue wasn"t removed
if not interface.getparam("has_netem"):
if not netif.getparam("has_netem"):
return
tc[2] = "delete"
@ -264,12 +264,12 @@ class OvsNet(PyCoreNet):
if self.up:
logger.info("linkconfig: %s" % ([tc + parent + ["handle", "10:"]],))
utils.check_cmd(tc + parent + ["handle", "10:"])
interface.setparam("has_netem", False)
netif.setparam("has_netem", False)
elif len(netem) > 1:
if self.up:
logger.info("linkconfig: %s" % ([tc + parent + ["handle", "10:"] + netem],))
utils.check_cmd(tc + parent + ["handle", "10:"] + netem)
interface.setparam("has_netem", True)
netif.setparam("has_netem", True)
def linknet(self, network):
"""