diff options
-rw-r--r-- | rumba/model.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/rumba/model.py b/rumba/model.py index 694ce33..1e28147 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -283,11 +283,15 @@ class IPCP: self.node = node self.dif = dif self.registrations = [] + self.enrollments = [] def __repr__(self): - return "IPCP=%s DIF=%s N-1-DIFs=(%s)" % \ + return "{IPCP=%s,DIF=%s,N-1-DIFs=(%s),enrollments=(%s)}" % \ (self.name, self.dif.name, - ' '.join([dif.name for dif in self.registrations])) + ' '.join([dif.name for dif in self.registrations]), + ' '.join(['{neigh=%s,N-1-DIF=%s}' % (e['enroller'].name, + e['lower_dif'].name) for e in self.enrollments]) + ) def __hash__(self): return hash((self.name, self.dif.name)) @@ -433,6 +437,8 @@ class Experiment: if node1 != node2: dif_graphs[dif][node1].append((node2, lower_dif)) + self.enrollments[dif] = [] + if first == None: # This is a shim DIF, nothing to do continue @@ -443,8 +449,6 @@ class Experiment: er.append("%s --[%s]--> %s" % (node.name, edge[1].name, edge[0].name)) print("DIF graph for %s: %s" % (dif, ', '.join(er))) - self.enrollments[dif] = [] - if self.enrollment_strategy == 'minimal': # To generate the list of enrollments, we simulate one, # using breadth-first trasversal. @@ -480,7 +484,8 @@ class Experiment: e['lower_dif'])) def compute_ipcps(self): - # For each node, compute the required IPCP instances + # For each node, compute the required IPCP instances, and associated + # registrations and enrollments for node in self.nodes: node.ipcps = [] # We want also the node.ipcps list to be generated in @@ -488,13 +493,18 @@ class Experiment: for dif in self.dif_ordering: if dif not in node.difs: continue - ipcp = IPCP(name = '%s.%s.IPCP' % (dif.name, node.name), + ipcp = IPCP(name = '%s.%s' % (dif.name, node.name), node = node, dif = dif) if dif in node.dif_registrations: for lower in node.dif_registrations[dif]: ipcp.registrations.append(lower) + for e in self.enrollments[dif]: + if e['enrollee'] == node: + ipcp.enrollments.append({'enroller': e['enroller'], + 'lower_dif': e['lower_dif']}) + node.ipcps.append(ipcp) print("IPCP for node %s: %s" % (node.name, node.ipcps)) |