1# Copyright (c) 2011 Advanced Micro Devices, Inc. 2# 2011 Massachusetts Institute of Technology 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 25 unchanged lines hidden (view full) --- 34from BaseTopology import SimpleTopology 35 36class Pt2Pt(SimpleTopology): 37 description='Pt2Pt' 38 39 def __init__(self, controllers): 40 self.nodes = controllers 41 |
42 def makeTopology(self, options, network, IntLink, ExtLink, Router): |
43 nodes = self.nodes |
44 |
45 # Create an individual router for each controller, and connect all to all. |
46 routers = [Router(router_id=i) for i in range(len(nodes))] |
47 network.routers = routers 48 |
49 ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i]) 50 for (i, n) in enumerate(nodes)] |
51 network.ext_links = ext_links |
52 |
53 link_count = len(nodes) |
54 int_links = [] 55 for i in xrange(len(nodes)): 56 for j in xrange(len(nodes)): 57 if (i != j): 58 link_count += 1 59 int_links.append(IntLink(link_id=link_count, 60 node_a=routers[i], 61 node_b=routers[j])) 62 |
63 network.int_links = int_links |