Changed mininet.link() to support multiple links.

It should also probably be renamed to something like:
configLinks(src, dst, status).
This commit is contained in:
Bob Lantz
2010-03-23 15:05:55 -07:00
parent 178a3d8410
commit fb2f652319
2 changed files with 14 additions and 9 deletions
+4 -9
View File
@@ -521,16 +521,11 @@ class Mininet( object ):
elif dst not in self.nameToNode:
error( 'dst not in network: %s\n' % dst )
else:
srcNode = self.nameToNode[ src ]
dstNode = self.nameToNode[ dst ]
srcID = int( src[ 1: ] )
dstID = int( dst[ 1: ] )
if self.topo.port( srcID, dstID ) is None:
srcNode, dstNode = self.nameToNode[ src ], self.nameToNode[ dst ]
connections = srcNode.connectionsTo( dstNode )
if len( connections ) == 0:
error( 'src and dst not connected: %s %s\n' % ( src, dst) )
else:
srcPort, dstPort = self.topo.port( srcID, dstID )
srcIntf = srcNode.intfs[ srcPort ]
dstIntf = dstNode.intfs[ dstPort ]
for srcIntf, dstIntf in connections:
result = srcNode.cmd( [ 'ifconfig', srcIntf, status ] )
if result:
error( 'link src status change failed: %s\n' % result )
+10
View File
@@ -261,6 +261,16 @@ class Node( object ):
"Register connection of intf to dstIntf on dstNode."
self.connection[ intf ] = ( dstNode, dstIntf )
def connectionsTo( self, node):
"Return [(srcIntf, dstIntf)..] for connections to dstNode."
# We could optimize this if it is important
connections = []
for intf in self.connection.keys():
dstNode, dstIntf = self.connection[ intf ]
if dstNode == node:
connections.append( ( intf, dstIntf ) )
return connections
# This is a symmetric operation, but it makes sense to put
# the code here since it is tightly coupled to routines in
# this class. For a more symmetric API, you can use