Add addresses to fastIntfPair() and fix codecheck

This commit is contained in:
Bob Lantz
2015-01-15 02:07:00 -08:00
parent 5383b0e603
commit da4dcf3753
+17 -8
View File
@@ -390,6 +390,7 @@ class Link( object ):
# This is a bit awkward; it seems that having everything in
# params is more orthogonal, but being able to specify
# in-line arguments is more convenient! So we support both.
# pylint: disable=too-many-branches
if params1 is None:
params1 = {}
if params2 is None:
@@ -417,13 +418,13 @@ class Link( object ):
self.fastIntfPair( intfName1, intfName2, addr1, addr2,
node1=node1, node2=node2)
else:
self.makeIntfPair( intfName1, intfName2, addr1, addr2,
node1=node1, node2=node2)
self.makeIntfPair( intfName1, intfName2, addr1, addr2 )
if not cls1:
cls1 = intf
if not cls2:
cls2 = intf
# pylint: enable=too-many-branches
intf1 = cls1( name=intfName1, node=node1,
link=self, mac=addr1, **params1 )
@@ -445,8 +446,7 @@ class Link( object ):
return node.name + '-eth' + repr( n )
@classmethod
def makeIntfPair( cls, intfname1, intfname2, addr1=None, addr2=None,
node1=None, node2=None ):
def makeIntfPair( cls, intfname1, intfname2, addr1=None, addr2=None ):
"""Create pair of interfaces
intfname1: name of interface 1
intfname2: name of interface 2
@@ -465,8 +465,16 @@ class Link( object ):
intf2: name of interface 2
(override this class method [and possibly delete()]
to change link type)"""
return node1.cmd( 'ip link add', intfname1, 'type veth '
'peer name', intfname2, 'netns', node2.pid )
if addr1 is None and addr2 is None:
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 ):
"Delete this link"
@@ -488,9 +496,10 @@ class Link( object ):
class OVSIntf( Intf ):
"Patch interface on an OVSSwitch"
def ifconfig( self, cmd ):
def ifconfig( self, *args ):
cmd = ' '.join( args )
if cmd == 'up':
"OVSIntf is always up"
# OVSIntf is always up
return
else:
raise Exception( 'OVSIntf cannot do ifconfig ' + cmd )