Ejemplo n.º 1
0
  private List<ServiceFunctionDictionary> createSfDictList(
      ServiceFunction sf, Class<? extends SlTransportType> transportType) {
    // For MPLS and MAC transport types, we want the SF to be MAC/VLAN
    Class<? extends SlTransportType> sfTransportType =
        (transportType.equals(VxlanGpe.class) ? transportType : Mac.class);

    SffSfDataPlaneLocatorBuilder sffSfDplBuilder = new SffSfDataPlaneLocatorBuilder();
    // TODO the vlanId needs to be the same as on the SF
    sffSfDplBuilder.setLocatorType(buildSfLocatorType(sfTransportType));
    sffSfDplBuilder.setTransport(sfTransportType);

    ServiceFunctionDictionaryBuilder sfDictBuilder = new ServiceFunctionDictionaryBuilder();
    sfDictBuilder.setName(sf.getName());
    sfDictBuilder.setType(sf.getType());
    sfDictBuilder.setSffSfDataPlaneLocator(sffSfDplBuilder.build());
    sfDictBuilder.setKey(new ServiceFunctionDictionaryKey(sf.getName()));

    // Augment the dictionary with an OfsPortBuilder if its not VxLan
    if (!transportType.equals(VxlanGpe.class)) {
      ServiceFunctionDictionary1Builder ofsSfDictBuilder = new ServiceFunctionDictionary1Builder();
      OfsPortBuilder ofsPortBuilder = new OfsPortBuilder();
      ofsPortBuilder.setMacAddress(new MacAddress(getNextMacAddress()));
      ofsPortBuilder.setPortId(SWITCH_PORT_STR);
      ofsSfDictBuilder.setOfsPort(ofsPortBuilder.build());
      sfDictBuilder.addAugmentation(ServiceFunctionDictionary1.class, ofsSfDictBuilder.build());
    }

    List<ServiceFunctionDictionary> sfDictList = new ArrayList<ServiceFunctionDictionary>();
    sfDictList.add(sfDictBuilder.build());

    return sfDictList;
  }
Ejemplo n.º 2
0
  private List<SffDataPlaneLocator> createSffDpls(Class<? extends SlTransportType> transportType) {
    int dplCount = (transportType.equals(VxlanGpe.class) ? 1 : 2);

    ArrayList<Integer> tunnelIds = new ArrayList<Integer>();
    int tunnelIdsIndex = 0;
    // This allows us to have adjacent SFFs with matching tunnel info
    if (transportType.equals(Mac.class)) {
      tunnelIds.add(0, Integer.valueOf(getLastSffVlanId()));
      tunnelIds.add(1, Integer.valueOf(getNextSffVlanId()));
    } else if (transportType.equals(Mpls.class)) {
      tunnelIds.add(0, Integer.valueOf(getLastSffMplsLabel()));
      tunnelIds.add(1, Integer.valueOf(getNextSffMplsLabel()));
    }

    List<SffDataPlaneLocator> sffDpls = new ArrayList<SffDataPlaneLocator>();
    for (int i = 0; i < dplCount; ++i) {
      SffDataPlaneLocatorName name =
          new SffDataPlaneLocatorName(SFF_DPL_NAME_PREFIX + String.valueOf(SFF_DPL_NAME_INDEX++));
      SffDataPlaneLocatorBuilder sffDplBuilder = new SffDataPlaneLocatorBuilder();
      sffDplBuilder.setKey(new SffDataPlaneLocatorKey(name));
      sffDplBuilder.setName(name);
      DataPlaneLocatorBuilder dplBuilder = new DataPlaneLocatorBuilder();
      // check the transport type to see what type of locator to build
      if (transportType.equals(Mac.class)) {
        dplBuilder.setLocatorType(
            buildLocatorTypeMac(getNextMacAddress(), tunnelIds.get(tunnelIdsIndex++)));
      } else if (transportType.equals(Mpls.class)) {
        dplBuilder.setLocatorType(buildLocatorTypeMpls(tunnelIds.get(tunnelIdsIndex++)));
      } else if (transportType.equals(VxlanGpe.class)) {
        dplBuilder.setLocatorType(buildLocatorTypeIp(getNextIpAddress(), VXLAN_UDP_PORT));
      }
      dplBuilder.setTransport(transportType);
      sffDplBuilder.setDataPlaneLocator(dplBuilder.build());

      // Augment the SFF DPL if its not VxLan
      if (!transportType.equals(VxlanGpe.class)) {

        SffDataPlaneLocator1Builder ofsSffDplBuilder = new SffDataPlaneLocator1Builder();
        OfsPortBuilder ofsPortBuilder = new OfsPortBuilder();
        ofsPortBuilder.setMacAddress(new MacAddress(getNextMacAddress()));
        ofsPortBuilder.setPortId(SWITCH_PORT_STR);
        ofsSffDplBuilder.setOfsPort(ofsPortBuilder.build());
        sffDplBuilder.addAugmentation(SffDataPlaneLocator1.class, ofsSffDplBuilder.build());
      }

      sffDpls.add(sffDplBuilder.build());
    }

    return sffDpls;
  }