aboutsummaryrefslogtreecommitdiff
path: root/rumba/model.py
diff options
context:
space:
mode:
authorVincenzo Maffione <v.maffione@gmail.com>2017-03-24 12:00:22 +0100
committerVincenzo Maffione <v.maffione@gmail.com>2017-03-24 12:22:31 +0100
commit21e1397605f9474ba638cc66425378fbd89cbcae (patch)
treee96d5ed95a2ae9101851f257c0c2489c00748914 /rumba/model.py
parent5f1aaa9c7bea51458385af7620bd847f059fa815 (diff)
downloadrumba-21e1397605f9474ba638cc66425378fbd89cbcae.tar.gz
rumba-21e1397605f9474ba638cc66425378fbd89cbcae.zip
model: add per-IPCP self-enrolled information
This boolean field is true if the IPCP auto-enrolls in its DIF.
Diffstat (limited to 'rumba/model.py')
-rw-r--r--rumba/model.py22
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))