Example #1
0
  @Override
  public Future<RpcResult<DeleteRenderedPathOutput>> deleteRenderedPath(
      DeleteRenderedPathInput input) {

    boolean ret;
    RpcResultBuilder<DeleteRenderedPathOutput> rpcResultBuilder;
    // If a RSP is deleted we delete both SF and SFF operational states.
    SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(input.getName());
    SfcProviderServiceFunctionAPI.deleteServicePathFromServiceFunctionStateExecutor(
        input.getName());

    ret = SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(input.getName());
    DeleteRenderedPathOutputBuilder deleteRenderedPathOutputBuilder =
        new DeleteRenderedPathOutputBuilder();
    deleteRenderedPathOutputBuilder.setResult(ret);
    if (ret) {
      rpcResultBuilder = RpcResultBuilder.success(deleteRenderedPathOutputBuilder.build());
    } else {
      String message = "Error Deleting Rendered Service Path: " + input.getName();
      rpcResultBuilder =
          RpcResultBuilder.<DeleteRenderedPathOutput>failed()
              .withError(ErrorType.APPLICATION, message);
    }

    return Futures.immediateFuture(rpcResultBuilder.build());
  }
Example #2
0
  /**
   * This method gets all necessary information for a system to construct a NSH header and
   * associated overlay packet to target the first service hop of a Rendered Service Path
   *
   * <p>
   *
   * @param input RPC input including a Rendered Service Path name
   * @return RPC output including a renderedServicePathFirstHop.
   */
  @Override
  public Future<RpcResult<ReadRenderedServicePathFirstHopOutput>> readRenderedServicePathFirstHop(
      ReadRenderedServicePathFirstHopInput input) {

    RenderedServicePathFirstHop renderedServicePathFirstHop = null;
    RpcResultBuilder<ReadRenderedServicePathFirstHopOutput> rpcResultBuilder;

    renderedServicePathFirstHop =
        SfcProviderRenderedPathAPI.readRenderedServicePathFirstHop(input.getName());

    ReadRenderedServicePathFirstHopOutput renderedServicePathFirstHopOutput = null;
    if (renderedServicePathFirstHop != null) {
      ReadRenderedServicePathFirstHopOutputBuilder renderedServicePathFirstHopOutputBuilder =
          new ReadRenderedServicePathFirstHopOutputBuilder();
      renderedServicePathFirstHopOutputBuilder.setRenderedServicePathFirstHop(
          renderedServicePathFirstHop);
      renderedServicePathFirstHopOutput = renderedServicePathFirstHopOutputBuilder.build();

      rpcResultBuilder = RpcResultBuilder.success(renderedServicePathFirstHopOutput);
    } else {
      String message = "Error Reading RSP First Hop from DataStore: " + input.getName();
      rpcResultBuilder =
          RpcResultBuilder.<ReadRenderedServicePathFirstHopOutput>failed()
              .withError(ErrorType.APPLICATION, message);
    }

    return Futures.immediateFuture(rpcResultBuilder.build());
  }
Example #3
0
  /**
   * This method reads all the necessary information for the first hop of a Rendered Service Path by
   * ServiceFunctionTypeIdentity list.
   *
   * <p>
   *
   * @param input RPC input including a ServiceFunctionTypeIdentity list
   * @return RPC output including a renderedServicePathFirstHop.
   */
  @Override
  public Future<RpcResult<ReadRspFirstHopBySftListOutput>> readRspFirstHopBySftList(
      ReadRspFirstHopBySftListInput input) {
    RenderedServicePathFirstHop renderedServicePathFirstHop = null;
    renderedServicePathFirstHop =
        SfcProviderRenderedPathAPI.readRspFirstHopBySftList(input.getSfst(), input.getSftList());
    ReadRspFirstHopBySftListOutput readRspFirstHopBySftListOutput = null;
    if (renderedServicePathFirstHop != null) {
      ReadRspFirstHopBySftListOutputBuilder readRspFirstHopBySftListOutputBuilder =
          new ReadRspFirstHopBySftListOutputBuilder();
      readRspFirstHopBySftListOutputBuilder.setRenderedServicePathFirstHop(
          renderedServicePathFirstHop);
      readRspFirstHopBySftListOutput = readRspFirstHopBySftListOutputBuilder.build();
    }

    RpcResultBuilder<ReadRspFirstHopBySftListOutput> rpcResultBuilder =
        RpcResultBuilder.success(readRspFirstHopBySftListOutput);
    return Futures.immediateFuture(rpcResultBuilder.build());
  }
Example #4
0
  @Override
  public Future<RpcResult<CreateRenderedPathOutput>> createRenderedPath(
      CreateRenderedPathInput createRenderedPathInput) {

    ServiceFunctionPath createdServiceFunctionPath;
    RenderedServicePath renderedServicePath;
    RenderedServicePath revRenderedServicePath;
    CreateRenderedPathOutputBuilder createRenderedPathOutputBuilder =
        new CreateRenderedPathOutputBuilder();
    RpcResult<CreateRenderedPathOutput> rpcResult;
    String retRspName = null;

    createdServiceFunctionPath =
        SfcProviderServicePathAPI.readServiceFunctionPathExecutor(
            createRenderedPathInput.getParentServiceFunctionPath());

    if (createdServiceFunctionPath != null) {
      renderedServicePath =
          SfcProviderRenderedPathAPI.createRenderedServicePathAndState(
              createdServiceFunctionPath, createRenderedPathInput);
      if (renderedServicePath != null) {
        retRspName = renderedServicePath.getName();
        createRenderedPathOutputBuilder.setName(retRspName);
        rpcResult = RpcResultBuilder.success(createRenderedPathOutputBuilder.build()).build();

        if ((createdServiceFunctionPath.getClassifier() != null)
            && SfcProviderServiceClassifierAPI.readServiceClassifierExecutor(
                    createdServiceFunctionPath.getClassifier())
                != null) {
          SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierStateExecutor(
              createdServiceFunctionPath.getClassifier(), renderedServicePath.getName());
        } else {
          LOG.warn("Classifier not provided or does not exist");
        }

        if ((createdServiceFunctionPath.isSymmetric() != null)
            && createdServiceFunctionPath.isSymmetric()) {

          revRenderedServicePath =
              SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(
                  renderedServicePath);
          if (revRenderedServicePath == null) {
            LOG.error("Failed to create symmetric service path: {}");
          } else if ((createdServiceFunctionPath.getSymmetricClassifier() != null)
              && SfcProviderServiceClassifierAPI.readServiceClassifierExecutor(
                      createdServiceFunctionPath.getSymmetricClassifier())
                  != null) {
            SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierStateExecutor(
                createdServiceFunctionPath.getSymmetricClassifier(),
                revRenderedServicePath.getName());

          } else {
            LOG.warn("Symmetric Classifier not provided or does not exist");
          }
        }
      } else {
        rpcResult =
            RpcResultBuilder.<CreateRenderedPathOutput>failed()
                .withError(ErrorType.APPLICATION, "Failed to create RSP")
                .build();
      }

    } else {
      rpcResult =
          RpcResultBuilder.<CreateRenderedPathOutput>failed()
              .withError(ErrorType.APPLICATION, "Service Function Path does not exist")
              .build();
    }
    return Futures.immediateFuture(rpcResult);
  }