Patch to update IP address to global IP address
( self, *args, **kwargs )
| 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 ): |