예제 #1
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();
 }
예제 #2
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();
 }