@@ -28,9 +28,9 @@ def moduleDeps( subtract=None, add=None ):
|
|||||||
add: string or list of module names to add, if not already loaded"""
|
add: string or list of module names to add, if not already loaded"""
|
||||||
subtract = subtract if subtract is not None else []
|
subtract = subtract if subtract is not None else []
|
||||||
add = add if add is not None else []
|
add = add if add is not None else []
|
||||||
if type( subtract ) is str:
|
if isinstance( subtract, basestring ):
|
||||||
subtract = [ subtract ]
|
subtract = [ subtract ]
|
||||||
if type( add ) is str:
|
if isinstance( add, basestring ):
|
||||||
add = [ add ]
|
add = [ add ]
|
||||||
for mod in subtract:
|
for mod in subtract:
|
||||||
if mod in lsmod():
|
if mod in lsmod():
|
||||||
|
|||||||
+5
-5
@@ -338,8 +338,8 @@ class Mininet( object ):
|
|||||||
params: additional link params (optional)
|
params: additional link params (optional)
|
||||||
returns: link object"""
|
returns: link object"""
|
||||||
# Accept node objects or names
|
# Accept node objects or names
|
||||||
node1 = node1 if type( node1 ) != str else self[ node1 ]
|
node1 = node1 if not isinstance( node1, basestring ) else self[ node1 ]
|
||||||
node2 = node2 if type( node2 ) != str else self[ node2 ]
|
node2 = node2 if not isinstance( node2, basestring ) else self[ node2 ]
|
||||||
options = dict( params )
|
options = dict( params )
|
||||||
# Port is optional
|
# Port is optional
|
||||||
if port1 is not None:
|
if port1 is not None:
|
||||||
@@ -388,7 +388,7 @@ class Mininet( object ):
|
|||||||
# Add a default controller
|
# Add a default controller
|
||||||
info( '*** Adding controller\n' )
|
info( '*** Adding controller\n' )
|
||||||
classes = self.controller
|
classes = self.controller
|
||||||
if type( classes ) is not list:
|
if not isinstance( classes, list ):
|
||||||
classes = [ classes ]
|
classes = [ classes ]
|
||||||
for i, cls in enumerate( classes ):
|
for i, cls in enumerate( classes ):
|
||||||
# Allow Controller objects because nobody understands currying
|
# Allow Controller objects because nobody understands currying
|
||||||
@@ -808,9 +808,9 @@ 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:
|
||||||
if type( src ) is str:
|
if isinstance( src, basestring ):
|
||||||
src = self.nameToNode[ src ]
|
src = self.nameToNode[ src ]
|
||||||
if type( dst ) is str:
|
if isinstance( dst, basestring ):
|
||||||
dst = self.nameToNode[ dst ]
|
dst = self.nameToNode[ dst ]
|
||||||
connections = src.connectionsTo( dst )
|
connections = src.connectionsTo( dst )
|
||||||
if len( connections ) == 0:
|
if len( connections ) == 0:
|
||||||
|
|||||||
+3
-3
@@ -355,7 +355,7 @@ class Node( object ):
|
|||||||
if type( args[ 0 ] ) is list:
|
if type( args[ 0 ] ) is list:
|
||||||
# popen([cmd, arg1, arg2...])
|
# popen([cmd, arg1, arg2...])
|
||||||
cmd = args[ 0 ]
|
cmd = args[ 0 ]
|
||||||
elif type( args[ 0 ] ) is str:
|
elif isinstance( args[ 0 ], basestring ):
|
||||||
# popen("cmd arg1 arg2...")
|
# popen("cmd arg1 arg2...")
|
||||||
cmd = args[ 0 ].split()
|
cmd = args[ 0 ].split()
|
||||||
else:
|
else:
|
||||||
@@ -432,7 +432,7 @@ class Node( object ):
|
|||||||
"""
|
"""
|
||||||
if not intf:
|
if not intf:
|
||||||
return self.defaultIntf()
|
return self.defaultIntf()
|
||||||
elif type( intf ) is str:
|
elif isinstance( intf, basestring):
|
||||||
return self.nameToIntf[ intf ]
|
return self.nameToIntf[ intf ]
|
||||||
else:
|
else:
|
||||||
return intf
|
return intf
|
||||||
@@ -484,7 +484,7 @@ class Node( object ):
|
|||||||
"""Set the default route to go through intf.
|
"""Set the default route to go through intf.
|
||||||
intf: Intf or {dev <intfname> via <gw-ip> ...}"""
|
intf: Intf or {dev <intfname> via <gw-ip> ...}"""
|
||||||
# Note setParam won't call us if intf is none
|
# Note setParam won't call us if intf is none
|
||||||
if type( intf ) is str and ' ' in intf:
|
if isinstance( intf, basestring ) and ' ' in intf:
|
||||||
params = intf
|
params = intf
|
||||||
else:
|
else:
|
||||||
params = 'dev %s' % intf
|
params = 'dev %s' % intf
|
||||||
|
|||||||
+1
-1
@@ -549,7 +549,7 @@ def waitListening( client=None, server='127.0.0.1', port=80, timeout=None ):
|
|||||||
partial( quietRun, shell=True ) )
|
partial( quietRun, shell=True ) )
|
||||||
if not run( 'which telnet' ):
|
if not run( 'which telnet' ):
|
||||||
raise Exception('Could not find telnet' )
|
raise Exception('Could not find telnet' )
|
||||||
serverIP = server if type( server ) is str else server.IP()
|
serverIP = server if isinstance( server, basestring ) else server.IP()
|
||||||
cmd = ( 'sh -c "echo A | telnet -e A %s %s"' %
|
cmd = ( 'sh -c "echo A | telnet -e A %s %s"' %
|
||||||
( serverIP, port ) )
|
( serverIP, port ) )
|
||||||
time = 0
|
time = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user