summaryrefslogtreecommitdiffstats
path: root/generic-resource-api/provider/src/main
diff options
context:
space:
mode:
authorCheung, Pat (kc1472) <kc1472@att.com>2019-03-11 17:23:05 +0000
committerCheung, Pat (kc1472) <kc1472@att.com>2019-03-11 18:09:40 +0000
commitdd6ec30e6a0141de5a4489b1c7c058419927d689 (patch)
tree875370af29e24843ce2b709755f742e4b2dcdce6 /generic-resource-api/provider/src/main
parent9f044980443b05e92fc961293416f9cda8deeac7 (diff)
Dublin yang model update
PNF support in Dublin Change-Id: Icb2a00b37be11e1d0ac1b13940c0c8053a2a5b64 Issue-ID: SDNC-633 Signed-off-by: Cheung, Pat (kc1472) <kc1472@att.com>
Diffstat (limited to 'generic-resource-api/provider/src/main')
-rw-r--r--generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java224
-rw-r--r--generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java13
2 files changed, 235 insertions, 2 deletions
diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
index 8c7e1a35..2a71e6d9 100644
--- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
+++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
@@ -96,6 +96,10 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutput;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.brg.response.information.BrgResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.connection.attachment.response.information.ConnectionAttachmentResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.contrail.route.response.information.ContrailRouteResponseInformationBuilder;
@@ -123,6 +127,7 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.tunnelxconn.response.information.TunnelxconnResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.response.information.VfModuleResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.response.information.PnfResponseInformationBuilder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -184,6 +189,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
private static final String SERVICE_OBJECT_PATH_PARAM = "service-object-path";
private static final String NETWORK_OBJECT_PATH_PARAM = "network-object-path";
private static final String VNF_OBJECT_PATH_PARAM = "vnf-object-path";
+ private static final String PNF_OBJECT_PATH_PARAM = "pnf-object-path";
private static final String VF_MODULE_OBJECT_PATH_PARAM = "vf-module-object-path";
private static final String UPDATING_MDSAL_ERROR_MESSAGE = "Caught Exception updating MD-SAL for {} [{}] \n";
private static final String UPDATING_MDSAL_ERROR_MESSAGE_2 = "Caught Exception updating MD-SAL for {} [{},{}] \n";
@@ -782,6 +788,224 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
}
+
+ @Override
+ public ListenableFuture<RpcResult<PnfTopologyOperationOutput>> pnfTopologyOperation(PnfTopologyOperationInput input) {
+
+ final String svcOperation = "pnf-topology-operation";
+ ServiceData serviceData;
+ ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
+ Properties properties = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ PnfTopologyOperationOutputBuilder responseBuilder = new PnfTopologyOperationOutputBuilder();
+
+ if (hasInvalidServiceId(input)) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ responseBuilder.setResponseCode("404");
+ responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
+ responseBuilder.setAckFinalIndicator("Y");
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Grab the service instance ID from the input buffer
+ String siid = input.getServiceInformation().getServiceInstanceId();
+
+ trySetSvcRequestId(input, responseBuilder);
+
+ /* Comment out mandatory check for pnf id for scenario wherein for assign/create request pnf-id is generated by
+ SDNC itself.
+ if (hasInvalidPnfId(input)) {
+ log.debug("exiting {} because of null or empty pnf-id", svcOperation);
+ responseBuilder.setResponseCode("404");
+ responseBuilder.setResponseMessage("invalid input, null or empty pnf-id");
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+ */
+
+ String pnfId = input.getPnfDetails().getPnfId();
+ ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, serviceDataBuilder);
+
+ ServiceDataBuilder operDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
+
+ // Set the serviceStatus based on input
+ setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader());
+ setServiceStatus(serviceStatusBuilder, input.getRequestInformation());
+
+ //
+ // setup a service-data object builder
+ // ACTION pnf-topology-operation
+ // INPUT:
+ // USES sdnc-request-header;
+ // USES request-information;
+ // USES service-information;
+ // USES pnf-details
+ // OUTPUT:
+ // USES pnf-topology-response-body;
+ // USES pnf-details
+ // USES service-information
+ //
+ // uses oper-status;
+
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
+ PnfTopologyOperationInputBuilder inputBuilder = new PnfTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(properties, inputBuilder.build());
+
+ log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build());
+ GenericResourceApiUtil.toProperties(properties, OPERATIONAL_DATA_PARAM, operDataBuilder);
+
+ // Call SLI sync method
+
+ ResponseObject responseObject = new ResponseObject("200", "");
+ String ackFinal = "Y";
+ String serviceObjectPath = null;
+ String pnfObjectPath = null;
+ Properties respProps = tryGetProperties(svcOperation, properties, serviceDataBuilder, responseObject);
+
+ if (respProps != null) {
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ if (pnfId == null) {
+ pnfId = respProps.getProperty("pnfId");
+ }
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ pnfObjectPath = respProps.getProperty(PNF_OBJECT_PATH_PARAM);
+ }
+
+ setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
+ serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
+ serviceStatusBuilder.setRpcName(svcOperation);
+
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ try {
+ saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
+ trySaveService(input, serviceBuilder);
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ }
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Got success from SLI
+ try {
+ serviceData = serviceDataBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
+
+ // service object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceData(serviceData);
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+
+ if (isValidRequest(input) && input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
+ // Only update operational tree on Assign
+ log.info(UPDATING_TREE_INFO_MESSAGE);
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ }
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ serviceResponseInformationBuilder.setInstanceId(siid);
+ serviceResponseInformationBuilder.setObjectPath(serviceObjectPath);
+ responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
+
+ PnfResponseInformationBuilder pnfResponseInformationBuilder = new PnfResponseInformationBuilder();
+ pnfResponseInformationBuilder.setInstanceId(pnfId);
+ pnfResponseInformationBuilder.setObjectPath(pnfObjectPath);
+ responseBuilder.setPnfResponseInformation(pnfResponseInformationBuilder.build());
+
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ responseBuilder.setResponseCode("500");
+ responseBuilder.setResponseMessage(e.getMessage());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ trySetResponseMessage(responseBuilder, responseObject);
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+
+ // return success
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private void trySetResponseMessage(PnfTopologyOperationOutputBuilder responseBuilder,
+ ResponseObject responseObject) {
+ if (responseObject.getMessage() != null) {
+ responseBuilder.setResponseMessage(responseObject.getMessage());
+ }
+ }
+
+ private void trySaveService(PnfTopologyOperationInput input, ServiceBuilder serviceBuilder) {
+ if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete)
+ || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
+
+ // Only update operational tree on activate or delete
+ log.info(UPDATING_TREE_INFO_MESSAGE);
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ }
+ }
+
+ private boolean hasInvalidPnfId(PnfTopologyOperationInput input) {
+ return input.getPnfDetails() == null || input.getPnfDetails().getPnfId() == null
+ || input.getPnfDetails().getPnfId().length() == 0;
+ }
+
+ private boolean hasInvalidServiceId(PnfTopologyOperationInput input) {
+ return input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ }
+
+ private void trySetSvcRequestId(PnfTopologyOperationInput input,
+ PnfTopologyOperationOutputBuilder responseBuilder) {
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+ }
+
+ private boolean isValidRequest(PnfTopologyOperationInput input) {
+ return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
+ }
+
+
@Override
public ListenableFuture<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(VnfTopologyOperationInput input) {
diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java
index 0ad9ac1c..63979833 100644
--- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java
+++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java
@@ -112,7 +112,16 @@ public class GenericResourceApiUtil extends MdsalHelper {
org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.resource.assignments.vnf.resource.assignments.vnf.networks.VnfNetworkBuilder u105 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.resource.assignments.vnf.resource.assignments.vnf.networks.VnfNetworkBuilder();
org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder u106 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder();
org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.structure.VnfTopologyIdentifierStructureBuilder u107 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.structure.VnfTopologyIdentifierStructureBuilder();
- org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder u110 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder();
- org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder u111 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder u108 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder u109 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.service.data.PnfsBuilder u110 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.service.data.PnfsBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.service.data.pnfs.PnfBuilder u111 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.service.data.pnfs.PnfBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.service.data.pnfs.pnf.PnfDataBuilder u112 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.service.data.pnfs.pnf.PnfDataBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.request.input.PnfRequestInputBuilder u113 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.request.input.PnfRequestInputBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.request.input.pnf.request.input.PnfInputParametersBuilder u114 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.request.input.pnf.request.input.PnfInputParametersBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.response.information.PnfResponseInformationBuilder u115 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.response.information.PnfResponseInformationBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.topology.identifier.structure.PnfTopologyIdentifierStructureBuilder u116 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.topology.identifier.structure.PnfTopologyIdentifierStructureBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationInputBuilder u117 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationInputBuilder();
+ org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationOutputBuilder u118 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationOutputBuilder();
}
}