From 21e1397605f9474ba638cc66425378fbd89cbcae Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Fri, 24 Mar 2017 12:00:22 +0100 Subject: model: add per-IPCP self-enrolled information This boolean field is true if the IPCP auto-enrolls in its DIF. --- rumba/model.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/rumba/model.py b/rumba/model.py index 4f3e72a..098930a 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -303,10 +303,15 @@ class IPCP: self.dif = dif self.registrations = [] + # Is this node the first in the DIF, so that it does not need + # to enroll to anyone ? + self.dif_bootstrapper = False + def __repr__(self): - return "{IPCP=%s,DIF=%s,N-1-DIFs=(%s)}" % \ + return "{IPCP=%s,DIF=%s,N-1-DIFs=(%s)%s}" % \ (self.name, self.dif.name, - ' '.join([dif.name for dif in self.registrations]) + ' '.join([dif.name for dif in self.registrations]), + ',bootstrapper' if self.dif_bootstrapper else '' ) def __hash__(self): @@ -537,6 +542,19 @@ class Experiment: for lower in node.dif_registrations[dif]: ipcp.registrations.append(lower) + ipcp.dif_bootstrapper = True + for el in self.enrollments: + for e in el: + if e['dif'] != dif: + # Skip this DIF + break + if e['enrollee'] == node: + ipcp.dif_bootstrapper = False + # Exit the loops + break + if not ipcp.dif_bootstrapper: + break + node.ipcps.append(ipcp) print("IPCP for node %s: %s" % (node.name, node.ipcps)) -- cgit v1.2.3