Change Link/TCLink to accept universal parameters
This also enables us to specify IP addresses for both sides of a TCLink, which enables LinuxRouter to work with TCLink. fixes #854 fixes #634
This commit is contained in:
+17
-21
@@ -407,7 +407,7 @@ class Link( object ):
|
|||||||
def __init__( self, node1, node2, port1=None, port2=None,
|
def __init__( self, node1, node2, port1=None, port2=None,
|
||||||
intfName1=None, intfName2=None, addr1=None, addr2=None,
|
intfName1=None, intfName2=None, addr1=None, addr2=None,
|
||||||
intf=Intf, cls1=None, cls2=None, params1=None,
|
intf=Intf, cls1=None, cls2=None, params1=None,
|
||||||
params2=None, fast=True ):
|
params2=None, fast=True, **params ):
|
||||||
"""Create veth link to another node, making two new interfaces.
|
"""Create veth link to another node, making two new interfaces.
|
||||||
node1: first node
|
node1: first node
|
||||||
node2: second node
|
node2: second node
|
||||||
@@ -417,18 +417,15 @@ class Link( object ):
|
|||||||
cls1, cls2: optional interface-specific constructors
|
cls1, cls2: optional interface-specific constructors
|
||||||
intfName1: node1 interface name (optional)
|
intfName1: node1 interface name (optional)
|
||||||
intfName2: node2 interface name (optional)
|
intfName2: node2 interface name (optional)
|
||||||
params1: parameters for interface 1
|
params1: parameters for interface 1 (optional)
|
||||||
params2: parameters for interface 2"""
|
params2: parameters for interface 2 (optional)
|
||||||
|
**params: additional parameters for both interfaces"""
|
||||||
|
|
||||||
# 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.
|
||||||
if params1 is None:
|
params1 = dict( params1 ) if params1 else {}
|
||||||
params1 = {}
|
params2 = dict( params2 ) if params2 else {}
|
||||||
if params2 is None:
|
|
||||||
params2 = {}
|
|
||||||
# Allow passing in params1=params2
|
|
||||||
if params2 is params1:
|
|
||||||
params2 = dict( params1 )
|
|
||||||
if port1 is not None:
|
if port1 is not None:
|
||||||
params1[ 'port' ] = port1
|
params1[ 'port' ] = port1
|
||||||
if port2 is not None:
|
if port2 is not None:
|
||||||
@@ -442,6 +439,10 @@ class Link( object ):
|
|||||||
if not intfName2:
|
if not intfName2:
|
||||||
intfName2 = self.intfName( node2, params2[ 'port' ] )
|
intfName2 = self.intfName( node2, params2[ 'port' ] )
|
||||||
|
|
||||||
|
# Update with remaining parameter list
|
||||||
|
params1.update( params )
|
||||||
|
params2.update( params )
|
||||||
|
|
||||||
self.fast = fast
|
self.fast = fast
|
||||||
if fast:
|
if fast:
|
||||||
params1.setdefault( 'moveIntfFn', self._ignore )
|
params1.setdefault( 'moveIntfFn', self._ignore )
|
||||||
@@ -463,6 +464,7 @@ class Link( object ):
|
|||||||
|
|
||||||
# All we are is dust in the wind, and our two interfaces
|
# All we are is dust in the wind, and our two interfaces
|
||||||
self.intf1, self.intf2 = intf1, intf2
|
self.intf1, self.intf2 = intf1, intf2
|
||||||
|
|
||||||
# pylint: enable=too-many-branches
|
# pylint: enable=too-many-branches
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -548,17 +550,11 @@ class OVSLink( Link ):
|
|||||||
|
|
||||||
|
|
||||||
class TCLink( Link ):
|
class TCLink( Link ):
|
||||||
"Link with symmetric TC interfaces configured via opts"
|
"Link with TC interfaces"
|
||||||
def __init__( self, node1, node2, port1=None, port2=None,
|
def __init__( self, *args, **kwargs):
|
||||||
intfName1=None, intfName2=None,
|
kwargs.setdefault( 'cls1', TCIntf )
|
||||||
addr1=None, addr2=None, **params ):
|
kwargs.setdefault( 'cls2', TCIntf )
|
||||||
Link.__init__( self, node1, node2, port1=port1, port2=port2,
|
Link.__init__( self, *args, **kwargs)
|
||||||
intfName1=intfName1, intfName2=intfName2,
|
|
||||||
cls1=TCIntf,
|
|
||||||
cls2=TCIntf,
|
|
||||||
addr1=addr1, addr2=addr2,
|
|
||||||
params1=params,
|
|
||||||
params2=params )
|
|
||||||
|
|
||||||
|
|
||||||
class TCULink( TCLink ):
|
class TCULink( TCLink ):
|
||||||
|
|||||||
Reference in New Issue
Block a user