diff options
-rw-r--r-- | rumba/model.py | 22 |
1 files 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)) |