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:
+4
-9
@@ -521,16 +521,11 @@ class Mininet( object ):
|
|||||||
elif dst not in self.nameToNode:
|
elif dst not in self.nameToNode:
|
||||||
error( 'dst not in network: %s\n' % dst )
|
error( 'dst not in network: %s\n' % dst )
|
||||||
else:
|
else:
|
||||||
srcNode = self.nameToNode[ src ]
|
srcNode, dstNode = self.nameToNode[ src ], self.nameToNode[ dst ]
|
||||||
dstNode = self.nameToNode[ dst ]
|
connections = srcNode.connectionsTo( dstNode )
|
||||||
srcID = int( src[ 1: ] )
|
if len( connections ) == 0:
|
||||||
dstID = int( dst[ 1: ] )
|
|
||||||
if self.topo.port( srcID, dstID ) is None:
|
|
||||||
error( 'src and dst not connected: %s %s\n' % ( src, dst) )
|
error( 'src and dst not connected: %s %s\n' % ( src, dst) )
|
||||||
else:
|
for srcIntf, dstIntf in connections:
|
||||||
srcPort, dstPort = self.topo.port( srcID, dstID )
|
|
||||||
srcIntf = srcNode.intfs[ srcPort ]
|
|
||||||
dstIntf = dstNode.intfs[ dstPort ]
|
|
||||||
result = srcNode.cmd( [ 'ifconfig', srcIntf, status ] )
|
result = srcNode.cmd( [ 'ifconfig', srcIntf, status ] )
|
||||||
if result:
|
if result:
|
||||||
error( 'link src status change failed: %s\n' % result )
|
error( 'link src status change failed: %s\n' % result )
|
||||||
|
|||||||
@@ -261,6 +261,16 @@ class Node( object ):
|
|||||||
"Register connection of intf to dstIntf on dstNode."
|
"Register connection of intf to dstIntf on dstNode."
|
||||||
self.connection[ intf ] = ( dstNode, dstIntf )
|
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
|
# This is a symmetric operation, but it makes sense to put
|
||||||
# the code here since it is tightly coupled to routines in
|
# the code here since it is tightly coupled to routines in
|
||||||
# this class. For a more symmetric API, you can use
|
# this class. For a more symmetric API, you can use
|
||||||
|
|||||||
Reference in New Issue
Block a user