示例#1
0
 def start(self):
     for n in self.values():
         for i in n.intfList():
             self.ip_allocs[str(i.ip)] = n
             # try:
             #     for sec in i.params[PRIVATE_IP_KEY]:
             #         self.ip_allocs[str(sec)] = n
             # except KeyError:
             #     pass
     log.info('*** Starting %s routers\n' % len(self.routers))
     for router in self.routers:
         log.info(router.name + ' ')
         #check that and modify what quagga does, just remove private things
         router.start()
     log.info('\n')
     #puts to all the hosts its default gateway
     log.info('*** Setting default host routes\n')
     for h in self.hosts:
         if 'defaultRoute' in h.params:
             continue  # Skipping hosts with explicit default route
         routers = []
         for itf in h.intfList():
             if itf.name == 'lo':
                 continue
             routers.extend(routers_in_bd(itf.params.get(BDOMAIN_KEY, ())))
         if routers:
             log.info('%s via %s, ' % (h.name, routers[0].node.name))
             h.setDefaultRoute('via %s' % routers[0].ip)
         else:
             log.info('%s is not connected to a router, ' % h.name)
     log.info('\n')
     super(IPNet, self).start()
示例#2
0
 def start(self):
     for n in self.values():
         for i in n.intfList():
             self.ip_allocs[str(i.ip)] = n
             try:
                 for sec in i.params[PRIVATE_IP_KEY]:
                     self.ip_allocs[str(sec)] = n
             except KeyError:
                 pass
     log.info("*** Starting %s routers\n" % len(self.routers))
     for router in self.routers:
         log.info(router.name + " ")
         router.start()
     log.info("\n")
     log.info("*** Setting default host routes\n")
     for h in self.hosts:
         if "defaultRoute" in h.params:
             continue  # Skipping hosts with explicit default route
         routers = []
         for itf in h.intfList():
             if itf.name == "lo":
                 continue
             routers.extend(routers_in_bd(itf.params.get(BDOMAIN_KEY, ())))
         if routers:
             log.info("%s via %s, " % (h.name, routers[0].node.name))
             h.setDefaultRoute("via %s" % routers[0].ip)
         else:
             log.info("%s is not connected to a router, " % h.name)
     log.info("\n")
     super(IPNet, self).start()
示例#3
0
 def build(self):
     super(IPNet, self).build()
     domains = self.broadcast_domains()
     log.info("*** Found %s broadcast domains\n" % len(domains))
     self.allocate_primaryIPS(domains)
     router_domains = filter(lambda x: x is not None and len(x) > 1, (routers_in_bd(d, IPRouter) for d in domains))
     allocations = self.allocate_privateIPs(router_domains)
     with open(self.private_ip_bindings, "w") as f:
         json.dump(
             {
                 str(net): {str(itf.node.id): itf.params.get(PRIVATE_IP_KEY, []) for itf in domains}
                 for net, domains in allocations
             },
             f,
         )
示例#4
0
    def start(self, timeout=None):
        """If the network has a set of nodes to test for convergence, this
        method will block until they can all ping each other.

        :param timeout: Maximal time in sec before giving up on the convergence
                        test"""
        for n in self.values():
            for i in n.intfList():
                self.ip_allocs[str(i.ip)] = n
                try:
                    for sec in i.params[PRIVATE_IP_KEY]:
                        self.ip_allocs[str(sec)] = n
                except KeyError:
                    pass
        log.info("*** Starting %s routers\n" % len(self.routers))
        for router in self.routers:
            log.info(router.name + " ")
            router.start()
        log.info("\n")
        log.info("*** Setting default host routes\n")
        for h in self.hosts:
            if "defaultRoute" in h.params:
                continue  # Skipping hosts with explicit default route
            routers = []
            for itf in h.intfList():
                if itf.name == "lo":
                    continue
                routers.extend(routers_in_bd(itf.params.get(BDOMAIN_KEY, ())))
            if routers:
                log.info("%s via %s, " % (h.name, routers[0].node.name))
                h.setDefaultRoute("via %s" % routers[0].ip)
            else:
                log.info("%s is not connected to a router, " % h.name)
        log.info("\n")
        super(IPNet, self).start()
        if self.wait_for_convergence:
            self._convergence_test(timeout)
示例#5
0
 def include_func(itf):
     return list(filter(lambda x: x.node != self,
                        routers_in_bd(itf.params.get(BDOMAIN_KEY, ()))))
示例#6
0
 def include_func(itf):
     return list(
         filter(lambda x: x.node != self,
                routers_in_bd(itf.params.get(BDOMAIN_KEY, ()))))