From 60e537f9bcd361e10ebc89c33f4c8cb6d82dd2c5 Mon Sep 17 00:00:00 2001 From: Olivier Tilmans Date: Mon, 21 Mar 2016 15:08:02 +0100 Subject: [PATCH] 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. --- mininet/link.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mininet/link.py b/mininet/link.py index 9703ce7..86c72ab 100644 --- a/mininet/link.py +++ b/mininet/link.py @@ -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 )