@Test public void createRenderedPathTest() throws Exception { init(); ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPath(SFP_NAME); assertNotNull("Must be not null", serviceFunctionPath); CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder(); createRenderedPathInputBuilder.setName(RSP_NAME.getValue()) .setParentServiceFunctionPath(SFP_NAME.getValue()) .setSymmetric(true); CreateRenderedPathInput createRenderedPathInput = createRenderedPathInputBuilder.build(); SfcProviderRenderedPathAPI.createRenderedServicePathAndState(serviceFunctionPath, createRenderedPathInput); List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffState(SFF_NAMES.get(0)); assertNotNull("Must be not null", sffServicePathList); assertEquals(sffServicePathList.get(0).getName().getValue(), RSP_NAME.getValue()); List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionState(new SfName("unittest-fw-1")); assertEquals(sfServicePathList.get(0).getName().getValue(), RSP_NAME.getValue()); List<SfpRenderedServicePath> sfpRenderedServicePathList = SfcProviderServicePathAPI.readServicePathState(SFP_NAME); assertEquals(sfpRenderedServicePathList.get(0).getName().getValue(), RSP_NAME.getValue()); ServiceFunctionClassifierBuilder serviceFunctionClassifierBuilder = new ServiceFunctionClassifierBuilder(); serviceFunctionClassifierBuilder.setName(SFP_NAME.getValue()); ServiceFunctionClassifier serviceFunctionClassifier = serviceFunctionClassifierBuilder.build(); InstanceIdentifier<ServiceFunctionClassifier> sclIID; ServiceFunctionClassifierKey serviceFunctionKey = new ServiceFunctionClassifierKey(SFP_NAME.getValue()); sclIID = InstanceIdentifier.builder(ServiceFunctionClassifiers.class) .child(ServiceFunctionClassifier.class, serviceFunctionKey) .build(); SfcDataStoreAPI.writePutTransactionAPI(sclIID, serviceFunctionClassifier, LogicalDatastoreType.CONFIGURATION); Future<RpcResult<CreateRenderedPathOutput>> result = sfcProviderRpc.createRenderedPath(createRenderedPathInput); assertNotNull(result); assertNotNull(result.get()); assertNotNull(result.get().getResult()); assertTrue(result.get().getErrors().isEmpty()); assertTrue(result.get().isSuccessful()); RenderedServicePath renderedServicePath = SfcProviderRenderedPathAPI.readRenderedServicePath(RSP_NAME); assertEquals(renderedServicePath.getName(), RSP_NAME); assertEquals(5, renderedServicePath.getRenderedServicePathHop().size()); assertHop(0, new SffName("SFF1"), renderedServicePath.getRenderedServicePathHop().get(0)); assertHop(1, new SffName("SFF2"), renderedServicePath.getRenderedServicePathHop().get(1)); ServiceFunctionClassifier serviceFunctionClassifierFromDataStore = SfcDataStoreAPI.readTransactionAPI(sclIID, LogicalDatastoreType.CONFIGURATION); assertEquals(SFP_NAME.getValue(), serviceFunctionClassifierFromDataStore.getName()); }
@Override public Future<RpcResult<CreateRenderedPathOutput>> createRenderedPath( CreateRenderedPathInput createRenderedPathInput) { ServiceFunctionPath createdServiceFunctionPath; RenderedServicePath renderedServicePath; RenderedServicePath revRenderedServicePath; CreateRenderedPathOutputBuilder createRenderedPathOutputBuilder = new CreateRenderedPathOutputBuilder(); RpcResult<CreateRenderedPathOutput> rpcResult; RspName retRspName = null; createdServiceFunctionPath = SfcProviderServicePathAPI .readServiceFunctionPath(new SfpName(createRenderedPathInput.getParentServiceFunctionPath())); if (createdServiceFunctionPath != null) { renderedServicePath = SfcProviderRenderedPathAPI .createRenderedServicePathAndState(createdServiceFunctionPath, createRenderedPathInput); if (renderedServicePath != null) { retRspName = renderedServicePath.getName(); createRenderedPathOutputBuilder.setName(retRspName.getValue()); rpcResult = RpcResultBuilder.success(createRenderedPathOutputBuilder.build()).build(); if (SfcProviderRenderedPathAPI.isChainSymmetric(createdServiceFunctionPath, renderedServicePath)) { revRenderedServicePath = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(renderedServicePath); if (revRenderedServicePath == null) { LOG.error("Failed to create symmetric service path: {}"); } else { SfcProviderRenderedPathAPI.setSymmetricPathId(renderedServicePath, revRenderedServicePath.getPathId()); } } } 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); }
SfcProviderRpc implements ServiceFunctionService, ServiceFunctionChainService, RenderedServicePathService,
        ServicePathIdService, RenderedIoamPathService { @Override public Future<RpcResult<CreateRenderedPathOutput>> createRenderedPath( CreateRenderedPathInput createRenderedPathInput) { ServiceFunctionPath createdServiceFunctionPath; RenderedServicePath renderedServicePath; RenderedServicePath revRenderedServicePath; CreateRenderedPathOutputBuilder createRenderedPathOutputBuilder = new CreateRenderedPathOutputBuilder(); RpcResult<CreateRenderedPathOutput> rpcResult; RspName retRspName = null; createdServiceFunctionPath = SfcProviderServicePathAPI .readServiceFunctionPath(new SfpName(createRenderedPathInput.getParentServiceFunctionPath())); if (createdServiceFunctionPath != null) { renderedServicePath = SfcProviderRenderedPathAPI .createRenderedServicePathAndState(createdServiceFunctionPath, createRenderedPathInput); if (renderedServicePath != null) { retRspName = renderedServicePath.getName(); createRenderedPathOutputBuilder.setName(retRspName.getValue()); rpcResult = RpcResultBuilder.success(createRenderedPathOutputBuilder.build()).build(); if (SfcProviderRenderedPathAPI.isChainSymmetric(createdServiceFunctionPath, renderedServicePath)) { revRenderedServicePath = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(renderedServicePath); if (revRenderedServicePath == null) { LOG.error("Failed to create symmetric service path: {}"); } else { SfcProviderRenderedPathAPI.setSymmetricPathId(renderedServicePath, revRenderedServicePath.getPathId()); } } } 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); } }
SfcProviderRpc implements ServiceFunctionService, ServiceFunctionChainService, RenderedServicePathService,
        ServicePathIdService, RenderedIoamPathService { @Override public Future<RpcResult<CreateRenderedPathOutput>> createRenderedPath( CreateRenderedPathInput createRenderedPathInput) { ServiceFunctionPath createdServiceFunctionPath; RenderedServicePath renderedServicePath; RenderedServicePath revRenderedServicePath; CreateRenderedPathOutputBuilder createRenderedPathOutputBuilder = new CreateRenderedPathOutputBuilder(); RpcResult<CreateRenderedPathOutput> rpcResult; RspName retRspName = null; createdServiceFunctionPath = SfcProviderServicePathAPI .readServiceFunctionPath(new SfpName(createRenderedPathInput.getParentServiceFunctionPath())); if (createdServiceFunctionPath != null) { renderedServicePath = SfcProviderRenderedPathAPI .createRenderedServicePathAndState(createdServiceFunctionPath, createRenderedPathInput); if (renderedServicePath != null) { retRspName = renderedServicePath.getName(); createRenderedPathOutputBuilder.setName(retRspName.getValue()); rpcResult = RpcResultBuilder.success(createRenderedPathOutputBuilder.build()).build(); if (SfcProviderRenderedPathAPI.isChainSymmetric(createdServiceFunctionPath, renderedServicePath)) { revRenderedServicePath = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(renderedServicePath); if (revRenderedServicePath == null) { LOG.error("Failed to create symmetric service path: {}"); } else { SfcProviderRenderedPathAPI.setSymmetricPathId(renderedServicePath, revRenderedServicePath.getPathId()); } } } 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); }  }
SfcProviderRpc implements ServiceFunctionService, ServiceFunctionChainService, RenderedServicePathService,
        ServicePathIdService, RenderedIoamPathService { @Override public Future<RpcResult<CreateRenderedPathOutput>> createRenderedPath( CreateRenderedPathInput createRenderedPathInput) { ServiceFunctionPath createdServiceFunctionPath; RenderedServicePath renderedServicePath; RenderedServicePath revRenderedServicePath; CreateRenderedPathOutputBuilder createRenderedPathOutputBuilder = new CreateRenderedPathOutputBuilder(); RpcResult<CreateRenderedPathOutput> rpcResult; RspName retRspName = null; createdServiceFunctionPath = SfcProviderServicePathAPI .readServiceFunctionPath(new SfpName(createRenderedPathInput.getParentServiceFunctionPath())); if (createdServiceFunctionPath != null) { renderedServicePath = SfcProviderRenderedPathAPI .createRenderedServicePathAndState(createdServiceFunctionPath, createRenderedPathInput); if (renderedServicePath != null) { retRspName = renderedServicePath.getName(); createRenderedPathOutputBuilder.setName(retRspName.getValue()); rpcResult = RpcResultBuilder.success(createRenderedPathOutputBuilder.build()).build(); if (SfcProviderRenderedPathAPI.isChainSymmetric(createdServiceFunctionPath, renderedServicePath)) { revRenderedServicePath = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(renderedServicePath); if (revRenderedServicePath == null) { LOG.error("Failed to create symmetric service path: {}"); } else { SfcProviderRenderedPathAPI.setSymmetricPathId(renderedServicePath, revRenderedServicePath.getPathId()); } } } 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); }  static SfcProviderRpc getSfcProviderRpc(); void setDataProvider(DataBroker r); static void setDataProviderAux(DataBroker r); @Override Future<RpcResult<Void>> deleteAllServiceFunction(); @Override Future<RpcResult<Void>> deleteServiceFunction(DeleteServiceFunctionInput input); @Override Future<RpcResult<Void>> putServiceFunction(PutServiceFunctionInput input); @Override Future<RpcResult<ReadServiceFunctionOutput>> readServiceFunction(ReadServiceFunctionInput input); @Override Future<RpcResult<InstantiateServiceFunctionChainOutput>> instantiateServiceFunctionChain(
            InstantiateServiceFunctionChainInput input); @Override Future<RpcResult<Void>> putServiceFunctionChains(PutServiceFunctionChainsInput input); @Override Future<RpcResult<CreateRenderedPathOutput>> createRenderedPath(
            CreateRenderedPathInput createRenderedPathInput); @Override Future<RpcResult<DeleteRenderedPathOutput>> deleteRenderedPath(DeleteRenderedPathInput input); @Override Future<RpcResult<ReadRenderedServicePathFirstHopOutput>> readRenderedServicePathFirstHop(
            ReadRenderedServicePathFirstHopInput input); @Override Future<RpcResult<ReadRspFirstHopBySftListOutput>> readRspFirstHopBySftList(
            ReadRspFirstHopBySftListInput input); @Override Future<RpcResult<TraceRenderedServicePathOutput>> traceRenderedServicePath(
            TraceRenderedServicePathInput input); @Override Future<RpcResult<ReservePathIdRangeOutput>> reservePathIdRange(ReservePathIdRangeInput input); @Override Future<RpcResult<ReadPathIdOutput>> readPathId(ReadPathIdInput input); @Override Future<RpcResult<AllocatePathIdOutput>> allocatePathId(AllocatePathIdInput input); @Override Future<RpcResult<DeletePathIdOutput>> deletePathId(DeletePathIdInput input); @Override Future<RpcResult<SetGenerationAlgorithmOutput>> setGenerationAlgorithm(SetGenerationAlgorithmInput input); @Override Future<RpcResult<CreateIoamPathOutput>> createIoamPath(final CreateIoamPathInput input); @Override Future<RpcResult<DeleteIoamPathOutput>> deleteIoamPath(DeleteIoamPathInput input); }
SfcProviderRpc implements ServiceFunctionService, ServiceFunctionChainService, RenderedServicePathService,
        ServicePathIdService, RenderedIoamPathService { @Override public Future<RpcResult<CreateRenderedPathOutput>> createRenderedPath( CreateRenderedPathInput createRenderedPathInput) { ServiceFunctionPath createdServiceFunctionPath; RenderedServicePath renderedServicePath; RenderedServicePath revRenderedServicePath; CreateRenderedPathOutputBuilder createRenderedPathOutputBuilder = new CreateRenderedPathOutputBuilder(); RpcResult<CreateRenderedPathOutput> rpcResult; RspName retRspName = null; createdServiceFunctionPath = SfcProviderServicePathAPI .readServiceFunctionPath(new SfpName(createRenderedPathInput.getParentServiceFunctionPath())); if (createdServiceFunctionPath != null) { renderedServicePath = SfcProviderRenderedPathAPI .createRenderedServicePathAndState(createdServiceFunctionPath, createRenderedPathInput); if (renderedServicePath != null) { retRspName = renderedServicePath.getName(); createRenderedPathOutputBuilder.setName(retRspName.getValue()); rpcResult = RpcResultBuilder.success(createRenderedPathOutputBuilder.build()).build(); if (SfcProviderRenderedPathAPI.isChainSymmetric(createdServiceFunctionPath, renderedServicePath)) { revRenderedServicePath = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(renderedServicePath); if (revRenderedServicePath == null) { LOG.error("Failed to create symmetric service path: {}"); } else { SfcProviderRenderedPathAPI.setSymmetricPathId(renderedServicePath, revRenderedServicePath.getPathId()); } } } 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); }  static SfcProviderRpc getSfcProviderRpc(); void setDataProvider(DataBroker r); static void setDataProviderAux(DataBroker r); @Override Future<RpcResult<Void>> deleteAllServiceFunction(); @Override Future<RpcResult<Void>> deleteServiceFunction(DeleteServiceFunctionInput input); @Override Future<RpcResult<Void>> putServiceFunction(PutServiceFunctionInput input); @Override Future<RpcResult<ReadServiceFunctionOutput>> readServiceFunction(ReadServiceFunctionInput input); @Override Future<RpcResult<InstantiateServiceFunctionChainOutput>> instantiateServiceFunctionChain(
            InstantiateServiceFunctionChainInput input); @Override Future<RpcResult<Void>> putServiceFunctionChains(PutServiceFunctionChainsInput input); @Override Future<RpcResult<CreateRenderedPathOutput>> createRenderedPath(
            CreateRenderedPathInput createRenderedPathInput); @Override Future<RpcResult<DeleteRenderedPathOutput>> deleteRenderedPath(DeleteRenderedPathInput input); @Override Future<RpcResult<ReadRenderedServicePathFirstHopOutput>> readRenderedServicePathFirstHop(
            ReadRenderedServicePathFirstHopInput input); @Override Future<RpcResult<ReadRspFirstHopBySftListOutput>> readRspFirstHopBySftList(
            ReadRspFirstHopBySftListInput input); @Override Future<RpcResult<TraceRenderedServicePathOutput>> traceRenderedServicePath(
            TraceRenderedServicePathInput input); @Override Future<RpcResult<ReservePathIdRangeOutput>> reservePathIdRange(ReservePathIdRangeInput input); @Override Future<RpcResult<ReadPathIdOutput>> readPathId(ReadPathIdInput input); @Override Future<RpcResult<AllocatePathIdOutput>> allocatePathId(AllocatePathIdInput input); @Override Future<RpcResult<DeletePathIdOutput>> deletePathId(DeletePathIdInput input); @Override Future<RpcResult<SetGenerationAlgorithmOutput>> setGenerationAlgorithm(SetGenerationAlgorithmInput input); @Override Future<RpcResult<CreateIoamPathOutput>> createIoamPath(final CreateIoamPathInput input); @Override Future<RpcResult<DeleteIoamPathOutput>> deleteIoamPath(DeleteIoamPathInput input);  }