Esempio n. 1
0
    def feature_config(self, **kwargs):
        self.pi_map = OrderedDict()
        feature_config = Feature(name=self.feature_name())
        if not self._is_evpn(self._physical_router):
            return feature_config

        self.build_vpg_config()
        vn_dict = self._get_connected_vn_li_map()
        for vn_uuid, interfaces in list(vn_dict.items()):
            vn_obj = VirtualNetworkDM.get(vn_uuid)
            ri_obj = self._get_primary_ri(vn_obj)
            if ri_obj is None:
                continue
            ri_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1],
                                            vn_obj.vn_network_id, 'l2')
            export_targets, import_targets = self._get_export_import_targets(
                vn_obj, ri_obj)
            if import_targets:
                # from Current VN's all L2 DCI objects, add remote peer fabric
                # RTs (type 1 routes) to import targets
                import_targets |= vn_obj.get_dci_peer_fabric_rt(
                    self._physical_router)
            ri = self._build_ri_config(vn_obj, ri_name, ri_obj, interfaces,
                                       export_targets, import_targets,
                                       feature_config)
            feature_config.add_routing_instances(ri)

        for pi, li_map in list(self.pi_map.values()):
            pi.set_logical_interfaces(list(li_map.values()))
            feature_config.add_physical_interfaces(pi)

        return feature_config
Esempio n. 2
0
    def feature_config(self, **kwargs):
        pr = self._physical_router
        if not pr:
            return

        self.pi_map = OrderedDict()
        self.pi_map_leafspine = OrderedDict()
        self.ri_map = OrderedDict()
        self.ri_map_leafspine = OrderedDict()
        self.sc_zone_map = OrderedDict()
        self.sc_policy_map = OrderedDict()
        self.vlan_map = OrderedDict()
        self.svc_intf_vlans = OrderedDict({"vlan_names": []})
        self.ri_protocols_leafspine_map = defaultdict(dict)

        feature_config = Feature(name=self.feature_name())

        if pr.physical_router_role == "pnf":
            self.build_pnf_svc_config()

            for pi, li_map in list(self.pi_map.values()):
                pi.set_logical_interfaces(list(li_map.values()))
                feature_config.add_physical_interfaces(pi)

            feature_config.set_routing_instances(
                self._get_values_sorted_by_key(self.ri_map))

            feature_config.set_security_zones(
                self._get_values_sorted_by_key(self.sc_zone_map))

            feature_config.set_security_policies(
                self._get_values_sorted_by_key(self.sc_policy_map))

            return feature_config

        elif pr.physical_router_role in ["leaf", "spine"]:
            self.build_svc_chaining_config()

            for pi, li_map in list(self.pi_map_leafspine.values()):
                pi.set_logical_interfaces(list(li_map.values()))
                feature_config.add_physical_interfaces(pi)

            feature_config.set_vlans(
                self._get_values_sorted_by_key(self.vlan_map))

            feature_config.set_routing_instances(
                self._get_values_sorted_by_key(self.ri_map_leafspine))

            return feature_config

        else:
            return
    def feature_config(self, **kwargs):
        self._pi_map = OrderedDict()
        feature_config = Feature(name=self.feature_name())
        self._build_server_config(feature_config)

        for pi, li_map in list(self._pi_map.values()):
            pi.set_logical_interfaces(list(li_map.values()))
            feature_config.add_physical_interfaces(pi)

        if self._forwarding_options_config:
            feature_config.set_forwarding_options_config(
                self._forwarding_options_config)

        return feature_config
    def feature_config(self, **kwargs):
        self.pi_list = set()
        self.pp_map = OrderedDict()
        feature_config = Feature(name=self.feature_name())

        self._build_port_profile_interface_config()

        for pi in set(self.pi_list):
            feature_config.add_physical_interfaces(pi)

        for pp_name in self.pp_map:
            feature_config.add_port_profile(self.pp_map[pp_name])

        return feature_config
    def feature_config(self, **kwargs):
        self.pi_list = set()
        self.telemetry_map = OrderedDict()
        feature_config = Feature(name=self.feature_name())

        pr = self._physical_router
        tp_uuid = pr.telemetry_profile
        tp = TelemetryProfileDM.get(tp_uuid)
        sflow_profile_params = None
        sflow_profile_name = ''
        grpc_profile_params = None
        grpc_profile_name = ''
        tp_name = ''

        if tp:
            tp_name = tp.fq_name[-1] + "-" + tp.fq_name[-2]

            sflow_uuid = tp.sflow_profile
            sflow_profile = SflowProfileDM.get(sflow_uuid)
            if sflow_profile:
                sflow_profile_params = \
                    sflow_profile.sflow_params
                sflow_profile_name = sflow_profile.fq_name[-1] + \
                    "-" + sflow_profile.fq_name[-2]

            for interface_uuid in pr.physical_interfaces:
                interface = PhysicalInterfaceDM.get(interface_uuid)
                self._build_telemetry_interface_config(interface, tp_name,
                                                       sflow_profile_name,
                                                       sflow_profile_params)

            grpc_uuid = tp.grpc_profile
            grpc_profile = GrpcProfileDM.get(grpc_uuid)

            if grpc_profile:
                grpc_profile_params = grpc_profile.grpc_params
                grpc_profile_name = grpc_profile.fq_name[-1] + \
                    "-" + grpc_profile.fq_name[-2]

                self._build_telemetry_grpc_config(tp_name,
                                                  grpc_profile_name,
                                                  grpc_profile_params)

        for pi in self.pi_list:
            feature_config.add_physical_interfaces(pi)

        for telemetry_name in self.telemetry_map:
            feature_config.add_telemetry(self.telemetry_map[telemetry_name])

        return feature_config
    def feature_config(self, **kwargs):
        self.pi_map = OrderedDict()
        self.sg_pis = OrderedDict()
        self.firewall_config = None
        self.firewall_acl_list = []
        feature_config = Feature(name=self.feature_name())

        vn_dict = self._get_connected_vn_li_map()
        for vn_uuid, interfaces in list(vn_dict.items()):
            vn_obj = VirtualNetworkDM.get(vn_uuid)
            self._build_l2_evpn_interface_config(interfaces, vn_obj)

        feature_config.set_firewall(self.firewall_config)
        for pi, li_map in list(self.sg_pis.values()):
            pi.set_logical_interfaces(list(li_map.values()))
            feature_config.add_physical_interfaces(pi)
        return feature_config
    def feature_config(self, **kwargs):
        self.ri_map = {}
        self.firewall_config = None
        self.pi_map = OrderedDict()
        self.inet4_forwarding_filter = None
        self.inet6_forwarding_filter = None

        feature_config = Feature(name=self.feature_name())
        self._build_ri_config_for_dc()
        feature_config.set_routing_instances(
            self._get_values_sorted_by_key(self.ri_map))

        if self.firewall_config is not None:
            feature_config.set_firewall(self.firewall_config)

        for pi, li_map in list(self.pi_map.values()):
            pi.set_logical_interfaces(list(li_map.values()))
            feature_config.add_physical_interfaces(pi)

        return feature_config
    def feature_config(self, **kwargs):
        self.pi_map = OrderedDict()
        feature_config = Feature(name=self.feature_name())
        vns = self._get_connected_vn_ids()
        # use_gateway_ip = all(
        #     [c.additional_params.use_gateway_ip == 'True'
        #         for c in self._configs])
        erb_pr_role = self._physical_router.is_erb_only()
        # To make this code in line with monolithic code.
        use_gateway_ip = erb_pr_role

        if erb_pr_role:
            vn_li_map = self._get_vn_li_map('l2')
            vpg_vn_uuids = list(vn_li_map.keys())
            vns = list(set(vns) & set(vpg_vn_uuids))

        irb_ip_map = self._physical_router.allocate_irb_ips_for(
            vns, use_gateway_ip)
        for vn_uuid in vns:
            vn_obj = VirtualNetworkDM.get(vn_uuid)
            ri_obj = self._get_primary_ri(vn_obj)
            if ri_obj is None:
                continue
            ri_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1],
                                            vn_obj.vn_network_id, 'l3')
            export_targets, import_targets = self._get_export_import_targets(
                vn_obj, ri_obj)
            ri = self._build_ri_config(vn_obj, ri_name, ri_obj, export_targets,
                                       import_targets, feature_config,
                                       irb_ip_map.get(vn_uuid,
                                                      []), erb_pr_role)
            feature_config.add_routing_instances(ri)

        for pi, li_map in list(self.pi_map.values()):
            pi.set_logical_interfaces(list(li_map.values()))
            feature_config.add_physical_interfaces(pi)

        return feature_config
Esempio n. 9
0
    def feature_config(self, **kwargs):
        self.pi_map = OrderedDict()
        feature_config = Feature(name=self.feature_name())
        vn_map, dhcp_servers = self._get_interconnect_vn_map()
        internal_vn_ris = []
        routing_policies = {}

        vn_li_map = self._get_vn_li_map('l2')
        vpg_vn_uuids = list(vn_li_map.keys())
        for internal_vn, vn_list in list(vn_map.items()):
            if self._physical_router.is_erb_only():
                if internal_vn not in dhcp_servers:
                    vn_list = list(set(vn_list) & set(vpg_vn_uuids))
                    if len(vn_list) == 0:
                        continue
                else:
                    # We need to have only the DHCP VN's in the VN list so
                    # that we will create only the VNI and IRB for the DHCP VNs
                    dhcp_server_ips = dhcp_servers[internal_vn]
                    dhcp_ip_2_vn_map = self.get_dhcp_server_in_same_network(
                        dhcp_server_ips, vn_list)
                    vn_list = list(set(vn_list) & set(vpg_vn_uuids))
                    for ip, vn in list(dhcp_ip_2_vn_map.items()):
                        vn_list.append(vn)
                    vn_list = list(set(vn_list))

            vn_obj = VirtualNetworkDM.get(internal_vn)
            ri_obj = self._get_primary_ri(vn_obj)
            if ri_obj is None:
                continue

            lr_obj = LogicalRouterDM.get(vn_obj.logical_router)
            if lr_obj:
                is_master_int_vn = lr_obj.is_master

            ri = self._build_ri_config(vn_obj, ri_obj, lr_obj, vn_list,
                                       is_master_int_vn)

            fip_map = vn_obj.instance_ip_map
            if lr_obj.logical_router_gateway_external:
                prefixes = vn_obj.get_prefixes(self._physical_router.uuid)
                if not fip_map:
                    if prefixes:
                        # for DC-gateway, skip routed vn prefix for public LR
                        routed_vn_prefix = set()
                        if vn_obj:
                            routed_vn_prefix = vn_obj.get_prefixes(
                                pr_uuid=self._physical_router.uuid,
                                only_routedvn_prefix=True)
                        for prefix in prefixes:
                            ri.add_static_routes(
                                self._get_route_for_cidr(prefix))
                            if prefix in routed_vn_prefix:
                                # skip DC-gateway prefix for routed vn
                                continue
                            ri.add_prefixes(self._get_subnet_for_cidr(prefix))

            if dhcp_servers.get(internal_vn):
                in_network = self._is_dhcp_server_in_same_network(
                    dhcp_servers[internal_vn], vn_list)
                fwd_options = self._build_dhcp_relay_config(
                    vn_obj.logical_router, dhcp_servers[internal_vn],
                    in_network)
                ri.set_forwarding_options(fwd_options)
                rib_group_name = 'external_vrf_' + internal_vn
                ri.set_rib_group(rib_group_name)

            self._set_routed_vn_proto_info(ri,
                                           feature_config,
                                           vn_list,
                                           routing_policies=routing_policies)

            if len(lr_obj.loopback_pr_ip_map) > 0:
                if (lr_obj.loopback_pr_ip_map.get(self._physical_router.uuid,
                                                  None)) is not None:
                    self._set_routed_vn_proto_info(
                        ri,
                        feature_config, [lr_obj.loopback_vn_uuid],
                        True,
                        vn_obj.logical_router,
                        routing_policies=routing_policies)

            feature_config.add_routing_instances(ri)

            if ri.get_virtual_network_is_internal() is True:
                internal_vn_ris.append(ri)

        rib_map, rp_list = \
            DataCenterInterconnectDM.set_intrafabric_dci_config(
                self._physical_router.uuid, internal_vn_ris)
        for k, v in rp_list.items():
            routing_policies[k] = v
        for k, v in routing_policies.items():
            feature_config.add_routing_policies(v)
        for k, v in rib_map.items():
            feature_config.add_rib_groups(v)

        for pi, li_map in list(self.pi_map.values()):
            pi.set_logical_interfaces(list(li_map.values()))
            feature_config.add_physical_interfaces(pi)

        return feature_config