예제 #1
0
  private void buildGroup(ServiceFunctionGroup sfg, boolean isAdd) {
    try {
      List<SfcServiceFunction> sfs = sfg.getSfcServiceFunction();
      SfName sfName = new SfName(sfs.get(0).getName());
      ServiceFunction sf = SfcProviderServiceFunctionAPI.readServiceFunction(sfName);
      // assuming all SF's have the same SFF
      // should use the ovs id
      SffName sffName = sf.getSfDataPlaneLocator().get(0).getServiceFunctionForwarder();
      String sffNodeId = null;
      sffNodeId = getSffOpenFlowNodeName(sffName);

      if (sffNodeId == null) {
        LOG.warn("failed to find switch configuration: sffName: {}- \naborting", sffName);
        return;
      }

      ServiceFunctionGroupAlgorithm algorithm =
          SfcProviderServiceFunctionGroupAlgAPI.readServiceFunctionGroupAlg(sfg.getAlgorithm());

      List<GroupBucketInfo> bucketsInfo = new ArrayList<GroupBucketInfo>();

      ServiceFunctionForwarder sff =
          SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(sffName);

      int index = 0;
      for (SfcServiceFunction sfcServiceFunction : sfg.getSfcServiceFunction()) {
        sfName = new SfName(sfcServiceFunction.getName());
        sf = SfcProviderServiceFunctionAPI.readServiceFunction(sfName);
        ServiceFunctionDictionary sffSfDict = sfcL2ProviderUtils.getSffSfDictionary(sff, sfName);
        String outPort = sfcL2ProviderUtils.getDictPortInfoPort(sff, sffSfDict);
        bucketsInfo.add(buildBucket(sf, outPort, index));
        index++;
      }
      this.sfcL2FlowProgrammer.configureGroup(
          sffName.getValue(),
          sffNodeId,
          sfg.getName(),
          sfg.getGroupId(),
          algorithm.getAlgorithmType().getIntValue(),
          bucketsInfo,
          isAdd);

    } catch (Exception e) {
      LOG.warn("Failed generating group " + sfg, e);
    }
  }
 public static List<String> getSfgNameList(ServiceFunctionChain serviceFunctionChain) {
   List<String> ret = new ArrayList<>();
   List<SfcServiceFunction> sfcServiceFunction = serviceFunctionChain.getSfcServiceFunction();
   LOG.debug(
       "searching groups for chain {} which has the elements {}",
       serviceFunctionChain.getName(),
       serviceFunctionChain.getSfcServiceFunction());
   if (sfcServiceFunction != null) {
     for (SfcServiceFunction sf : sfcServiceFunction) {
       ServiceFunctionGroup sfg =
           SfcProviderServiceFunctionGroupAPI.getServiceFunctionGroupByType(sf.getType());
       LOG.debug("look for service function group of type {} and found {}", sf.getType(), sfg);
       if (sfg != null) {
         ret.add(sfg.getName());
       } else {
         return null;
       }
     }
   }
   return ret;
 }