Merging MurphyMc LinearTopo pull request
This commit is contained in:
@@ -281,7 +281,7 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
MininetRunner()
|
MininetRunner()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
info( "Keyboard Interrupt. Shutting down and cleaning up...")
|
info( "\n\nKeyboard Interrupt. Shutting down and cleaning up...\n\n")
|
||||||
cleanup()
|
cleanup()
|
||||||
except Exception:
|
except Exception:
|
||||||
# Print exception
|
# Print exception
|
||||||
|
|||||||
+8
-1
@@ -249,6 +249,12 @@ class LinearTopo(Topo):
|
|||||||
self.k = k
|
self.k = k
|
||||||
self.n = n
|
self.n = n
|
||||||
|
|
||||||
|
if n == 1:
|
||||||
|
genHostName = lambda i,j: 'h%s' % i
|
||||||
|
else:
|
||||||
|
genHostName = lambda i,j: 'h%ss%d' % (j,i)
|
||||||
|
|
||||||
|
|
||||||
lastSwitch = None
|
lastSwitch = None
|
||||||
for i in irange(1, k):
|
for i in irange(1, k):
|
||||||
# Add switch
|
# Add switch
|
||||||
@@ -256,7 +262,8 @@ class LinearTopo(Topo):
|
|||||||
# Add hosts to switch
|
# Add hosts to switch
|
||||||
for j in irange(1, n):
|
for j in irange(1, n):
|
||||||
hostNum = (i-1)*n + j
|
hostNum = (i-1)*n + j
|
||||||
host = self.addHost('h%s' % hostNum)
|
#host = self.addHost('h%s' % hostNum)
|
||||||
|
host = self.addHost(genHostName(i, j))
|
||||||
self.addLink(host, switch)
|
self.addLink(host, switch)
|
||||||
# Connect switch to previous
|
# Connect switch to previous
|
||||||
if lastSwitch:
|
if lastSwitch:
|
||||||
|
|||||||
Reference in New Issue
Block a user