Pt2Pt.py (9148:a7a72f42919e) | Pt2Pt.py (9862:54d6728d99cf) |
---|---|
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 | 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, IntLink, ExtLink, Router): | 42 def makeTopology(self, options, network, IntLink, ExtLink, Router): |
43 nodes = self.nodes | 43 nodes = self.nodes |
44 # Create an individual router for each controller, and connect all to all. | |
45 | 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))] | 46 routers = [Router(router_id=i) for i in range(len(nodes))] |
47 network.routers = routers 48 |
|
47 ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i]) 48 for (i, n) in enumerate(nodes)] | 49 ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i]) 50 for (i, n) in enumerate(nodes)] |
49 link_count = len(nodes) | 51 network.ext_links = ext_links |
50 | 52 |
53 link_count = len(nodes) |
|
51 int_links = [] 52 for i in xrange(len(nodes)): 53 for j in xrange(len(nodes)): 54 if (i != j): 55 link_count += 1 56 int_links.append(IntLink(link_id=link_count, 57 node_a=routers[i], 58 node_b=routers[j])) 59 | 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 |
60 return routers, int_links, ext_links | 63 network.int_links = int_links |