def buildFromTopo(self, topo=None): """Build mininet from a topology object At the end of this function, everything should be connected and up.""" # Possibly we should clean up here and/or validate # the topo if self.cleanup: pass info('*** Creating network\n') if self.controllers: # Add a default controller info('*** Adding controller\n') classes = self.controller if type(classes) is not list: classes = [classes] for i, cls in enumerate(classes): self.addController('c%d' % i, cls) info('*** Adding hosts:\n') for hostName in topo.hosts(): #aqui ele adiciona os hosts mesmo. Funcao self.addHost retorna o host adicionado! So precisa entao pegar esse host, passar pra classe MetricsCollector e ja era. Ou se preferir, tem uma lista com todos os hosts self.hosts. self.addHost(hostName, **topo.nodeInfo(hostName)) info(hostName + ' ') #info( hostName + '\n' ) if self.switches: info('\n*** Adding switches:\n') for switchName in topo.switches(): self.addSwitch(switchName, **topo.nodeInfo(switchName)) info(switchName + ' ') info('\n*** Adding links:\n') #pdb.set_trace() for srcName, dstName in topo.links(sort=True): src, dst = self.nameToNode[srcName], self.nameToNode[dstName] params = topo.linkInfo(srcName, dstName) srcPort, dstPort = topo.port(srcName, dstName) self.addLink(src, dst, srcPort, dstPort, **params) if self.isCCNhost(src): src.setIP(ipStr(ipParse(self.ccnNetBase) + 1) + '/30', intf=src.name + '-eth' + str(srcPort)) dst.setIP(ipStr(ipParse(self.ccnNetBase) + 2) + '/30', intf=dst.name + '-eth' + str(dstPort)) self.ccnNetBase = nextCCNnet(self.ccnNetBase) info('(%s, %s) ' % (src.name, dst.name)) info('\n')
def buildFromTopo( self, topo=None ): """Build mininet from a topology object At the end of this function, everything should be connected and up.""" # Possibly we should clean up here and/or validate # the topo if self.cleanup: pass info( '*** Creating network\n' ) if self.controllers: # Add a default controller info( '*** Adding controller\n' ) classes = self.controller if type( classes ) is not list: classes = [ classes ] for i, cls in enumerate( classes ): self.addController( 'c%d' % i, cls ) info( '*** Adding hosts:\n' ) for hostName in topo.hosts(): #aqui ele adiciona os hosts mesmo. Funcao self.addHost retorna o host adicionado! So precisa entao pegar esse host, passar pra classe MetricsCollector e ja era. Ou se preferir, tem uma lista com todos os hosts self.hosts. self.addHost( hostName, **topo.nodeInfo( hostName ) ) info( hostName + ' ' ) #info( hostName + '\n' ) if self.switches: info( '\n*** Adding switches:\n' ) for switchName in topo.switches(): self.addSwitch( switchName, **topo.nodeInfo( switchName) ) info( switchName + ' ' ) info( '\n*** Adding links:\n' ) #pdb.set_trace() for srcName, dstName in topo.links(sort=True): src, dst = self.nameToNode[ srcName ], self.nameToNode[ dstName ] params = topo.linkInfo( srcName, dstName ) srcPort, dstPort = topo.port( srcName, dstName ) self.addLink( src, dst, srcPort, dstPort, **params ) if self.isCCNhost(src): src.setIP(ipStr(ipParse(self.ccnNetBase) + 1) + '/30', intf=src.name + '-eth' + str(srcPort)) dst.setIP(ipStr(ipParse(self.ccnNetBase) + 2) + '/30', intf=dst.name + '-eth' + str(dstPort)) self.ccnNetBase=nextCCNnet(self.ccnNetBase) info( '(%s, %s) ' % ( src.name, dst.name ) ) info( '\n' )
def buildFromTopo( self, topo=None ): """Build mininet from a topology object At the end of this function, everything should be connected and up.""" # Possibly we should clean up here and/or validate # the topo if self.cleanup: pass info( '*** Creating network\n' ) #if not self.controllers: # Add a default controller #info( '*** Adding controller\n' ) #classes = self.controller #if type( classes ) is not list: # classes = [ classes ] #for i, cls in enumerate( classes ): # self.addController( 'c%d' % i, cls ) info( '*** Adding hosts:\n' ) for hostName in topo.hosts(): #pdb.set_trace() self.addHost( hostName, **topo.nodeInfo( hostName ) ) info( hostName + ' ' ) info( '\n*** Adding switches:\n' ) for switchName in topo.switches(): self.addSwitch( switchName, **topo.nodeInfo( switchName) ) info( switchName + ' ' ) info( '\n*** Adding links:\n' ) for srcName, dstName in topo.links(sort=True): src, dst = self.nameToNode[ srcName ], self.nameToNode[ dstName ] params = topo.linkInfo( srcName, dstName ) srcPort, dstPort = topo.port( srcName, dstName ) self.addLink( src, dst, srcPort, dstPort, **params ) if self.isCCNhost(src): src.setIP(ipStr(ipParse(self.ccnNetBase) + 1) + '/30', intf=src.name + '-eth' + str(srcPort)) dst.setIP(ipStr(ipParse(self.ccnNetBase) + 2) + '/30', intf=dst.name + '-eth' + str(dstPort)) self.ccnNetBase=nextCCNnet(self.ccnNetBase) info( '(%s, %s) ' % ( src.name, dst.name ) ) info( '\n' )
def buildFromTopo( self, topo=None ): """Build mininet from a topology object At the end of this function, everything should be connected and up.""" # Possibly we should clean up here and/or validate # the topo if self.cleanup: pass info( '*** Creating network\n' ) if not self.controllers: # Add a default controller info( '*** Adding controller\n' ) classes = self.controller if type( classes ) is not list: classes = [ classes ] for i, cls in enumerate( classes ): self.addController( 'c%d' % i, cls ) info( '*** Adding hosts:\n' ) for hostName in topo.hosts(): self.addHost( hostName, **topo.nodeInfo( hostName ) ) info( hostName + ' ' ) info( '\n*** Adding switches:\n' ) for switchName in topo.switches(): self.addSwitch( switchName, **topo.nodeInfo( switchName) ) info( switchName + ' ' ) info( '\n*** Adding links:\n' ) for srcName, dstName in topo.links(sort=True): src, dst = self.nameToNode[ srcName ], self.nameToNode[ dstName ] params = topo.linkInfo( srcName, dstName ) srcPort, dstPort = topo.port( srcName, dstName ) self.addLink( src, dst, srcPort, dstPort, **params ) if self.isCCNhost(src): src.setIP(ipStr(ipParse(self.ccnNetBase) + 1) + '/30', intf=src.name + '-eth' + str(srcPort)) dst.setIP(ipStr(ipParse(self.ccnNetBase) + 2) + '/30', intf=dst.name + '-eth' + str(dstPort)) self.ccnNetBase=nextCCNnet(self.ccnNetBase) info( '(%s, %s) ' % ( src.name, dst.name ) ) info( '\n' )