From b4a1c65e541f0815436941aeccac4397ac5eeb26 Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Sun, 23 Oct 2016 18:52:18 +0200 Subject: libarcfire: add Policy and normal DIF --- libarcfire.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'libarcfire.py') 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 -- cgit v1.2.3