diff options
22 files changed, 248 insertions, 115 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index 0900863a62..e5c9514fa5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -158,7 +158,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index 0f1bf0d8b4..7beafefc28 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -23,12 +23,10 @@ package org.onap.so.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.SliceProfile -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils @@ -38,6 +36,7 @@ import org.slf4j.LoggerFactory class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class); + final String AAI_VERSION = "v21" JsonUtils jsonUtil = new JsonUtils() TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -67,23 +66,26 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { void createSliceProfile(DelegateExecution execution) { - String sliceserviceInstanceId = execution.getVariable("sliceServiceInstanceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String sliceProfileStr = execution.getVariable("sliceProfile") String sliceProfileId = UUID.randomUUID().toString() SliceProfile sliceProfile = new SliceProfile(); sliceProfile.setProfileId(sliceProfileId) sliceProfile.setLatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) sliceProfile.setResourceSharingLevel(jsonUtil.getJsonValue(sliceProfileStr, "resourceSharingLevel")) - sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)) //TODO: should be list + //sliceProfile.setSNssai(tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr)) - sliceProfile.setE2ELatency(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "latency"))) sliceProfile.setMaxBandwidth(Integer.parseInt(jsonUtil.getJsonValue(sliceProfileStr, "maxBandwidth"))) - //TODO: new API - sliceProfile.setReliability(new Object()) + //sliceProfile.setReliability(new Object()) try { AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceserviceInstanceId).sliceProfile(sliceProfileId)) + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId) + .sliceProfile(sliceProfileId)) client.create(uri, sliceProfile) } catch (BpmnError e) { @@ -112,20 +114,25 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { ss.setOrchestrationStatus(serviceStatus) String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - ss.setModelInvariantId(modelInvariantUuid) - ss.setModelVersionId(modelUuid) + //TODO: need valid model ID from the caller, as AAI does not accept invalid IDs + //ss.setModelInvariantId(modelInvariantUuid) + //ss.setModelVersionId(modelUuid) String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) ss.setServiceInstanceLocationId(serviceInstanceLocationid) String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) ss.setEnvironmentContext(snssai) ss.setServiceRole(serviceRole) AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ssInstanceId)) + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId)) client.create(uri, ss) } catch (BpmnError e) { throw e } catch (Exception ex) { - String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance. " + ex.getMessage() + String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance: " + ex.getMessage() logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -133,17 +140,19 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { void createAllottedResource(DelegateExecution execution) { - String serviceInstanceId = execution.getVariable('sliceServiceInstanceId') - - AAIResourcesClient resourceClient = getAAIClient() - AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + String ssInstanceId = execution.getVariable('sliceServiceInstanceId') try { List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportSliceNetworks")) for (String networkStr : networkStrList) { String allottedResourceId = UUID.randomUUID().toString() - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("sliceserviceInstanceId")).allottedResource(allottedResourceId)) + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(execution.getVariable("sliceServiceInstanceId")) + .allottedResource(allottedResourceId)) execution.setVariable("allottedResourceUri", allottedResourceUri) String modelInvariantId = execution.getVariable("modelInvariantUuid") String modelVersionId = execution.getVariable("modelUuid") @@ -152,27 +161,37 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { resource.setId(allottedResourceId) resource.setType("TsciNetwork") resource.setAllottedResourceName("network_" + execution.getVariable("sliceServiceInstanceName")) - resource.setModelInvariantId(modelInvariantId) - resource.setModelVersionId(modelVersionId) getAAIClient().create(allottedResourceUri, resource) - //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build()) - //getAAIClient().connect(allottedResourceUri,ssServiceuri) - //execution.setVariable("aaiARPath", allottedResourceUri.build().toString()); String linkArrayStr = jsonUtil.getJsonValue(networkStr, "connectionLinks") - createLogicalLinksForAllocatedResource(execution, linkArrayStr, serviceInstanceId, allottedResourceId) + createLogicalLinksForAllocatedResource(execution, linkArrayStr, ssInstanceId, allottedResourceId) } - + } catch (BpmnError e) { + throw e } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage()) + String msg = "Exception in DoCreateTnNssiInstance.createAllottedResource: " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } void createLogicalLinksForAllocatedResource(DelegateExecution execution, - String linkArrayStr, String serviceInstanceId, + String linkArrayStr, String ssInstanceId, String allottedResourceId) { - try { + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId) + .allottedResource(allottedResourceId)) + + if (!getAAIClient().exists(allottedResourceUri)) { + logger.info("ERROR: createLogicalLinksForAllocatedResource: allottedResource not exist: uri={}", + allottedResourceUri) + return + } + List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) for (String linkStr : linkStrList) { @@ -186,15 +205,22 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { resource.setLinkId(logicalLinkId) resource.setLinkName(epA) resource.setLinkName2(epB) - resource.setModelInvariantId(modelInvariantId) - resource.setModelVersionId(modelVersionId) + resource.setLinkType("TsciConnectionLink") + resource.setInMaint(false) - AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId)) + //epA is link-name + AAIResourceUri logicalLinkUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA)) getAAIClient().create(logicalLinkUri, resource) + + tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, AAI_VERSION, allottedResourceUri, epA); } + } catch (BpmnError e) { + throw e } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, - "Exception in createLogicalLinksForAllocatedResource" + ex.getMessage()) + String msg = "Exception in DoCreateTnNssiInstance.createLogicalLinksForAllocatedResource: " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index a410b93d16..baf0333a19 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -162,7 +162,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy index 03a726c52c..4ff15a58c5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -387,7 +387,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 7d2e536af9..e856522fca 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -27,11 +27,9 @@ import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -155,7 +153,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { "modelUuid":"${modelUuid}", "modelVersion":"" }""" - execution.setVariable("ssServiceModelInfo", serviceModelInfo) + execution.setVariable("serviceModelInfo", serviceModelInfo) logger.debug("Finish prepareDecomposeService") } @@ -186,13 +184,14 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { if (maxIndex < 1) { String msg = "Exception in TN NSST processDecomposition. There is no NSST associated with TN NSST " logger.info(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } else { + execution.setVariable("tnNsstInfoList", nsstInfoList) + execution.setVariable("tnModelVersion", tnModelVersion) + execution.setVariable("tnModelName", tnModelName) + execution.setVariable("currentIndex", currentIndex) + execution.setVariable("maxIndex", maxIndex) } - execution.setVariable("tnNsstInfoList", nsstInfoList) - execution.setVariable("tnModelVersion", tnModelVersion) - execution.setVariable("tnModelName", tnModelName) - execution.setVariable("currentIndex", currentIndex) - execution.setVariable("maxIndex", maxIndex) logger.debug("End processDecomposition") } @@ -334,7 +333,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) - requestDBUtil.prepareUpdateResourceOperationStatus(execution, status) + requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index a1b883c34e..1bb0e8aca7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -20,8 +20,11 @@ package org.onap.so.bpmn.infrastructure.scripts - +import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.Relationship +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils @@ -241,4 +244,40 @@ class TnNssmfUtils { return res } + + void createRelationShipInAAI(DelegateExecution execution, AAIResourceUri uri, Relationship relationship) { + logger.debug("createRelationShipInAAI Start") + String msg + AAIResourcesClient client = new AAIResourcesClient() + try { + if (!client.exists(uri)) { + logger.info("ERROR: createRelationShipInAAI: not exist: uri={}", uri) + return + } + AAIResourceUri from = ((AAIResourceUri) (uri.clone())).relationshipAPI() + client.create(from, relationship) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in createRelationShipInAAI. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("createRelationShipInAAI Exit") + } + + void attachLogicalLinkToAllottedResource(DelegateExecution execution, String aaiVersion, AAIResourceUri arUri, + String logicalLinkId) { + + + String toLink = "aai/${aaiVersion}/network/logical-links/logical-link/${logicalLinkId}" + + Relationship relationship = new Relationship() + relationship.setRelatedLink(toLink) + relationship.setRelatedTo("logical-link") + relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") + + createRelationShipInAAI(execution, arUri, relationship) + } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn index f4886322c2..12632dec72 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn @@ -68,12 +68,12 @@ ex.processJavaException(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_07e12rt</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0t094g7</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def rupScript = new TnAllocateNssi() +def runScript = new TnAllocateNssi() runScript.prepareUpdateJobStatus(execution,"progress","10","Allocate TN NSSI started")</bpmn:script> </bpmn:scriptTask> <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_1ex8ke9" name="Goto OOF TN NSSI Selection"> <bpmn:incoming>SequenceFlow_0jrclmc</bpmn:incoming> - <bpmn:linkEventDefinition id="LinkEventDefinition_0de65en" name="OofTnNssiSelect" /> + <bpmn:linkEventDefinition id="LinkEventDefinition_0de65en" name="TnAllocateNssi" /> </bpmn:intermediateThrowEvent> <bpmn:scriptTask id="ScriptTask_1ssh2l9" name="Prepare Update Resource Oper Status((finish)" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0kixzdj</bpmn:incoming> diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml index 1c13ecac25..3178b28502 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/pom.xml @@ -102,5 +102,11 @@ <version>${hamcrest-version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>nl.jqno.equalsverifier</groupId> + <artifactId>equalsverifier</artifactId> + <version>${equalsverifier-version}</version> + <scope>test</scope> + </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java index 0dcadfd4d8..0901f077d2 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/exceptions/NsRequestProcessingException.java @@ -31,10 +31,11 @@ import org.springframework.web.bind.annotation.ResponseStatus; public class NsRequestProcessingException extends RuntimeException { private static final long serialVersionUID = 66862444537194516L; - private InlineResponse400 problemDetails; + private final InlineResponse400 problemDetails; public NsRequestProcessingException(final String message) { super(message); + problemDetails = null; } public NsRequestProcessingException(final String message, final InlineResponse400 problemDetails) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java index 75dd7107a7..097db5c153 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProviderImpl.java @@ -25,7 +25,7 @@ import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model. import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.etsicatalog.model.VnfPkgInfo; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.EtsiCatalogManagerRequestFailureException; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; -import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptorParser; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser.NetworkServiceDescriptorParser; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java index 58ca2507bd..cfe5b94859 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileEntry.java @@ -22,6 +22,7 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.Arrays; import java.util.Objects; /** @@ -82,7 +83,7 @@ public class FileEntry { @Override public int hashCode() { - return Objects.hash(isDirectory, filePath, fileContent); + return Objects.hash(isDirectory, filePath) + Arrays.hashCode(fileContent); } @Override @@ -90,7 +91,7 @@ public class FileEntry { if (obj instanceof FileEntry) { final FileEntry other = (FileEntry) obj; return Objects.equals(isDirectory, other.isDirectory) && Objects.equals(filePath, other.filePath) - && Objects.equals(fileContent, other.fileContent); + && Arrays.equals(fileContent, other.fileContent); } return false; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/FileParser.java index 9df5262302..2a37922e9b 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/FileParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/FileParser.java @@ -17,9 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import java.util.Map; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; /** * @author Waqas Ikram (waqas.ikram@est.tech) diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParser.java index 33737f4c17..7df2e6973d 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParser.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -31,6 +31,10 @@ import java.util.Optional; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.apache.commons.io.IOUtils; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.ToscaMetadata; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.VirtualNetworkFunction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -79,7 +83,7 @@ public class NetworkServiceDescriptorParser { final Map<String, Object> nodeTemplates = getNodeTemplates(topologyTemplates); final Optional<NetworkServiceDescriptor> nsdOptional = - getNetworkServiceDescriptor(topologyTemplates);; + getNetworkServiceDescriptor(topologyTemplates); if (nsdOptional.isPresent()) { final NetworkServiceDescriptor networkServiceDescriptor = nsdOptional.get(); networkServiceDescriptor.setVnfs(getVirtualNetworkFunctions(nodeTemplates)); @@ -91,10 +95,10 @@ public class NetworkServiceDescriptorParser { } + logger.error("Unable to find {} file in {}", TOSCA_META_PATH_FILE_NAME, files); } catch (final Exception exception) { - logger.error("Unable to parser nsd zip content", exception); + logger.error("Unable to parse nsd zip content", exception); } - logger.error("Unable to parser nsd zip content"); return Optional.empty(); } @@ -191,7 +195,7 @@ public class NetworkServiceDescriptorParser { } return files; } catch (final Exception exception) { - logger.error("Unable to parser nsd zip content", exception); + logger.error("Unable to parse nsd zip content", exception); return Collections.emptyMap(); } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadataParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/ToscaMetadataParser.java index fe23f5ef8d..746416c8e4 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/ToscaMetadataParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/ToscaMetadataParser.java @@ -17,12 +17,15 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.util.List; import java.util.Optional; import org.apache.commons.io.IOUtils; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.ToscaMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -39,7 +42,7 @@ public class ToscaMetadataParser { public Optional<ToscaMetadata> parse(final FileEntry toscaMetaFile) { try { final ToscaMetadata toscaMetadata = new ToscaMetadata(); - final List<String> lines = IOUtils.readLines(toscaMetaFile.getFileContentAsStream(), "utf-8"); + final List<String> lines = IOUtils.readLines(toscaMetaFile.getFileContentAsStream(), UTF_8); for (final String line : lines) { final String trimmedLine = line.trim(); if (!trimmedLine.isEmpty() && trimmedLine.contains(ATTRIBUTE_VALUE_SEPARATOR)) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/YamlFileParser.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/YamlFileParser.java index ac8f782a99..eab6974252 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/YamlFileParser.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/YamlFileParser.java @@ -17,9 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import java.util.Map; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; import org.springframework.stereotype.Service; import org.yaml.snakeyaml.Yaml; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java index bfeaf49daa..fcebea59f2 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java @@ -47,6 +47,7 @@ import org.springframework.stereotype.Component; */ @Component public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { + private static final String CREATE_INSTANTIATE_REQUEST_PARAM_NAME = "request"; private static final Logger logger = LoggerFactory.getLogger(CreateInstantiateVnfTask.class); private static final String NF_INST_ID_PARAM_NAME = "NF_INST_ID"; public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse"; @@ -64,7 +65,8 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { public void checkIfNfInstanceExistsInDb(final DelegateExecution execution) { logger.info("Executing checkIfNfInstanceInDb"); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); setJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NF Instance record exists in database for " @@ -79,7 +81,8 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { public void createNfInstanceInDb(final DelegateExecution execution) { logger.info("Executing createNfInstanceInDb"); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); setJobStatus(execution, IN_PROGRESS, "Creating NF Instance record in database for " + request.getVnfName()); @@ -104,7 +107,8 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { public void createGenericVnfInAai(final DelegateExecution execution) { logger.info("Executing createGenericVnfInAai"); try { - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); setJobStatus(execution, IN_PROGRESS, "Creating GenericVnf record in AAI for " + request.getVnfName()); @@ -140,7 +144,8 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing invokeCreateInstantiationRequest"); try { - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); setJobStatus(execution, IN_PROGRESS, @@ -180,7 +185,8 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing updateNfInstanceStatusToInstantiated"); updateNfInstanceStatus(execution, State.INSTANTIATED); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); setJobStatus(execution, FINISHED, "Successfully created and Instantiated VNF: " + request.getVnfName() + " will set status to " + State.INSTANTIATED); @@ -192,7 +198,8 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing updateNfInstanceStatusToActive"); updateNfInstanceStatus(execution, State.FAILED); - final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable("request"); + final CreateInstantiateRequest request = + (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); setJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName() + " will set status to " + State.FAILED); @@ -204,7 +211,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(nfInstId); - if (!optional.isPresent()) { + if (optional.isEmpty()) { final String message = "Unable to find NfvoNfInst record in database using nfInstId: " + nfInstId; logger.error(message); diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java index 1d9e09e74b..f3dbf37f6a 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/InstantiateNsTask.java @@ -240,12 +240,20 @@ public class InstantiateNsTask extends AbstractNetworkServiceTask { final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId); - final String nsPackageId = nfvoNsInst.getNsPackageId(); - final NsdInfo nsdInfo = getNsdInfo(execution, nsPackageId); final Map<String, String> vnfdIdToVnfPkgIdMapping = new HashMap<>(); try { + final Optional<NsdInfo> nsdInfoOptional = + etsiCatalogPackageManagementServiceProvider.getNSPackageModel(nsPackageId); + + if (nsdInfoOptional.isEmpty()) { + final String message = "Unable to find NS package using NS package id: " + nsPackageId; + logger.error(message); + abortOperation(execution, message); + } + + final NsdInfo nsdInfo = nsdInfoOptional.get(); for (final String vnfPkgId : nsdInfo.getVnfPkgIds()) { final Optional<VnfPkgInfo> optional = etsiCatalogPackageManagementServiceProvider.getVnfPkgInfo(vnfPkgId); @@ -290,32 +298,6 @@ public class InstantiateNsTask extends AbstractNetworkServiceTask { setJobStatusToError(execution, "Instantiate NS workflow process failed"); } - private NsdInfo getNsdInfo(final DelegateExecution execution, final String nsPackageId) { - try { - final Optional<NsdInfo> optional = - etsiCatalogPackageManagementServiceProvider.getNSPackageModel(nsPackageId); - - if (optional.isPresent()) { - final NsdInfo packageModel = optional.get(); - logger.info("NS Package exists {}", packageModel); - return packageModel; - } - - } catch (final EtsiCatalogManagerRequestFailureException failureException) { - final String message = - "Unexpected exception occured while getting ns package using nsPackageId: " + nsPackageId; - logger.error(message, failureException); - - abortOperation(execution, message); - } - - final String message = "Unable to find NS package using NS package id: " + nsPackageId; - logger.error(message); - abortOperation(execution, message); - return null; - - } - private Optional<Tenant> getTenant(final Map<String, String> additionalParams) { final String vimId = (String) additionalParams.get("vim_id"); if (vimId != null) { diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java index 2baa2845a5..23a239e3b1 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateNsTask.java @@ -109,9 +109,8 @@ public class TerminateNsTask extends AbstractNetworkServiceTask { final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); final List<NfvoNfInst> nfInstances = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId); if (nfInstances != null) { - nfInstances.stream().forEach(instance -> { - logger.info("Current status {} of vnf: {}", instance.getStatus(), instance.getName()); - }); + nfInstances.stream().forEach( + instance -> logger.info("Current status {} of vnf: {}", instance.getStatus(), instance.getName())); } } @@ -120,16 +119,14 @@ public class TerminateNsTask extends AbstractNetworkServiceTask { logger.info("Getting NfvoNfInstList using nsInstId: {}", nsInstId); final List<NfvoNfInst> nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId); - if (nfvoNfInstList.size() == 0) { + if (nfvoNfInstList == null || nfvoNfInstList.size() == 0) { final String message = "Unable to find NF Instances in database using id: " + nsInstId; abortOperation(execution, message); } final List<String> vnfIdsList = new ArrayList<>(); - nfvoNfInstList.stream().forEach(nfvoNfInst -> { - vnfIdsList.add(nfvoNfInst.getNfInstId()); - }); + nfvoNfInstList.stream().forEach(nfvoNfInst -> vnfIdsList.add(nfvoNfInst.getNfInstId())); return vnfIdsList; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java index 34959ee0f0..9f21d2b449 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapter.java @@ -24,6 +24,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; /** @@ -45,14 +46,14 @@ public class LocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> { @Override public LocalDateTime read(final JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - final String dateTime = in.nextString(); - return LocalDateTime.parse(dateTime, FORMATTER); + if (JsonToken.NULL == in.peek()) { + in.nextNull(); + return null; + } + final String dateTime = in.nextString(); + return LocalDateTime.parse(dateTime, FORMATTER); + } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/PojoClassesTests.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/PojoClassesTests.java new file mode 100644 index 0000000000..edfb20afd2 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/PojoClassesTests.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows; + +import java.util.Arrays; +import java.util.List; +import org.junit.Test; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.FileEntry; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.ToscaMetadata; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.VirtualNetworkFunction; +import org.onap.so.openpojo.rules.ToStringTester; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class PojoClassesTests { + + @Test + public void test_nsd_parser_pojo_classes() throws ClassNotFoundException { + + final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()) + .with(new ToStringTester()).build(); + validator.validate(FileEntry.class.getPackageName(), new FilterPackageInfo()); + } + + + @Test + public void test_nsd_parser_pojo_classes_equalAndHashMethod() throws ClassNotFoundException { + final List<Class<?>> classes = Arrays.asList(FileEntry.class, NetworkServiceDescriptor.class, + ToscaMetadata.class, VirtualNetworkFunction.class); + for (final Class<?> clazz : classes) { + EqualsVerifier.forClass(clazz).suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, + Warning.INHERITED_DIRECTLY_FROM_OBJECT).verify(); + } + } + +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParserTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParserTest.java index 2bebf1c30a..4a8c715e5c 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/NetworkServiceDescriptorParserTest.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/nsd/parser/NetworkServiceDescriptorParserTest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd; +package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -31,6 +31,8 @@ import java.util.Optional; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.TestApplication; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.NetworkServiceDescriptor; +import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd.parser.NetworkServiceDescriptorParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java index 78ab9e96cc..2390cef564 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java @@ -77,7 +77,7 @@ public class NsLifecycleManagementController { */ @PostMapping(value = "/ns_instances", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> createNs( + public ResponseEntity<NsInstancesNsInstance> createNs( @RequestHeader(value = HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME, required = true) final String globalCustomerId, @RequestHeader(value = HTTP_SERVICETYPE_HEADER_PARM_NAME, required = false, @@ -106,7 +106,7 @@ public class NsLifecycleManagementController { */ @DeleteMapping(value = "/ns_instances/{nsInstanceId}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> deleteNs(@PathVariable("nsInstanceId") final String nsInstanceId) { + public ResponseEntity<Void> deleteNs(@PathVariable("nsInstanceId") final String nsInstanceId) { logger.debug("Received delete NS request for nsInstanceId: {}", nsInstanceId); nsLifeCycleManager.deleteNs(nsInstanceId); logger.info("Successfully deleted NS for nsInstanceId: {}", nsInstanceId); @@ -124,7 +124,7 @@ public class NsLifecycleManagementController { @PostMapping(value = "/ns_instances/{nsInstanceId}/instantiate", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> instantiateNs(@PathVariable("nsInstanceId") final String nsInstanceId, + public ResponseEntity<Void> instantiateNs(@PathVariable("nsInstanceId") final String nsInstanceId, @RequestBody final InstantiateNsRequest instantiateNsRequest) { logger.debug("Received instantiate NS request: {}\n with nsInstanceId: {}", instantiateNsRequest, nsInstanceId); final URI resourceUri = nsLifeCycleManager.instantiateNs(nsInstanceId, instantiateNsRequest); @@ -144,7 +144,7 @@ public class NsLifecycleManagementController { @PostMapping(value = "/ns_instances/{nsInstanceId}/terminate", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> terminateNs(@PathVariable("nsInstanceId") final String nsInstanceId, + public ResponseEntity<Void> terminateNs(@PathVariable("nsInstanceId") final String nsInstanceId, @RequestBody final TerminateNsRequest terminateNsRequest) { logger.debug("Received terminate NS request: {}\n with nsInstanceId: {}", terminateNsRequest, nsInstanceId); final URI resourceUri = nsLifeCycleManager.terminateNs(nsInstanceId, terminateNsRequest); |