link: Fix circular import
Having an 'import mininet.node' in the link module causes a circular import as the node module also has a top-level import for the link module. In order to break the cycle, the import for the node module is delayed and executed only if using the sole class that actually needs it in the link module.
This commit is contained in:
+4
-3
@@ -26,7 +26,6 @@ Link: basic link class for creating veth pairs
|
||||
|
||||
from mininet.log import info, error, debug
|
||||
from mininet.util import makeIntfPair
|
||||
import mininet.node
|
||||
import re
|
||||
|
||||
class Intf( object ):
|
||||
@@ -504,10 +503,12 @@ class OVSLink( Link ):
|
||||
than ~64 OVS patch links should be used in row."""
|
||||
|
||||
def __init__( self, node1, node2, **kwargs ):
|
||||
from mininet.node import OVSSwitch
|
||||
|
||||
"See Link.__init__() for options"
|
||||
self.isPatchLink = False
|
||||
if ( isinstance( node1, mininet.node.OVSSwitch ) and
|
||||
isinstance( node2, mininet.node.OVSSwitch ) ):
|
||||
if ( isinstance( node1, OVSSwitch ) and
|
||||
isinstance( node2, OVSSwitch ) ):
|
||||
self.isPatchLink = True
|
||||
kwargs.update( cls1=OVSIntf, cls2=OVSIntf )
|
||||
Link.__init__( self, node1, node2, **kwargs )
|
||||
|
||||
Reference in New Issue
Block a user