aboutsummaryrefslogtreecommitdiff
path: root/rumba/elements
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2018-04-12 11:54:47 +0200
committerMarco Capitani <m.capitani@nextworks.it>2018-04-12 12:21:35 +0200
commit3be4baa7e19133f0c41188bb1c2ee6ae3a82d470 (patch)
tree989bc72464101511d8f69da80e8be77d04a21597 /rumba/elements
parent441c9fcba86070840dcff757986a5d4e20ccbcaa (diff)
downloadrumba-3be4baa7e19133f0c41188bb1c2ee6ae3a82d470.tar.gz
rumba-3be4baa7e19133f0c41188bb1c2ee6ae3a82d470.zip
model & irati: add QOS cubes
Fixes #45 Only implemented in IRATI, other prototypes warn and ignore.
Diffstat (limited to 'rumba/elements')
-rw-r--r--rumba/elements/topology.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/rumba/elements/topology.py b/rumba/elements/topology.py
index 24dcfa2..0ff1957 100644
--- a/rumba/elements/topology.py
+++ b/rumba/elements/topology.py
@@ -212,6 +212,8 @@ class NormalDIF(DIF):
if policy is None:
policy = Policy(self)
self.policy = policy
+ self.qos_cubes = []
+ self._last_cube_id = 0
def add_policy(self, comp, pol, **params):
"""
@@ -243,6 +245,43 @@ class NormalDIF(DIF):
% (comp, pol, params)
return s
+ def add_qos_cube(self, name, **kwargs):
+ """
+ Adds a QoS Cube to this DIF
+
+ :param name: the name to be assigned to the QoS cube
+ :type name: `str`
+ :param kwargs: the parameters of the QoS cube (prototype dependent)
+ """
+ self.del_qos_cube(name, strict=False)
+ c_id = self._last_cube_id + 1
+ self._last_cube_id = c_id
+ kwargs["name"] = name
+ kwargs["cube_id"] = c_id
+ self.qos_cubes.append(kwargs)
+
+ def del_qos_cube(self, name, strict=True):
+ """
+ Deletes a QoS cube from this DIF
+
+ :param name: the name of the cube to delete
+ :type name: `str`
+ :param strict: if no cube with the provided name exists,
+ raise an exception if and only if `strict` is `True`
+ :type strict: `bool`
+ """
+ for i, cube in enumerate(self.qos_cubes):
+ if cube["name"] == name:
+ index = i
+ break
+ else: # no match
+ if strict:
+ raise ValueError("No cube with name %s found in dif %s"
+ % (name, self.name))
+ else:
+ return
+ self.qos_cubes.pop(index)
+
class Distribution(Enum):
"""