def _build_ri_config(self, vn, ri_name, ri_obj, export_targets, import_targets, feature_config, irb_ips, erb_pr_role): gevent.idle() network_id = vn.vn_network_id vxlan_id = vn.get_vxlan_vni() desc = DMUtils.vn_comment(vn) is_master_vn = False lr = None if vn.logical_router is None: # try updating logical router incase of DM restart vn.set_logical_router(vn.fq_name[-1]) lr_uuid = vn.logical_router if lr_uuid: lr = LogicalRouterDM.get(lr_uuid) if lr: if lr.is_master is True: is_master_vn = True ri = RoutingInstance(name=ri_name, virtual_network_mode='l3', export_targets=export_targets, import_targets=import_targets, virtual_network_id=str(network_id), vxlan_id=str(vxlan_id), is_public_network=vn.router_external, routing_instance_type='vrf', is_master=is_master_vn, comment=desc) for prefix in vn.get_prefixes(self._physical_router.uuid): ri.add_prefixes(self._get_subnet_for_cidr(prefix)) _, li_map = self._add_or_lookup_pi(self.pi_map, 'irb', 'irb') irb = None if irb_ips: irb = self._add_or_lookup_li(li_map, 'irb.' + str(network_id), network_id) if vn.has_ipv6_subnet is True: irb.set_is_virtual_router(True) for (irb_ip, gateway) in irb_ips: self._add_ip_address(irb, irb_ip, gateway=gateway) # This is a hack to advertise vrouter IP in underlay ebgp # Required in ERB-UCAST-GW when a VN is directly extended to a PR # Refererence: CEM-20163 if erb_pr_role and not lr: irb.set_comment("PR External IRB") elif lr and lr.is_master: irb.set_comment("Master LR IRB") vlan = Vlan(name=DMUtils.make_bridge_name(vxlan_id), vxlan_id=vxlan_id) vlan.set_description(desc) feature_config.add_vlans(vlan) if irb: self._add_ref_to_list(vlan.get_interfaces(), irb.get_name()) if erb_pr_role: # for ERB_xxx_gateway PR role, set vlan id for current vn self._set_vn_vlanid(vlan, vn) return ri
def _build_ri_config(self, vn, ri_name, ri_obj, interfaces, export_targets, import_targets, feature_config): gevent.idle() encapsulation_priorities = self._get_encapsulation_priorities() highest_encapsulation = encapsulation_priorities[0] network_id = vn.vn_network_id vxlan_id = vn.get_vxlan_vni() is_master_vn = False if vn.logical_router is None: # try updating logical router incase of DM restart vn.set_logical_router(vn.fq_name[-1]) lr_uuid = vn.logical_router if lr_uuid: lr = LogicalRouterDM.get(lr_uuid) if lr: if lr.is_master is True: is_master_vn = True ri = RoutingInstance(name=ri_name, virtual_network_mode='l2', export_targets=export_targets, import_targets=import_targets, virtual_network_id=str(network_id), vxlan_id=str(vxlan_id), is_public_network=vn.router_external, is_master=is_master_vn) ri.set_virtual_network_id(str(network_id)) ri.set_vxlan_id(str(vxlan_id)) ri.set_is_public_network(vn.router_external) vlan = None if highest_encapsulation == 'VXLAN': ri.set_routing_instance_type('virtual-switch') vlan = Vlan(name=DMUtils.make_bridge_name(vxlan_id), vxlan_id=vxlan_id) vlan.set_comment(DMUtils.vn_bd_comment(vn, 'VXLAN')) desc = "Virtual Network - %s" % vn.name vlan.set_description(desc) feature_config.add_vlans(vlan) for interface in interfaces: self._add_ref_to_list(vlan.get_interfaces(), interface.li_name) elif highest_encapsulation in ['MPLSoGRE', 'MPLSoUDP']: ri.set_routing_instance_type('evpn') self._build_l2_evpn_interface_config(interfaces, vn, vlan) return ri
def _build_ri_config(self, vn, ri_name, ri_obj, export_targets, import_targets, feature_config, irb_ips, erb_pr_role): gevent.idle() network_id = vn.vn_network_id vxlan_id = vn.get_vxlan_vni() is_master_vn = False if vn.logical_router is None: # try updating logical router incase of DM restart vn.set_logical_router(vn.fq_name[-1]) lr_uuid = vn.logical_router if lr_uuid: lr = LogicalRouterDM.get(lr_uuid) if lr: if lr.is_master is True: is_master_vn = True ri = RoutingInstance(name=ri_name, virtual_network_mode='l3', export_targets=export_targets, import_targets=import_targets, virtual_network_id=str(network_id), vxlan_id=str(vxlan_id), is_public_network=vn.router_external, routing_instance_type='vrf', is_master=is_master_vn) for prefix in vn.get_prefixes(self._physical_router.uuid): ri.add_prefixes(self._get_subnet_for_cidr(prefix)) _, li_map = self._add_or_lookup_pi(self.pi_map, 'irb', 'irb') irb = None if irb_ips: irb = self._add_or_lookup_li(li_map, 'irb.' + str(network_id), network_id) if vn.has_ipv6_subnet is True: irb.set_is_virtual_router(True) for (irb_ip, gateway) in irb_ips: self._add_ip_address(irb, irb_ip, gateway=gateway) vlan = Vlan(name=DMUtils.make_bridge_name(vxlan_id), vxlan_id=vxlan_id) desc = "Virtual Network - %s" % vn.name vlan.set_description(desc) feature_config.add_vlans(vlan) if irb: self._add_ref_to_list(vlan.get_interfaces(), irb.get_name()) if erb_pr_role: # for ERB_xxx_gateway PR role, set vlan id for current vn self._set_vn_vlanid(vlan, vn) return ri
def build_svc_chaining_irb_bd_config(self, svc_app_obj, left_right_params): left_fq_name = left_right_params["left_qfx_fq_name"] right_fq_name = left_right_params["right_qfx_fq_name"] left_svc_vlan = left_right_params["left_svc_vlan"] right_svc_vlan = left_right_params["right_svc_vlan"] left_svc_unit = left_right_params["left_svc_unit"] right_svc_unit = left_right_params["right_svc_unit"] for pnf_pi, intf_type in list(svc_app_obj.physical_interfaces.items()): pnf_pi_obj = PhysicalInterfaceDM.get(pnf_pi) for spine_pi in pnf_pi_obj.physical_interfaces: if spine_pi not in self._physical_router.physical_interfaces: continue spine_pi_obj = PhysicalInterfaceDM.get(spine_pi) if spine_pi_obj.fq_name == left_fq_name: li_name = spine_pi_obj.name + "." + left_svc_vlan li_fq_name = spine_pi_obj.fq_name + [ li_name.replace(":", "_") ] li_obj = LogicalInterfaceDM.find_by_fq_name(li_fq_name) if li_obj: # irb creation iip_obj = InstanceIpDM.get(li_obj.instance_ip) if iip_obj: irb_addr = iip_obj.instance_ip_address irb_unit = left_svc_unit left_irb_intf, li_map = self._add_or_lookup_pi( self.pi_map_leafspine, "irb", "irb") intf_unit = self._add_or_lookup_li( li_map, "irb." + str(irb_unit), irb_unit) intf_unit.set_comment("PNF-Service-Chaining") self._add_ip_address(intf_unit, irb_addr + "/29") # build BD config left_bd_vlan = Vlan( name=DMUtils.make_bridge_name(left_svc_unit), vxlan_id=left_svc_unit, ) left_bd_vlan.set_vlan_id(left_svc_vlan) left_bd_vlan.set_description( "PNF-Service-Chaining") left_bd_vlan.set_comment("PNF-Service-Chaining") self._add_ref_to_list( left_bd_vlan.get_interfaces(), "irb." + str(irb_unit), ) self.vlan_map[ left_bd_vlan.get_name()] = left_bd_vlan # create logical interfaces for the aggregated # interfaces left_svc_intf, li_map = self._add_or_lookup_pi( self.pi_map_leafspine, spine_pi_obj.name, "service", ) left_svc_intf_unit = self._add_or_lookup_li( li_map, left_fq_name[-1] + ".0", "0") left_svc_intf_unit.set_comment( "PNF-Service-Chaining") left_svc_intf_unit.set_family("ethernet-switching") vlan_left = Vlan(name="bd-" + left_svc_unit) if (vlan_left.get_name() not in self.svc_intf_vlans["vlan_names"]): left_svc_intf_unit.add_vlans(vlan_left) self.svc_intf_vlans["vlan_names"].append( vlan_left.get_name()) if spine_pi_obj.fq_name == right_fq_name: li_name = spine_pi_obj.name + "." + right_svc_vlan li_fq_name = spine_pi_obj.fq_name + [ li_name.replace(":", "_") ] li_obj = LogicalInterfaceDM.find_by_fq_name(li_fq_name) if li_obj: # irb creation iip_obj = InstanceIpDM.get(li_obj.instance_ip) if iip_obj: irb_addr = iip_obj.instance_ip_address irb_unit = right_svc_unit right_irb_intf, li_map = self._add_or_lookup_pi( self.pi_map_leafspine, "irb", "irb") intf_unit = self._add_or_lookup_li( li_map, "irb." + str(irb_unit), irb_unit) intf_unit.set_comment("PNF-Service-Chaining") self._add_ip_address(intf_unit, irb_addr + "/29") # build BD config right_bd_vlan = Vlan( name=DMUtils.make_bridge_name(right_svc_unit), vxlan_id=right_svc_unit, ) right_bd_vlan.set_vlan_id(right_svc_vlan) right_bd_vlan.set_description( "PNF-Service-Chaining") right_bd_vlan.set_comment("PNF-Service-Chaining") self._add_ref_to_list( right_bd_vlan.get_interfaces(), "irb." + str(irb_unit), ) self.vlan_map[ right_bd_vlan.get_name()] = right_bd_vlan # create logical interfaces for the aggregated # interfaces right_svc_intf, li_map = self._add_or_lookup_pi( self.pi_map_leafspine, spine_pi_obj.name, "service", ) right_svc_intf_unit = self._add_or_lookup_li( li_map, right_fq_name[-1] + ".0", "0") right_svc_intf_unit.set_comment( "PNF-Service-Chaining") right_svc_intf_unit.set_family( "ethernet-switching") vlan_right = Vlan(name="bd-" + right_svc_unit) if (vlan_right.get_name() not in self.svc_intf_vlans["vlan_names"]): right_svc_intf_unit.add_vlans(vlan_right) self.svc_intf_vlans["vlan_names"].append( vlan_right.get_name())