Example #1
0
    def gre(self, node):
        node.gre_tunnels = []
        if not self.anm.has_overlay('gre_tunnel'):
            return

        g_gre_tunnel = self.anm['gre_tunnel']
        if node not in g_gre_tunnel:
            return  # no gre tunnel for node

        gre_node = g_gre_tunnel.node(node)
        neighbors = gre_node.neighbors()
        for index, neigh in enumerate(neighbors, start=1):
            stanza = ConfigStanza(id=index, endpoint=neigh)

            # TODO: try/except here
            # TODO: Explain logic here
            src_int = g_gre_tunnel.edge(node, neigh).src_int
            tunnel_source = node.interface(src_int).id
            stanza.source = tunnel_source
            stanza.destination = "0.0.0.0"  # placeholder for user to replace

            if neigh.tunnel_enabled_ipv4:
                ip_address = neigh.tunnel_ipv4_address
                cidr = neigh.tunnel_ipv4_cidr
                stanza.ipv4_address = ip_address
                stanza.ipv4_subnet = cidr
                stanza.use_ipv4 = True

            if neigh.tunnel_enabled_ipv6:
                cidr = neigh.tunnel_ipv6_cidr
                stanza.ipv4_subnet = cidr
                stanza.use_ipv6 = True

            node.gre_tunnels.append(stanza)
Example #2
0
    def gre(self, node):
        node.gre_tunnels = []
        if not self.anm.has_overlay('gre_tunnel'):
            return

        g_gre_tunnel = self.anm['gre_tunnel']
        if node not in g_gre_tunnel:
            return   # no gre tunnel for node

        gre_node = g_gre_tunnel.node(node)
        neighbors = gre_node.neighbors()
        for index, neigh in enumerate(neighbors, start=1):
            stanza = ConfigStanza(id=index, endpoint=neigh)

            # TODO: try/except here
            # TODO: Explain logic here
            src_int = g_gre_tunnel.edge(node, neigh).src_int
            tunnel_source = node.interface(src_int).id
            stanza.source = tunnel_source
            stanza.destination = "0.0.0.0"  # placeholder for user to replace

            if neigh.tunnel_enabled_ipv4:
                ip_address = neigh.tunnel_ipv4_address
                cidr = neigh.tunnel_ipv4_cidr
                stanza.ipv4_address = ip_address
                stanza.ipv4_subnet = cidr
                stanza.use_ipv4 = True

            if neigh.tunnel_enabled_ipv6:
                cidr = neigh.tunnel_ipv6_cidr
                stanza.ipv4_subnet = cidr
                stanza.use_ipv6 = True

            node.gre_tunnels.append(stanza)