def add_dynamic_tunnels(self, tunnel_source_ip, ip_fabric_nets,
                            bgp_router_ips):
        dynamic_tunnel = DynamicTunnel(name=DMUtils.dynamic_tunnel_name(
            self.get_asn()),
                                       source_address=tunnel_source_ip,
                                       gre='')
        if ip_fabric_nets is not None:
            for subnet in ip_fabric_nets.get("subnet", []):
                dest_net = subnet['ip_prefix'] + '/' + str(
                    subnet['ip_prefix_len'])
                dynamic_tunnel.add_destination_networks(
                    DestinationNetworks(
                        name=dest_net,
                        comment=DMUtils.ip_fabric_subnet_comment()))

        for r_name, bgp_router_ip in bgp_router_ips.items():
            dynamic_tunnel.add_destination_networks(
                DestinationNetworks(
                    name=bgp_router_ip + '/32',
                    comment=DMUtils.bgp_router_subnet_comment(r_name)))

        dynamic_tunnels = DynamicTunnels()
        dynamic_tunnels.add_dynamic_tunnel(dynamic_tunnel)
        if self.global_routing_options_config is None:
            self.global_routing_options_config = RoutingOptions(
                comment=DMUtils.routing_options_comment())
        self.global_routing_options_config.set_dynamic_tunnels(dynamic_tunnels)
    def add_dynamic_tunnels(self, tunnel_source_ip,
                            ip_fabric_nets, bgp_router_ips):
        if not self.system_config:
            self.system_config = System()
        self.system_config.set_tunnel_ip(tunnel_source_ip)
        dynamic_tunnel = DynamicTunnel(
            name=DMUtils.dynamic_tunnel_name(self.get_asn()),
            source_address=tunnel_source_ip, gre='')
        if ip_fabric_nets is not None:
            for subnet in ip_fabric_nets.get("subnet", []):
                dest_net = Subnet(prefix=subnet['ip_prefix'],
                                  prefix_len=subnet['ip_prefix_len'])
                self.system_config.add_tunnel_destination_networks(dest_net)

        for r_name, bgp_router_ip in bgp_router_ips.items():
            dest_net = Subnet(prefix=bgp_router_ip, prefix_len=32)
            self.system_config.add_tunnel_destination_networks(dest_net)
Exemplo n.º 3
0
    def add_dynamic_tunnels(self, tunnel_source_ip,
                             ip_fabric_nets, bgp_router_ips):
        dynamic_tunnel = DynamicTunnel(name=DMUtils.dynamic_tunnel_name(self.get_asn()),
                                       source_address=tunnel_source_ip, gre='')
        if ip_fabric_nets is not None:
            for subnet in ip_fabric_nets.get("subnet", []):
                dest_net = subnet['ip_prefix'] + '/' + str(subnet['ip_prefix_len'])
                dynamic_tunnel.add_destination_networks(
                    DestinationNetworks(name=dest_net,
                                        comment=DMUtils.ip_fabric_subnet_comment()))

        for r_name, bgp_router_ip in bgp_router_ips.items():
            dynamic_tunnel.add_destination_networks(
                DestinationNetworks(name=bgp_router_ip + '/32',
                                    comment=DMUtils.bgp_router_subnet_comment(r_name)))

        dynamic_tunnels = DynamicTunnels()
        dynamic_tunnels.add_dynamic_tunnel(dynamic_tunnel)
        if self.global_routing_options_config is None:
            self.global_routing_options_config = RoutingOptions(comment=DMUtils.routing_options_comment())
        self.global_routing_options_config.set_dynamic_tunnels(dynamic_tunnels)