Skip to content
Snippets Groups Projects
Commit da4dcf37 authored by Bob Lantz's avatar Bob Lantz
Browse files

Add addresses to fastIntfPair() and fix codecheck

parent 5383b0e6
No related branches found
No related tags found
No related merge requests found
...@@ -390,6 +390,7 @@ def __init__( self, node1, node2, port1=None, port2=None, ...@@ -390,6 +390,7 @@ def __init__( self, node1, node2, port1=None, port2=None,
# This is a bit awkward; it seems that having everything in # This is a bit awkward; it seems that having everything in
# params is more orthogonal, but being able to specify # params is more orthogonal, but being able to specify
# in-line arguments is more convenient! So we support both. # in-line arguments is more convenient! So we support both.
# pylint: disable=too-many-branches
if params1 is None: if params1 is None:
params1 = {} params1 = {}
if params2 is None: if params2 is None:
...@@ -417,13 +418,13 @@ def __init__( self, node1, node2, port1=None, port2=None, ...@@ -417,13 +418,13 @@ def __init__( self, node1, node2, port1=None, port2=None,
self.fastIntfPair( intfName1, intfName2, addr1, addr2, self.fastIntfPair( intfName1, intfName2, addr1, addr2,
node1=node1, node2=node2) node1=node1, node2=node2)
else: else:
self.makeIntfPair( intfName1, intfName2, addr1, addr2, self.makeIntfPair( intfName1, intfName2, addr1, addr2 )
node1=node1, node2=node2)
if not cls1: if not cls1:
cls1 = intf cls1 = intf
if not cls2: if not cls2:
cls2 = intf cls2 = intf
# pylint: enable=too-many-branches
intf1 = cls1( name=intfName1, node=node1, intf1 = cls1( name=intfName1, node=node1,
link=self, mac=addr1, **params1 ) link=self, mac=addr1, **params1 )
...@@ -445,8 +446,7 @@ def intfName( self, node, n ): ...@@ -445,8 +446,7 @@ def intfName( self, node, n ):
return node.name + '-eth' + repr( n ) return node.name + '-eth' + repr( n )
@classmethod @classmethod
def makeIntfPair( cls, intfname1, intfname2, addr1=None, addr2=None, def makeIntfPair( cls, intfname1, intfname2, addr1=None, addr2=None ):
node1=None, node2=None ):
"""Create pair of interfaces """Create pair of interfaces
intfname1: name of interface 1 intfname1: name of interface 1
intfname2: name of interface 2 intfname2: name of interface 2
...@@ -458,15 +458,23 @@ def makeIntfPair( cls, intfname1, intfname2, addr1=None, addr2=None, ...@@ -458,15 +458,23 @@ def makeIntfPair( cls, intfname1, intfname2, addr1=None, addr2=None,
@classmethod @classmethod
def fastIntfPair( cls, intfname1, intfname2, addr1=None, addr2=None, def fastIntfPair( cls, intfname1, intfname2, addr1=None, addr2=None,
node1=None, node2=None ): node1=None, node2=None ):
"""Create pair of interfaces """Create pair of interfaces
'fast' version: no checking, only works with Nodes. 'fast' version: no checking, only works with Nodes.
intf1: name of interface 1 intf1: name of interface 1
intf2: name of interface 2 intf2: name of interface 2
(override this class method [and possibly delete()] (override this class method [and possibly delete()]
to change link type)""" to change link type)"""
return node1.cmd( 'ip link add', intfname1, 'type veth ' if addr1 is None and addr2 is None:
'peer name', intfname2, 'netns', node2.pid ) return node1.cmd( 'ip link add name', intfname1,
'type veth peer name',
intfname2, 'netns', node2.pid )
else:
return node1.cmd( 'ip link add name', intfname1,
'address', addr1,
'type veth peer name', intfname2,
'address', addr2,
'netns', node2.pid )
def delete( self ): def delete( self ):
"Delete this link" "Delete this link"
...@@ -488,9 +496,10 @@ def __str__( self ): ...@@ -488,9 +496,10 @@ def __str__( self ):
class OVSIntf( Intf ): class OVSIntf( Intf ):
"Patch interface on an OVSSwitch" "Patch interface on an OVSSwitch"
def ifconfig( self, cmd ): def ifconfig( self, *args ):
cmd = ' '.join( args )
if cmd == 'up': if cmd == 'up':
"OVSIntf is always up" # OVSIntf is always up
return return
else: else:
raise Exception( 'OVSIntf cannot do ifconfig ' + cmd ) raise Exception( 'OVSIntf cannot do ifconfig ' + cmd )
...@@ -506,8 +515,8 @@ def __init__( self, node1, node2, **kwargs ): ...@@ -506,8 +515,8 @@ def __init__( self, node1, node2, **kwargs ):
self.isPatchLink = False self.isPatchLink = False
if ( type( node1 ) is mininet.node.OVSSwitch and if ( type( node1 ) is mininet.node.OVSSwitch and
type( node2 ) is mininet.node.OVSSwitch ): type( node2 ) is mininet.node.OVSSwitch ):
self.isPatchLink = True self.isPatchLink = True
kwargs.update( cls1=OVSIntf, cls2=OVSIntf ) kwargs.update( cls1=OVSIntf, cls2=OVSIntf )
Link.__init__( self, node1, node2, **kwargs ) Link.__init__( self, node1, node2, **kwargs )
def fastIntfPair( self, *args, **kwargs ): def fastIntfPair( self, *args, **kwargs ):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment