Example #1
0
 /**
  * Convert To yang object VpnInstAfs.
  *
  * @param vrfEntity virtual routing forwarding entity
  * @return VpnInstAfs
  */
 public static VpnInstAfs convertToVpnInstAfs(VrfEntity vrfEntity) {
   VpnInstAfsBuilder vpnInstAfsBuilder = new VpnInstAfsBuilder();
   List<VpnInstAf> vpnInstAfList = new ArrayList<VpnInstAf>();
   VpnInstAfBuilder vpnInstAfBuilder = new VpnInstAfBuilder();
   vpnInstAfBuilder.afType(L3VpncommonL3VpnPrefixType.of(L3VpncommonL3VpnPrefixTypeEnum.IPV4UNI));
   // Vrf Route Distinguisher
   vpnInstAfBuilder.vrfRd(vrfEntity.routeDistinguisher());
   // Vpn Targets
   List<VpnTarget> vpnTargetList = new ArrayList<VpnTarget>();
   List<String> erts = vrfEntity.exportTargets();
   if (erts != null && !erts.isEmpty()) {
     for (String ert : erts) {
       VpnTargetBuilder vpnErtTargetBuilder = new VpnTargetBuilder();
       vpnErtTargetBuilder.vrfRttype(
           L3VpncommonVrfRtType.of(L3VpncommonVrfRtTypeEnum.EXPORT_EXTCOMMUNITY));
       vpnErtTargetBuilder.vrfRtvalue(ert);
       vpnTargetList.add(vpnErtTargetBuilder.build());
     }
   }
   List<String> irts = vrfEntity.importTargets();
   if (irts != null && !irts.isEmpty()) {
     for (String irt : irts) {
       VpnTargetBuilder vpnIrtTargetBuilder = new VpnTargetBuilder();
       vpnIrtTargetBuilder.vrfRttype(
           L3VpncommonVrfRtType.of(L3VpncommonVrfRtTypeEnum.IMPORT_EXTCOMMUNITY));
       vpnIrtTargetBuilder.vrfRtvalue(irt);
       vpnTargetList.add(vpnIrtTargetBuilder.build());
     }
   }
   VpnTargets vpnTargets = new VpnTargetsBuilder().vpnTarget(vpnTargetList).build();
   vpnInstAfBuilder.vpnTargets(vpnTargets);
   vpnInstAfList.add(vpnInstAfBuilder.build());
   vpnInstAfsBuilder.vpnInstAf(vpnInstAfList);
   return vpnInstAfsBuilder.build();
 }
Example #2
0
 /**
  * Convert To yang object Bgpcomm.
  *
  * @param vpnInstance VpnInstance
  * @return Bgpcomm
  */
 public static Bgpcomm convertToBgpComm(VpnInstance vpnInstance) {
   BgpcommBuilder bgpcommBuilder = new BgpcommBuilder();
   BgpVrfsBuilder bgpVrfsBuilder = new BgpVrfsBuilder();
   List<BgpVrf> bgpVrfList = new ArrayList<BgpVrf>();
   for (VrfEntity vrfEntity : vpnInstance.vrfList()) {
     Bgp bgp = vrfEntity.bgp();
     BgpVrfBuilder bgpVrfBuilder = new BgpVrfBuilder();
     BgpVrfAfsBuilder bgpVrfAfsBuilder = new BgpVrfAfsBuilder();
     List<BgpVrfAf> bgpVrfAfList = new ArrayList<BgpVrfAf>();
     BgpVrfAfBuilder bgpVrfAfBuilder = new BgpVrfAfBuilder();
     ImportRoutesBuilder importRoutesBuilder = new ImportRoutesBuilder();
     List<ImportRoute> importRouteList = new ArrayList<ImportRoute>();
     for (BgpImportProtocol importPro : bgp.importProtocols()) {
       ImportRouteBuilder importRouteBuilder = new ImportRouteBuilder();
       switch (importPro.protocolType()) {
         case DIRECT:
           importRouteBuilder.importProtocol(
               new BgpcommImRouteProtocol(BgpcommImRouteProtocolEnum.DIRECT));
           break;
         case BGP:
           importRouteBuilder.importProtocol(
               new BgpcommImRouteProtocol(BgpcommImRouteProtocolEnum.STATIC));
           break;
         case ISIS:
           importRouteBuilder.importProtocol(
               new BgpcommImRouteProtocol(BgpcommImRouteProtocolEnum.ISIS));
           break;
         case OSPF:
           importRouteBuilder.importProtocol(
               new BgpcommImRouteProtocol(BgpcommImRouteProtocolEnum.OSPF));
           break;
         default:
           break;
       }
       importRouteBuilder.importProcessId(importPro.processId());
       importRouteList.add(importRouteBuilder.build());
     }
     importRoutesBuilder.importRoute(importRouteList);
     bgpVrfAfBuilder.importRoutes(importRoutesBuilder.build());
     bgpVrfAfBuilder.afType(new BgpcommPrefixType(BgpcommPrefixTypeEnum.IPV4UNI));
     bgpVrfAfList.add(bgpVrfAfBuilder.build());
     bgpVrfAfsBuilder.bgpVrfAf(bgpVrfAfList);
     bgpVrfBuilder.bgpVrfAfs(bgpVrfAfsBuilder.build());
     bgpVrfBuilder.vrfName(vrfEntity.vrfName());
     bgpVrfList.add(bgpVrfBuilder.build());
   }
   bgpVrfsBuilder.bgpVrf(bgpVrfList);
   bgpcommBuilder.bgpVrfs(bgpVrfsBuilder.build());
   return bgpcommBuilder.build();
 }
Example #3
0
 /**
  * Convert To yang object L3vpnInstances.
  *
  * @param vpnAcForVrfMap vpnAcForVrfMap
  * @return L3VpnInstances
  */
 public static L3VpnInstances convertToL3vpnInstances(
     Map<VrfEntity, HashSet<VpnAc>> vpnAcForVrfMap) {
   L3VpnInstancesBuilder l3VpnInstancesBuilder = new L3VpnInstancesBuilder();
   List<L3VpnInstance> l3VpnInstanceList = new ArrayList<L3VpnInstance>();
   for (Map.Entry<VrfEntity, HashSet<VpnAc>> entry : vpnAcForVrfMap.entrySet()) {
     VrfEntity vrfEntity = entry.getKey();
     HashSet<VpnAc> vpnAcs = entry.getValue();
     L3VpnInstanceBuilder l3vpnInstanceBuilder = new L3VpnInstanceBuilder();
     l3vpnInstanceBuilder.vrfName(vrfEntity.vrfName());
     VpnInstAfs vpnInstAfs = convertToVpnInstAfs(vrfEntity);
     l3vpnInstanceBuilder.vpnInstAfs(vpnInstAfs);
     L3VpnIfs l3VpnIfs = convertToL3VpnIfs(vpnAcs);
     l3vpnInstanceBuilder.l3VpnIfs(l3VpnIfs);
     l3VpnInstanceList.add(l3vpnInstanceBuilder.build());
   }
   l3VpnInstancesBuilder.l3VpnInstance(l3VpnInstanceList);
   return l3VpnInstancesBuilder.build();
 }