aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Capitani <[email protected]>2018-03-27 17:39:30 +0200
committerNick Aerts <[email protected]>2018-03-27 18:43:41 +0200
commitb95e6d7cddd7e07bbc3ce355862249227a323865 (patch)
tree9dc435c4cfd70cc97808d3e1d036bd1af11e81e5
parentdfd400c2fb1383bcd6e3862d6199fffad4e78524 (diff)
downloadrumba-b95e6d7cddd7e07bbc3ce355862249227a323865.tar.gz
rumba-b95e6d7cddd7e07bbc3ce355862249227a323865.zip
model: fix case where no quality is provided
Also add overloading in LinkQuality constructor
-rw-r--r--rumba/model.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/rumba/model.py b/rumba/model.py
index b6cb15e..6d0af58 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -161,7 +161,7 @@ class ShimEthDIF(DIF):
def __init__(self, name, members=None, link_quality=None):
DIF.__init__(self, name, members)
- self._link_quality = link_quality
+ self._link_quality = link_quality if link_quality is not None else LinkQuality()
def get_ipcp_class(self):
return ShimEthIPCP
@@ -325,13 +325,22 @@ class LinkQuality(object):
"""
Link quality configuration
:param delay: Delay object holding delay configuration
- :param loss: Loss object holding delay configuration
+ or number corresponding to delay in ms
+ :type delay: :py:class:`.Delay` or :py:class:`int`
+ :param loss: Loss object holding delay configuration or
+ number corresponding to loss percentage
+ :type loss: :py:class:`.Loss` or :py:class:`float`
:param rate: The rate of the link in mbit
+ :type rate: :py:class:`int`
"""
if rate and not rate > 0:
raise ValueError("Rate needs to be higher than 0")
+ if isinstance(delay, int):
+ delay = Delay(delay)
+ if isinstance(loss, int) or isinstance(loss, float):
+ loss = Loss(loss)
self._delay = delay
self._loss = loss
self._rate = rate
@@ -383,6 +392,8 @@ class LinkQuality(object):
def deactivate(self, shim):
for ipcp in shim.ipcps:
+ if ipcp not in LinkQuality._active:
+ continue
if not ipcp.ifname:
logger.error("Could not remove LinkQuality from IPCP because "
"the interface name is None")