MCPcopy Create free account
hub / github.com/mininet/mininet / addController

Method addController

examples/cluster.py:862–890  ·  view source on GitHub ↗

Patch to update IP address to global IP address

( self, *args, **kwargs )

Source from the content-addressed store, hash-verified

860
861 # pylint: disable=arguments-differ,signature-differs
862 def addController( self, *args, **kwargs ):
863 "Patch to update IP address to global IP address"
864 controller = Mininet.addController( self, *args, **kwargs )
865 controllerIP = controller.IP()
866 if ( not isinstance( controller, Controller ) or
867 not self.isLoopback( controller.IP() ) ):
868 return controller
869 # Find route to a different server IP address
870 serverIPs = [ ip for ip in self.serverIP.values()
871 if ip != controllerIP ]
872 if not serverIPs:
873 return None # no remote servers - loopback is fine
874 for remoteIP in serverIPs:
875 # Route should contain 'dev <intfname>'
876 route = controller.cmd( 'ip route get', remoteIP,
877 r'| egrep -o "dev\s[^[:space:]]+"' )
878 if not route:
879 raise Exception('addController: no route from', controller,
880 'to', remoteIP )
881 intf = route.split()[ 1 ].strip()
882 if intf != 'lo':
883 break
884 if intf == 'lo':
885 raise Exception( 'addController: could not find external '
886 'interface/IP for %s' % controller )
887 debug( 'adding', intf, 'to', controller )
888 Intf( intf, node=controller ).updateIP()
889 debug( controller, 'IP address updated to', controller.IP() )
890 return controller
891
892 # pylint: disable=arguments-differ,signature-differs
893 def buildFromTopo( self, *args, **kwargs ):

Callers 2

buildNodesMethod · 0.45
controllers.pyFile · 0.45

Calls 6

isLoopbackMethod · 0.95
IntfClass · 0.90
updateIPMethod · 0.80
IPMethod · 0.45
valuesMethod · 0.45
cmdMethod · 0.45

Tested by

no test coverage detected