diff options
author | Vincenzo Maffione <v.maffione@gmail.com> | 2016-10-23 18:52:18 +0200 |
---|---|---|
committer | Vincenzo Maffione <v.maffione@gmail.com> | 2016-10-23 18:52:18 +0200 |
commit | b4a1c65e541f0815436941aeccac4397ac5eeb26 (patch) | |
tree | 68cb497938929ff6090a666caf0561313331b6bc /libarcfire.py | |
parent | 3f6113d2bb0aca29a91282f8103b47d8ac310340 (diff) | |
download | rumba-b4a1c65e541f0815436941aeccac4397ac5eeb26.tar.gz rumba-b4a1c65e541f0815436941aeccac4397ac5eeb26.zip |
libarcfire: add Policy and normal DIF
Diffstat (limited to 'libarcfire.py')
-rwxr-xr-x | libarcfire.py | 42 |
1 files changed, 42 insertions, 0 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 |