aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincenzo Maffione <[email protected]>2016-10-23 18:52:18 +0200
committerVincenzo Maffione <[email protected]>2016-10-23 18:52:18 +0200
commitb4a1c65e541f0815436941aeccac4397ac5eeb26 (patch)
tree68cb497938929ff6090a666caf0561313331b6bc
parent3f6113d2bb0aca29a91282f8103b47d8ac310340 (diff)
downloadrumba-b4a1c65e541f0815436941aeccac4397ac5eeb26.tar.gz
rumba-b4a1c65e541f0815436941aeccac4397ac5eeb26.zip
libarcfire: add Policy and normal DIF
-rwxr-xr-xlibarcfire.py42
-rwxr-xr-xmain.py8
2 files changed, 49 insertions, 1 deletions
diff --git a/libarcfire.py b/libarcfire.py
index e9b7adc..60bce47 100755
--- a/libarcfire.py
+++ b/libarcfire.py
@@ -37,6 +37,48 @@ class ShimEthDIF(DIF):
raise ValueError("link_speed must be a non-negative number")
+# A policy
+#
+# @component: RINA component to which the policy applies to
+# @name: Name of the policy
+# @parameters: A dictionary of (key, values) pairs representing policy-specific
+# parameters
+class Policy:
+ def __init__(self, component, name, **kwargs):
+ self.component = component
+ self.name = name
+ self.parameters = kwargs
+
+ def __repr__(self):
+ s = "%s:%s" % (self.component, self.name)
+ if self.parameters:
+ s += "%s" % self.parameters
+ return s
+
+
+# Normal DIF
+class NormalDIF(DIF):
+ def __init__(self, name, members = None):
+ DIF.__init__(self, name, members)
+ self.policies = dict()
+
+ def policy_add(self, policy):
+ self.policies[policy.component] = policy
+
+ def policy_del(self, component):
+ del self.policies[component]
+
+ def __repr__(self):
+ s = DIF.__repr__(self)
+ if self.policies:
+ s += " policies=["
+ for p in self.policies:
+ s += "%s," % self.policies[p]
+ if self.policies:
+ s += "]"
+ return s
+
+
# Base class for ARCFIRE experiments
#
# @name [string] Name of the experiment
diff --git a/main.py b/main.py
index 88effbb..7777a93 100755
--- a/main.py
+++ b/main.py
@@ -6,7 +6,13 @@ from libarcfire import *
exp = Experiment("prova")
-exp.dif_add(ShimEthDIF("300", 0, ["a", "b", "c"]))
+exp.dif_add(ShimEthDIF("300", 0, ["a", "b"]))
+exp.dif_add(ShimEthDIF("400", 0, ["b", "c"]))
+
+n1 = NormalDIF("n1", ["a", "b", "c"])
+n1.policy_add(Policy("rmt.pff", "lfa"))
+n1.policy_add(Policy("security-manager", "passwd", passwd="xyz"))
+exp.dif_add(n1)
print(exp)