import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ServiceType;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityService;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraint;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraintBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPoint;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointBuilder;
this.pceListenerImpl.setInput(input);
this.pceListenerImpl.setServiceUuid(serviceUuid);
this.rendererListenerImpl.setServiceUuid(serviceUuid);
- ListenableFuture<RpcResult<ServiceCreateOutput>> output = null;
- OperationResult validationResult = CreateConnectivityServiceValidation.validateCreateConnectivityServiceRequest(
- input);
- if (validationResult.isSuccess()) {
- LOG.info("input parameter of RPC create-connectivity are being handled");
- // check uuid of SIP in tapi context
- Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap = this.tapiContext.getTapiContext()
- .getServiceInterfacePoint();
- if (sipMap == null) {
- return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
- .withError(ErrorType.RPC, "SIP list is empty")
- .buildFuture();
- }
- if (sipMap.containsKey(new ServiceInterfacePointKey(input.getEndPoint().values().stream().findFirst()
- .orElseThrow().getServiceInterfacePoint().getServiceInterfacePointUuid()))
- && sipMap.containsKey(new ServiceInterfacePointKey(input.getEndPoint().values().stream().skip(1)
- .findFirst().orElseThrow().getServiceInterfacePoint().getServiceInterfacePointUuid()))) {
- LOG.info("SIPs found in sipMap");
- // TODO: differentiate between OTN service and GbE service in TAPI
- ServiceCreateInput sci = this.connectivityUtils.createORServiceInput(input, serviceUuid);
- if (sci == null) {
- return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
- .withError(ErrorType.RPC, "Couldnt map Service create input")
- .buildFuture();
- }
- LOG.info("Service Create input = {}", sci);
- output = rpcService.getRpc(ServiceCreate.class).invoke(sci);
- if (!output.isDone()) {
- return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
- .withError(ErrorType.RPC, "Service create RPC failed")
- .buildFuture();
- }
- } else {
- LOG.error("Unknown UUID");
- return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
- .withError(ErrorType.RPC, "SIPs do not exist in tapi context")
- .buildFuture();
- }
+ OperationResult validationResult =
+ CreateConnectivityServiceValidation.validateCreateConnectivityServiceRequest(input);
+ if (!validationResult.isSuccess()) {
+ return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
+ .withError(ErrorType.RPC, "Failed to create service")
+ .buildFuture();
+ }
+ LOG.info("input parameter of RPC create-connectivity are being handled");
+ // check uuid of SIP in tapi context
+ Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap =
+ this.tapiContext.getTapiContext().getServiceInterfacePoint();
+ if (sipMap == null) {
+ return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
+ .withError(ErrorType.RPC, "SIP list is empty")
+ .buildFuture();
+ }
+ if (!sipMap.containsKey(new ServiceInterfacePointKey(input.getEndPoint().values().stream().findFirst()
+ .orElseThrow().getServiceInterfacePoint().getServiceInterfacePointUuid()))
+ || !sipMap.containsKey(new ServiceInterfacePointKey(input.getEndPoint().values().stream().skip(1)
+ .findFirst().orElseThrow().getServiceInterfacePoint().getServiceInterfacePointUuid()))) {
+ LOG.error("Unknown UUID");
+ return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
+ .withError(ErrorType.RPC, "SIPs do not exist in tapi context")
+ .buildFuture();
+ }
+ LOG.info("SIPs found in sipMap");
+ // TODO: differentiate between OTN service and GbE service in TAPI
+ ServiceCreateInput sci = this.connectivityUtils.createORServiceInput(input, serviceUuid);
+ if (sci == null) {
+ return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
+ .withError(ErrorType.RPC, "Couldnt map Service create input")
+ .buildFuture();
}
+ LOG.info("Service Create input = {}", sci);
+ ListenableFuture<RpcResult<ServiceCreateOutput>> output = rpcService.getRpc(ServiceCreate.class).invoke(sci);
+ if (!output.isDone()) {
+ return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
+ .withError(ErrorType.RPC, "Service create RPC failed")
+ .buildFuture();
+ }
+ LOG.info("Service create request was successful");
try {
- if (output == null) {
- return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
- .withError(ErrorType.RPC, "Failed to create service")
- .buildFuture();
- }
- LOG.info("Service create request was successful");
if (output.get().getResult().getConfigurationResponseCommon().getResponseCode()
.equals(ResponseCodes.RESPONSE_FAILED)) {
return RpcResultBuilder.<CreateConnectivityServiceOutput>failed()
LOG.error("Error checking response code of service create", e);
}
// Connections and states should be created/updated when the pce and renderer are done :)
- Map<EndPointKey, EndPoint> endPointList = createEndPoints(input.getEndPoint());
Name name = new NameBuilder()
.setValueName("Connectivity Service Name")
.setValue(serviceUuid.getValue())
.build();
- ConnectivityConstraint conConstr = new ConnectivityConstraintBuilder()
- .setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY)
- .setServiceLevel(input.getConnectivityConstraint().getServiceLevel()).build();
-
ConnectivityService service = new ConnectivityServiceBuilder()
.setUuid(serviceUuid)
.setAdministrativeState(AdministrativeState.LOCKED)
.setOperationalState(OperationalState.DISABLED)
.setLifecycleState(LifecycleState.PLANNED)
.setLayerProtocolName(input.getLayerProtocolName())
- .setConnectivityConstraint(conConstr)
+ .setConnectivityConstraint(
+ new ConnectivityConstraintBuilder()
+ .setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY)
+ .setServiceLevel(input.getConnectivityConstraint().getServiceLevel())
+ .build())
.setDirection(ForwardingDirection.BIDIRECTIONAL)
.setName(Map.of(name.key(), name))
.setConnection(new HashMap<>())
- .setEndPoint(endPointList)
+ .setEndPoint(createEndPoints(input.getEndPoint()))
.build();
// add to tapi context
this.tapiContext.updateConnectivityContext(Map.of(service.key(), service), new HashMap<>());
LOG.info("Created locked service in Datastore. Waiting for PCE and Renderer to complete tasks...");
// return ConnectivityServiceCreateOutput
- return RpcResultBuilder.success(new CreateConnectivityServiceOutputBuilder()
- .setService(new ServiceBuilder(service).build()).build()).buildFuture();
+ return RpcResultBuilder.success(
+ new CreateConnectivityServiceOutputBuilder()
+ .setService(new ServiceBuilder(service).build())
+ .build())
+ .buildFuture();
}
private Map<EndPointKey, EndPoint> createEndPoints(
- Map<org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPointKey,
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) {
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .create.connectivity.service.input.EndPointKey,
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .create.connectivity.service.input.EndPoint> endPoints) {
Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
- for (org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint ep:
- endPoints.values()) {
+ for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .create.connectivity.service.input.EndPoint ep: endPoints.values()) {
EndPoint endpoint = new EndPointBuilder()
- .setServiceInterfacePoint(new ServiceInterfacePointBuilder()
- .setServiceInterfacePointUuid(ep.getServiceInterfacePoint().getServiceInterfacePointUuid())
- .build())
+ .setServiceInterfacePoint(
+ new ServiceInterfacePointBuilder()
+ .setServiceInterfacePointUuid(ep.getServiceInterfacePoint().getServiceInterfacePointUuid())
+ .build())
.setName(ep.getName())
.setAdministrativeState(ep.getAdministrativeState())
.setDirection(ep.getDirection())
.setLifecycleState(ep.getLifecycleState())
.setOperationalState(ep.getOperationalState())
.setLayerProtocolName(ep.getLayerProtocolName())
- // TODO: implement bandwidth profile
.setCapacity(new CapacityBuilder()
.setTotalSize(new TotalSizeBuilder().build())
-// .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
+ // TODO: implement bandwidth profile //.setBandwidthProfile(new BandwidthProfileBuilder().build())
.build())
.setProtectionRole(ep.getProtectionRole())
.setRole(ep.getRole())