diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-10-12 14:03:02 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-10-16 17:28:55 -0400 |
commit | 2ff435b28384a066017b690cf8a876a2cdd52d29 (patch) | |
tree | 0b87091067f3a23d8a75738d933bcb61cb8f8d6a | |
parent | d6c21ac6f38474841d3b9ced0524fe7671ae8682 (diff) |
Bug fixes for casablanca
Updated builder to use String.format
Added exception specifically for issues interacting with
requestdbadapter
Updated exception message and added junit test case
Added case to handle when homing is not called during assign vnf.
include network ID for completion handler
Added exception handling for saving to requestdb
added null check to mdc and interceptors to sdnc cxf
confirm subnet map is not null in adapter response
shallow copy subnet before AAI udpate
update AAIObjectType to use uriTemplate
extract subnet data from adapter response
update correct AAIObjectType for subnet query
update subnet(s) in AAI on network create completion
updated how request db is set to failure in workflowA
updated in and out mapping to be generalBuildingBlock
change source out mapping to generalBuildingBlock
Use explicit conversion to JSON to read cloudConfiguration settings.
Use explicit conversion to JSON to read cloudConfiguration settings.
Correct the name of DeleteVfModuleBB subprocess.
Write the returned value from Homing to gBBInput
updated unit test coverage for update network
sync subnet status with network update
Added WorkflowException to out mapping which will trigger an exception
to be thrown when populated.
Correct the payload for HealthCheck APP-C Action to remove escaping and
change parameter name.
Added WorkflowException to out mapping which will trigger an exception
to be thrown when populated.
Commit a change that was not staged in previous commit
updated arguments to getConstructor method
forgot to extract throwable from Optional object
added throwable constructor to createException
fixed broken unit test and added a new test and method
set the network technology in the network request
remove namespace from added networkId payload element
- Updated SDWan test case to check the database to make sure the
VNFCustomization object exist.
- Updated code to only loop in iNotif.getResources() for VF resources,
all others are unnecessary and were causing issues with the Service
object.
- Removed modifiedHeatTemplate variable since this isn't needed in the
ONAP code base.
Make sure vnfResponseCode variable is set to 200 when VNF is correctly
retrieved from A&AI.
VRR VRRCreateVfModule - send availability_zone to SDNC Infra Assign
request
Safeguard the retrieval of Boolean setting for isRollbackEnabled.
Set isRollbackEnabled to opposite of suppressRollback early on in the
execution.
Reverse suppressRollback value to pass as backout parameter to VNF
Adapter
Add the exceptions to the calls to aai client queries
Correct retrieval of the object from Optional for A&AI queries.
Change-Id: I7d22e621b0316c14ce61bd51a9d5753473622697
Issue-ID: SO-1134
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
40 files changed, 506 insertions, 173 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 91505918a8..503de0429e 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -680,36 +680,13 @@ public class ASDCController { VfResourceStructure resourceStructure = null; ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(); boolean deploySuccessful = true; + boolean hasVFResource = false; String errorMessage = null; try { this.processCsarServiceArtifacts(iNotif, toscaResourceStructure); - - if (toscaResourceStructure.getServiceVersion() == null) { - LOGGER.debug("Deploy the workflow"); - IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact(); - String csarFilePath = System.getProperty("mso.config.path") + "/ASDC" + "/" + iArtifact.getArtifactName(); - bpmnInstaller.installBpmn(csarFilePath); - } - - // Install a service with no resources, only the service itself - if (iNotif.getResources() == null || iNotif.getResources().size() < 1) { - - LOGGER.debug("No resources found for Service: " + iNotif.getServiceUUID()); - - try{ - resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance()); - - this.deployResourceStructure(resourceStructure, toscaResourceStructure); - - } catch(ArtifactInstallerException e){ - deploySuccessful = false; - errorMessage = e.getMessage(); - LOGGER.debug ("Exception in processResourceNotification(): " + e); - } - } else { // Services with resources - + for (IResourceInstance resource : iNotif.getResources()){ resourceStructure = new VfResourceStructure(iNotif,resource); @@ -720,11 +697,14 @@ public class ASDCController { LOGGER.debug("Processing Resource Type: " + resourceType + " and Model UUID: " + resourceStructure.getResourceInstance().getResourceUUID()); if("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)){ + + hasVFResource = true; for (IArtifactInfo artifact : resource.getArtifacts()) { IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact, iNotif.getDistributionID()); if (resultArtifact != null) { + if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) { LOGGER.debug("VF_MODULE_ARTIFACT: "+new String(resultArtifact.getArtifactPayload(),"UTF-8")); LOGGER.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(resourceStructure.decodeVfModuleArtifact(resultArtifact.getArtifactPayload()))); @@ -732,21 +712,37 @@ public class ASDCController { resourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact); } } + + //Deploy VF resource and artifacts + LOGGER.debug("Preparing to deploy Service: " + iNotif.getServiceUUID()); + try{ + + this.deployResourceStructure(resourceStructure, toscaResourceStructure); + + } catch(ArtifactInstallerException e){ + deploySuccessful = false; + errorMessage = e.getMessage(); + LOGGER.error(e); + } } + + } + + // There are cases where the Service has no VF resources, those are handled here + if (!hasVFResource) { + + LOGGER.debug("No resources found for Service: " + iNotif.getServiceUUID()); - //Deploy All resources and artifacts - LOGGER.debug("Preparing to deploy Service: " + iNotif.getServiceUUID()); - try{ - + try{ + resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance()); + this.deployResourceStructure(resourceStructure, toscaResourceStructure); } catch(ArtifactInstallerException e){ deploySuccessful = false; errorMessage = e.getMessage(); - LOGGER.debug ("Exception in processResourceNotification(): " + e); - } - - } + LOGGER.error(e); + } } this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful, errorMessage); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java index ca4c5e83a9..f7c761f017 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java @@ -97,6 +97,7 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Environment Context:"); buffer.append(csarHelper.getServiceMetadata().getValue("environmentContext")); + buffer.append(System.lineSeparator()); List<NodeTemplate> serviceProxyResourceList = toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY); @@ -223,6 +224,9 @@ public class ASDCNotificationLogging { buffer.append("Type:"); buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))); buffer.append(System.lineSeparator()); + buffer.append("Category:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY))); + buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); buffer.append(System.lineSeparator()); @@ -412,14 +416,13 @@ public class ASDCNotificationLogging { } - buffer.append(System.lineSeparator()); - buffer.append("Network Collection Resource Properties:"); - buffer.append(System.lineSeparator()); - + List<NodeTemplate> networkCollectionList = toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR); if (networkCollectionList != null) { for (NodeTemplate crNode : networkCollectionList) { + buffer.append(System.lineSeparator()); + buffer.append("Network Collection Properties:"); buffer.append(System.lineSeparator()); buffer.append("Model Name:"); buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy index ff5dabf99a..c19851d223 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy @@ -206,6 +206,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { idXml = "" } idXml = utils.removeXmlPreamble(idXml) + idXml = utils.removeXmlNamespaces(idXml) msoLogger.debug("Incoming Instance Id Xml: " + idXml) String payload = """ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy index e182ae3300..1a55bf2a0e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy @@ -20,6 +20,7 @@ package org.onap.so.bpmn.common.scripts +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.camunda.bpm.model.dmn.instance.OrganizationUnit @@ -124,10 +125,11 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { try { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.ONE)) + AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.ONE), NotFoundException.class) GenericVnf responseData = wrapper.asBean(GenericVnf.class).get() execution.setVariable('PUAAIVfMod_getVnfResponse', responseData) + execution.setVariable('PUAAIVfMod_getVnfResponseCode', 200) } catch (Exception ex) { msoLogger.error(ex); @@ -176,8 +178,8 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { execution.setVariable('PUAAIVfMod_vfModuleValidationError', msg) execution.setVariable('PUAAIVfMod_vfModuleOK', false) } else { - AAIResultWrapper wrapper = resourceClient.get(uri) - org.onap.aai.domain.yang.VfModule vfModule = wrapper.asBean(org.onap.aai.domain.yang.VfModule.class) + AAIResultWrapper wrapper = resourceClient.get(uri, NotFoundException.class) + org.onap.aai.domain.yang.VfModule vfModule = wrapper.asBean(org.onap.aai.domain.yang.VfModule.class).get() def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus') if (vfModule.isBaseVfModule && genericVnf.getVfModules().getVfModule().size() > 1 && vfModule.getOrchestrationStatus().equals('pending-delete')) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java index 47e36424dd..45bc27d840 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java @@ -85,9 +85,9 @@ public class PayloadClient { public static Optional<String> healthCheckFormat(String vnfName, String vnfHostIpAddress) throws JsonProcessingException{ HealthCheckAction payloadResult = new HealthCheckAction(); RequestParametersHealthCheck requestParams = new RequestParametersHealthCheck(); - requestParams.setVnfHostIpAddress(vnfHostIpAddress); + requestParams.setHostIpAddress(vnfHostIpAddress); payloadResult.setRequestParameters(requestParams); - return Optional.of((mapper.writeValueAsString(payloadResult)).replaceAll("\"", "\\\\\"")); + return Optional.of((mapper.writeValueAsString(payloadResult))); } public static Optional<String> snapshotFormat(String vmId, String identityUrl)throws JsonProcessingException{ diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java index 053ac5e741..60030ee3dd 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java @@ -32,8 +32,8 @@ public class RequestParametersHealthCheck { @JsonProperty("vnf-name") private String vnfName; -@JsonProperty("vnf-host-ip-address") -private String vnfHostIpAddress; +@JsonProperty("host-ip-address") +private String hostIpAddress; @JsonProperty("vnf-name") public String getVnfName() { @@ -45,14 +45,14 @@ public void setVnfName(String vnfName) { this.vnfName = vnfName; } -@JsonProperty("vnf-host-ip-address") -public void setVnfHostIpAddress(String vnfHostIpAddress) { - this.vnfHostIpAddress = vnfHostIpAddress; +@JsonProperty("host-ip-address") +public void setHostIpAddress(String hostIpAddress) { + this.hostIpAddress = hostIpAddress; } -@JsonProperty("vnf-host-ip-address") -public String getVnfHostIpAddress() { - return vnfHostIpAddress; +@JsonProperty("host-ip-address") +public String getHostIpAddress() { + return hostIpAddress; } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 6c399ddbbb..d463fde09c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -347,7 +347,7 @@ public class BBInputSetupMapperLayer { protected OrchestrationContext mapOrchestrationContext(RequestDetails requestDetails) { OrchestrationContext context = new OrchestrationContext(); - context.setIsRollbackEnabled((requestDetails.getRequestInfo().getSuppressRollback())); + context.setIsRollbackEnabled(!(requestDetails.getRequestInfo().getSuppressRollback())); return context; } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy index 8ac8f25eb1..4b0c33ab99 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy @@ -57,6 +57,19 @@ class CompleteMsoProcessTest { <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name> </sdncadapterworkflow:MsoCompletionRequest> """ + + private String completeMsoNetworkProcessRequest = """ + <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:ns="http://org.onap/so/request/types/v1"> + <request-info xmlns="http://org.onap/so/infra/vnf-request/v1"> + <request-id>bd631913-cfc6-488b-ba22-6b98504f703d</request-id> + <action>CREATE</action> + <source>VID</source> + </request-info> + <aetgt:status-message>Resource Completed Successfully</aetgt:status-message> + <aetgt:networkId>bd631913-cfc6-488b-ba22-6b98504f703d</aetgt:networkId> + <aetgt:mso-bpel-name>BPMN Network action: CREATE</aetgt:mso-bpel-name> + </aetgt:MsoCompletionRequest>""" @Test public void testPreProcessRequest() { @@ -117,7 +130,7 @@ class CompleteMsoProcessTest { <statusMessage>Resource Completed Successfully</statusMessage> <requestStatus>COMPLETE</requestStatus> <progress>100</progress> - + <networkId>bd631913-cfc6-488b-ba22-6b98504f703d</networkId> </req:updateInfraRequest> </soapenv:Body> </soapenv:Envelope>""" @@ -130,6 +143,7 @@ class CompleteMsoProcessTest { when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("BPEL") when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC"); when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7"); + when(mockExecution.getVariable("CompleteMsoProcessRequest")).thenReturn(completeMsoNetworkProcessRequest); CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess() completeMsoProcess.setUpdateDBstatustoSuccessPayload(mockExecution) diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java index a08d8ca25d..20c69fafe3 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java @@ -66,8 +66,8 @@ public class PayloadClientTest { @Test public void healthCheckFormatTest() throws Exception { - String payloadResult = "{\\\"request-parameters\\\":{\\\"vnf-host-ip-address\\\":\\\"vnfHostIpAddress1\\\"}}"; - Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "vnfHostIpAddress1"); + String payloadResult = "{\"request-parameters\":{\"host-ip-address\":\"hostIpAddress1\"}}"; + Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "hostIpAddress1"); assertEquals(payloadResult, payloadClient.get()); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index e5138b394c..94dbbf427c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -549,7 +549,7 @@ public class BBInputSetupMapperLayerTest { @Test public void testMapOrchestrationContext() throws IOException { OrchestrationContext expected = new OrchestrationContext(); - expected.setIsRollbackEnabled(false); + expected.setIsRollbackEnabled(true); RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json index d3698771bf..60dd880040 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json @@ -10,7 +10,7 @@ "configurationParameters": [] }, "orchContext": { - "is-rollback-enabled": true + "is-rollback-enabled": false }, "cloudRegion": { "lcp-cloud-region-id" : "myRegionId", diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn index eaee5399e6..3355e627c3 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn @@ -37,7 +37,8 @@ <bpmn:extensionElements> <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:in source="mso-request-id" target="mso-request-id" /> - <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:out source="generalBuildingBlock" target="gBBInput" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1uiok7v</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0v8d14a</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 5795c1c671..bb7abf7d7d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> - <bpmn:process id="DeleteVfModuleBB" name="Start" isExecutable="true"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> + <bpmn:process id="DeleteVfModuleBB" name="DeleteVfModuleBB" isExecutable="true"> <bpmn:startEvent id="DeleteVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_1537yw5</bpmn:outgoing> </bpmn:startEvent> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy index d2903f5396..cd583f77ef 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License") + * 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 * diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy index 06346ea81e..56e5be04a5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License") + * 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 * diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy index 548f521c33..4978faf46c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy @@ -167,12 +167,12 @@ public class UpdateVnfInfra extends VnfCmBase { def usePreload = reqMap.requestDetails?.requestParameters?.usePreload execution.setVariable('usePreload', usePreload) - def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration - def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId + def cloudConfiguration = jsonOutput.toJson(reqMap.requestDetails?.cloudConfiguration) + def lcpCloudRegionId = jsonUtils.getJsonValue(cloudConfiguration, "lcpCloudRegionId") execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) def cloudOwner = jsonUtils.getJsonValue(cloudConfiguration, "cloudOwner") execution.setVariable('cloudOwner', cloudOwner) - def tenantId = cloudConfiguration.tenantId + def tenantId = jsonUtils.getJsonValue(cloudConfiguration, "tenantId") execution.setVariable('tenantId', tenantId) def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: '' diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 58c51f6223..c84e26911c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -20,6 +20,9 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; +import java.util.List; +import java.util.Map; + import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -28,6 +31,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -209,22 +213,7 @@ public class AAIUpdateTasks { * @throws BBObjectNotFoundException */ public void updateOrchestrationStatusAssignedNetwork(BuildingBlockExecution execution) { - execution.setVariable("aaiNetworkAssignRollback", false); - try { - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - L3Network copiedl3network = l3network.shallowCopyId(); - - - l3network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - l3network.setHeatStackId(""); - - copiedl3network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - copiedl3network.setHeatStackId(""); - aaiNetworkResources.updateNetwork(copiedl3network); - execution.setVariable("aaiNetworkAssignRollback", true); - } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateNetwork(execution, OrchestrationStatus.ASSIGNED); } /** @@ -233,18 +222,7 @@ public class AAIUpdateTasks { * @throws BBObjectNotFoundException */ public void updateOrchestrationStatusActiveNetwork(BuildingBlockExecution execution) { - execution.setVariable("aaiNetworkActivateRollback", false); - try { - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - L3Network copiedl3network = l3network.shallowCopyId(); - - copiedl3network.setOrchestrationStatus(OrchestrationStatus.ACTIVE); - l3network.setOrchestrationStatus(OrchestrationStatus.ACTIVE); - aaiNetworkResources.updateNetwork(copiedl3network); - execution.setVariable("aaiNetworkActivateRollback", true); - } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateNetwork(execution, OrchestrationStatus.ACTIVE); } /** @@ -253,20 +231,35 @@ public class AAIUpdateTasks { * @throws BBObjectNotFoundException */ public void updateOrchestrationStatusCreatedNetwork(BuildingBlockExecution execution) { - execution.setVariable("aaiNetworkActivateRollback", false); + updateNetwork(execution, OrchestrationStatus.CREATED); + } + + protected void updateNetwork(BuildingBlockExecution execution, OrchestrationStatus status) { try { - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - L3Network copiedl3network = l3network.shallowCopyId(); - - copiedl3network.setOrchestrationStatus(OrchestrationStatus.CREATED); - l3network.setOrchestrationStatus(OrchestrationStatus.CREATED); - aaiNetworkResources.updateNetwork(copiedl3network); - execution.setVariable("aaiNetworkActivateRollback", true); + L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + updateNetworkAAI(l3Network, status); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + protected void updateNetworkAAI(L3Network l3Network, OrchestrationStatus status) { + L3Network copiedl3Network = l3Network.shallowCopyId(); + + copiedl3Network.setOrchestrationStatus(status); + l3Network.setOrchestrationStatus(status); + aaiNetworkResources.updateNetwork(copiedl3Network); + + List<Subnet> subnets = l3Network.getSubnets(); + if (subnets != null){ + for (Subnet subnet : subnets){ + Subnet copiedSubnet = subnet.shallowCopyId(); + copiedSubnet.setOrchestrationStatus(status); + aaiNetworkResources.updateSubnet(copiedl3Network, copiedSubnet); + } + } + } + /** * BPMN access method to update status of L3Network Collection to Active in AAI * @param execution @@ -336,6 +329,18 @@ public class AAIUpdateTasks { copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId()); aaiNetworkResources.updateNetwork(copiedl3network); + + Map<String, String> subnetMap = response.getSubnetMap(); + List<Subnet> subnets = l3network.getSubnets(); + if (subnets != null && subnetMap != null){ + for (Subnet subnet: subnets){ + Subnet copiedSubnet = subnet.shallowCopyId(); + copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId())); + copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED); + aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet); + } + } + execution.setVariable("aaiNetworkActivateRollback", true); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java index 5f263e8b4b..ec79b2825a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java @@ -72,8 +72,8 @@ public class SDNCAssignTasks { } public void assignVnf(BuildingBlockExecution execution) { - try { - GeneralBuildingBlock gBBInput = execution.getVariable("generalBuildingBlock"); + try { + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); RequestContext requestContext = gBBInput.getRequestContext(); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 724dea6cf5..24246273e8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -294,6 +294,7 @@ public class WorkflowAction { execution.setVariable("retryCount", 0); execution.setVariable("isRollback", false); execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("isRollbackComplete", false); } catch (Exception ex) { buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 8a16b54bf4..4e02ca3f6f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -290,16 +290,11 @@ public class WorkflowActionBBTasks { String requestId = (String) execution.getVariable(G_REQUEST_ID); InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); String errorMsg = null; - boolean rollback = false; + boolean rollback = (boolean) execution.getVariable("isRollbackComplete"); try { WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException"); - if(exception.getErrorMessage()!=null || !exception.getErrorMessage().equals("")){ + if(exception != null && (exception.getErrorMessage()!=null || !exception.getErrorMessage().equals(""))){ errorMsg = exception.getErrorMessage(); - rollback = (boolean) execution.getVariable("isRollbackComplete"); - if(rollback){ - errorMsg = errorMsg + " + Rollback has been completed successfully."; - } - request.setStatusMessage(errorMsg); } } catch (Exception ex) { //log error and attempt to extact WorkflowExceptionMessage @@ -308,12 +303,16 @@ public class WorkflowActionBBTasks { if (errorMsg == null){ try { errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage"); - request.setStatusMessage(errorMsg); } catch (Exception ex) { logger.error("Failed to extract workflow exception message from WorkflowException",ex); - request.setStatusMessage("Unexpected Error in BPMN"); + errorMsg = "Unexpected Error in BPMN."; } } + if(rollback){ + errorMsg = errorMsg + " + Rollback has been completed successfully."; + } + request.setProgress(Long.valueOf(100)); + request.setStatusMessage(errorMsg); request.setRequestStatus("FAILED"); request.setLastModifiedBy("CamundaBPMN"); requestDbclient.updateInfraActiveRequests(request); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index 4a1c3f512c..c895566ca5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -298,5 +298,8 @@ public class AAIObjectMapper { aaiVpnBinding.setRouteTargets(routeTargets); } } - + + public org.onap.aai.domain.yang.Subnet mapSubnet (Subnet subnet){ + return modelMapper.map(subnet,org.onap.aai.domain.yang.Subnet.class); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 056ac3f6e5..57c760b01f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -33,6 +33,7 @@ import org.onap.so.adapters.nwrest.ContrailNetwork; import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.NetworkTechnology; import org.onap.so.adapters.nwrest.ProviderVlanNetwork; import org.onap.so.adapters.nwrest.RollbackNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; @@ -82,6 +83,8 @@ public class NetworkAdapterObjectMapper { ProviderVlanNetwork providerVlanNetwork = buildProviderVlanNetwork(l3Network); createNetworkRequest.setProviderVlanNetwork(providerVlanNetwork); + createNetworkRequest.setNetworkTechnology(setNetworkTechnology(l3Network.getModelInfoNetwork().getNetworkTechnology())); + //build and set Contrail Network ContrailNetwork contrailNetwork = buildContrailNetwork(l3Network, customer); createNetworkRequest.setContrailNetwork(contrailNetwork); @@ -100,6 +103,16 @@ public class NetworkAdapterObjectMapper { return createNetworkRequest; } + + protected NetworkTechnology setNetworkTechnology(String networkTechnology) { + if(networkTechnology.equalsIgnoreCase("Contrail")) { + return NetworkTechnology.CONTRAIL; + } else if(networkTechnology.equalsIgnoreCase("Neutron")){ + return NetworkTechnology.NEUTRON; + } else { + return NetworkTechnology.VMWARE; + } + } public DeleteNetworkRequest deleteNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, ServiceInstance serviceInstance, L3Network l3Network) throws UnsupportedEncodingException { DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest(); @@ -330,9 +343,8 @@ public class NetworkAdapterObjectMapper { private CreateNetworkRequest setFlowFlags(CreateNetworkRequest createNetworkRequest, OrchestrationContext orchestrationContext){ //TODO confirm flag value - createNetworkRequest.setSkipAAI(true); - //revert suppressRollabck=TRUE into backout=FALSE and vice versa - createNetworkRequest.setBackout(orchestrationContext.getIsRollbackEnabled()); + createNetworkRequest.setSkipAAI(true); + createNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); //TODO confirm value - false by default createNetworkRequest.setFailIfExists(true); //NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default @@ -340,9 +352,8 @@ public class NetworkAdapterObjectMapper { } private void setFlowFlags(UpdateNetworkRequest updateNetworkRequest, OrchestrationContext orchestrationContext){ - updateNetworkRequest.setSkipAAI(true); - //revert suppressRollabck=TRUE into backout=FALSE and vice versa - updateNetworkRequest.setBackout(!Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); + updateNetworkRequest.setSkipAAI(true); + updateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); //NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java index ec202b8a3f..93e588f2e1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java @@ -74,7 +74,7 @@ public class VnfAdapterObjectMapper { createVolumeGroupRequest.setVolumeGroupParams(createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse)); createVolumeGroupRequest.setSkipAAI(true); - createVolumeGroupRequest.setSuppressBackout(orchestrationContext.getIsRollbackEnabled()); + createVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); createVolumeGroupRequest.setFailIfExists(true); createVolumeGroupRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 81c2107328..a36d18c524 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -140,7 +140,7 @@ public class VnfAdapterVfModuleObjectMapper { createVfModuleRequest.setVfModuleParams(buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse)); createVfModuleRequest.setSkipAAI(true); - createVfModuleRequest.setBackout(orchestrationContext.getIsRollbackEnabled()); + createVfModuleRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); createVfModuleRequest.setFailIfExists(true); MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index e4984c921d..dc5ba64d2d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -31,6 +31,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; @@ -55,6 +56,12 @@ public class AAINetworkResources { injectionHelper.getAaiClient().update(networkURI, aaiL3Network); } + public void updateSubnet(L3Network network, Subnet subnet) { + AAIResourceUri subnetURI = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, network.getNetworkId(), subnet.getSubnetId()); + org.onap.aai.domain.yang.Subnet aaiSubnet = aaiObjectMapper.mapSubnet(subnet); + injectionHelper.getAaiClient().update(subnetURI, aaiSubnet); + } + public void createNetworkConnectToServiceInstance(L3Network network, ServiceInstance serviceInstance) { AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index b5bb0bed94..380a94f951 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -52,6 +52,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; @@ -71,6 +72,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.db.catalog.beans.OrchestrationStatus; public class TestDataSetup{ private int collectionCounter; @@ -686,4 +688,12 @@ public class TestDataSetup{ serviceInstance.setConfigurations(configurations); return config; } + + public Subnet buildSubnet() { + Subnet subnet = new Subnet(); + subnet.setSubnetId("testSubnetId"); + subnet.setOrchestrationStatus(OrchestrationStatus.PENDING); + subnet.setNeutronSubnetId("testNeutronSubnetId"); + return subnet; + } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index d800ae9618..55958946a3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -21,14 +21,24 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.HashMap; import org.camunda.bpm.engine.delegate.BpmnError; +import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -36,6 +46,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -52,6 +63,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ private VolumeGroup volumeGroup; private CloudRegion cloudRegion; private Configuration configuration; + private Subnet subnet; @Before public void before() { @@ -62,6 +74,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ cloudRegion = setCloudRegion(); network = setL3Network(); configuration = setConfiguration(); + subnet = buildSubnet(); } @Test @@ -290,51 +303,14 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ doThrow(Exception.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution); } - - @Test - public void updateOstatusAssignedNetworkTest() throws Exception { - doNothing().when(aaiNetworkResources).updateNetwork(network); - - aaiUpdateTasks.updateOrchestrationStatusAssignedNetwork(execution); - - verify(aaiNetworkResources, times(1)).updateNetwork(network); - assertEquals("", network.getHeatStackId()); - } @Test - public void updateOstatusAssignedNetworkExceptionTest() throws Exception { - expectedException.expect(BpmnError.class); - - doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network); - - aaiUpdateTasks.updateOrchestrationStatusAssignedNetwork(execution); - } - - @Test - public void updateOstatusActivedNetworkTest() throws Exception { - doNothing().when(aaiNetworkResources).updateNetwork(network); - - aaiUpdateTasks.updateOrchestrationStatusActiveNetwork(execution); - - verify(aaiNetworkResources, times(1)).updateNetwork(network); - } - - @Test - public void updateOstatusCreatedNetworkTest() throws Exception { - doNothing().when(aaiNetworkResources).updateNetwork(network); - - aaiUpdateTasks.updateOrchestrationStatusActiveNetwork(execution); - - verify(aaiNetworkResources, times(1)).updateNetwork(network); - } - - @Test - public void updateOstatusActiveNetworkExceptionTest() throws Exception { + public void updateNetworkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network); - aaiUpdateTasks.updateOrchestrationStatusActiveNetwork(execution); + aaiUpdateTasks.updateNetwork(execution, OrchestrationStatus.ACTIVE); } @Test @@ -374,20 +350,62 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse(); createNetworkResponse.setNetworkFqdn("testNetworkFqdn"); createNetworkResponse.setNetworkStackId("testNetworkStackId"); + HashMap<String, String> subnetMap = new HashMap<String, String>(); + subnetMap.put("testSubnetId", "testNeutronSubnetId"); + createNetworkResponse.setSubnetMap(subnetMap); + + network.getSubnets().add(subnet); execution.setVariable("createNetworkResponse", createNetworkResponse); doNothing().when(aaiNetworkResources).updateNetwork(network); + doNothing().when(aaiNetworkResources).updateSubnet(network, subnet); + aaiUpdateTasks.updateNetworkCreated(execution); verify(aaiNetworkResources, times(1)).updateNetwork(network); + verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet); assertEquals(createNetworkResponse.getNetworkFqdn(), network.getContrailNetworkFqdn()); assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus()); assertEquals(createNetworkResponse.getNetworkStackId(), network.getHeatStackId()); assertEquals(createNetworkResponse.getNeutronNetworkId(), network.getNeutronNetworkId()); + String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue(); + assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId()); } @Test + public void updateOrchestrationStatusNetworkTest() { + AAIUpdateTasks spy = Mockito.spy(new AAIUpdateTasks()); + doNothing().when(spy).updateNetwork(eq(execution), any()); + spy.updateOrchestrationStatusActiveNetwork(execution); + verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ACTIVE); + spy.updateOrchestrationStatusAssignedNetwork(execution); + verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ASSIGNED); + spy.updateOrchestrationStatusCreatedNetwork(execution); + verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.CREATED); + } + + @Test + public void updateNetworkAAITest() { + + L3Network spy = spy(new L3Network()); + L3Network shallowCopy = mock(L3Network.class); + Subnet mockSubnet = mock(Subnet.class); + Subnet shallowCopySubnet = mock(Subnet.class); + when(mockSubnet.shallowCopyId()).thenReturn(shallowCopySubnet); + doReturn(shallowCopy).when(spy).shallowCopyId(); + + doNothing().when(aaiNetworkResources).updateNetwork(network); + doNothing().when(aaiNetworkResources).updateSubnet(network, subnet); + + spy.getSubnets().add(mockSubnet); + aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED); + + verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED); + verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED); + verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED); + } + @Test public void updateNetworkCreatedkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java index 7cade7703a..dcc95affce 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.appc.tasks; import static org.mockito.Mockito.times; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java index b818b07c1f..b4ec68050e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.hamcrest.CoreMatchers.is; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java index 99f1b188c9..d86453b87c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java @@ -654,4 +654,21 @@ public class AAIObjectMapperTest { assertThat(actualRouteTarget, sameBeanAs(expectedRouteTarget)); } + + @Test + public void mapSubnetTest() { + Subnet subnet = new Subnet(); + subnet.setSubnetId("testSubnetId"); + subnet.setOrchestrationStatus(OrchestrationStatus.PENDING); + subnet.setNeutronSubnetId("testNeutronSubnetId"); + + org.onap.aai.domain.yang.Subnet expectedSubnet = new org.onap.aai.domain.yang.Subnet(); + expectedSubnet.setSubnetId("testSubnetId"); + expectedSubnet.setOrchestrationStatus("Pending"); + expectedSubnet.setNeutronSubnetId("testNeutronSubnetId"); + + org.onap.aai.domain.yang.Subnet actualSubnet = aaiObjectMapper.mapSubnet(subnet); + + assertThat(actualSubnet, sameBeanAs(expectedSubnet)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java index fddba98f4c..8f0d00ff86 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java @@ -21,6 +21,7 @@ package org.onap.so.client.adapter.network.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.*; import static org.mockito.Mockito.doReturn; import java.io.UnsupportedEncodingException; @@ -38,6 +39,7 @@ import org.onap.so.adapters.nwrest.ContrailNetwork; import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.NetworkTechnology; import org.onap.so.adapters.nwrest.ProviderVlanNetwork; import org.onap.so.adapters.nwrest.RollbackNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; @@ -96,6 +98,24 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ } @Test + public void testSetNetworkTechnology() { + String networkTechnology = "Contrail"; + NetworkTechnology expectedNetworkTechnology = NetworkTechnology.CONTRAIL; + NetworkTechnology actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology); + assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology); + + networkTechnology = "Neutron"; + expectedNetworkTechnology = NetworkTechnology.NEUTRON; + actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology); + assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology); + + networkTechnology = "Vmware"; + expectedNetworkTechnology = NetworkTechnology.VMWARE; + actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology); + assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology); + + } + @Test public void buildCreateNetworkRequestFromBbobjectTest() throws Exception { String cloudRegionPo = "cloudRegionPo"; @@ -108,7 +128,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ expectedCreateNetworkRequest.setNetworkType(l3Network.getNetworkType()); expectedCreateNetworkRequest.setBackout(false); expectedCreateNetworkRequest.setFailIfExists(true); - + expectedCreateNetworkRequest.setNetworkTechnology(NetworkTechnology.CONTRAIL); MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId(requestContext.getMsoRequestId()); msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId()); @@ -124,10 +144,11 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ List<Subnet> subnetList = new ArrayList<Subnet>(); subnetList.add(openstackSubnet); l3Network.getSubnets().add(openstackSubnet); + l3Network.getModelInfoNetwork().setNetworkTechnology("Contrail"); CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer); - assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId")); + assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId")); } @Test @@ -232,7 +253,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ expectedUpdateNetworkRequest.setNetworkParams(userInput); expectedUpdateNetworkRequest.setMsoRequest(msoRequest); expectedUpdateNetworkRequest.setSkipAAI(true); - expectedUpdateNetworkRequest.setBackout(!Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); + expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); expectedUpdateNetworkRequest.setMessageId("messageId"); expectedUpdateNetworkRequest.setNotificationUrl("http://localhost:28080/mso/WorkflowMesssage/NetworkAResponse/messageId"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java index b2f01f007f..8f5c8dfb5e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java @@ -134,7 +134,7 @@ public class VnfAdapterObjectMapperTest { expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams); expectedCreateVolumeGroupRequest.setSkipAAI(true); - expectedCreateVolumeGroupRequest.setSuppressBackout(orchestrationContext.getIsRollbackEnabled()); + expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); expectedCreateVolumeGroupRequest.setFailIfExists(true); MsoRequest msoRequest = new MsoRequest(); @@ -210,7 +210,7 @@ public class VnfAdapterObjectMapperTest { expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams); expectedCreateVolumeGroupRequest.setSkipAAI(true); - expectedCreateVolumeGroupRequest.setSuppressBackout(orchestrationContext.getIsRollbackEnabled()); + expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); expectedCreateVolumeGroupRequest.setFailIfExists(true); MsoRequest msoRequest = new MsoRequest(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index a68afd811a..32a495e094 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -135,6 +135,80 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { } @Test + public void createVfModuleWithFalseRollbackRequestMapperTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); + modelInfoServiceInstance.setModelName("serviceModelName"); + modelInfoServiceInstance.setModelUuid("serviceModelUuid"); + modelInfoServiceInstance.setModelVersion("serviceModelVersion"); + modelInfoServiceInstance.setEnvironmentContext("environmentContext"); + modelInfoServiceInstance.setWorkloadContext("workloadContext"); + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + + RequestContext requestContext = new RequestContext(); + HashMap<String, String> userParams = new HashMap<String, String>(); + userParams.put("key1", "value2"); + requestContext.setMsoRequestId("requestId"); + requestContext.setUserParams(userParams); + requestContext.setProductFamilyId("productFamilyId"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("vnfId"); + vnf.setVnfType("vnfType"); + vnf.setVnfName("vnfName"); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); + modelInfoGenericVnf.setModelName("vnfModelName"); + modelInfoGenericVnf.setModelVersion("vnfModelVersion"); + modelInfoGenericVnf.setModelUuid("vnfModelUuid"); + modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); + vnf.setModelInfoGenericVnf(modelInfoGenericVnf); + + Integer vfModuleIndex = 1; + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setVfModuleName("vfModuleName"); + vfModule.setModuleIndex(vfModuleIndex); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); + modelInfoVfModule.setModelName("vfModuleModelName"); + modelInfoVfModule.setModelVersion("vfModuleModelVersion"); + modelInfoVfModule.setModelUUID("vfModuleModelUuid"); + modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); + vfModule.setModelInfoVfModule(modelInfoVfModule); + HashMap<String, String> cloudParams = new HashMap<String, String>(); + cloudParams.put("key3", "value3"); + vfModule.setCloudParams(cloudParams); + + CloudRegion cloudRegion = new CloudRegion(); + cloudRegion.setLcpCloudRegionId("cloudRegionId"); + cloudRegion.setTenantId("tenantId"); + + OrchestrationContext orchestrationContext = new OrchestrationContext(); + orchestrationContext.setIsRollbackEnabled(true); + + String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json"))); + String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json"))); + + CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper( + requestContext, cloudRegion, orchestrationContext, serviceInstance, + vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse); + + + String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestTrueBackout.json"))); + + CreateVfModuleRequest reqMapper1 = omapper.readValue( + jsonToCompare, + CreateVfModuleRequest.class); + + assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); + } + + @Test public void createVfModuleRequestWithNoEnvironmentAndWorkloadContextMapperTest() throws Exception { // prepare and set service instance diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java index fa3324840c..cf270c21a7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java @@ -55,6 +55,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -74,6 +75,7 @@ public class AAINetworkResourcesTest extends TestDataSetup{ private InstanceGroup instanceGroup; private ServiceInstance serviceInstance; private CloudRegion cloudRegion; + private Subnet subnet; @Mock protected AAIResourcesClient MOCK_aaiResourcesClient; @@ -101,6 +103,9 @@ public class AAINetworkResourcesTest extends TestDataSetup{ serviceInstance = buildServiceInstance(); cloudRegion = buildCloudRegion(); + + subnet = buildSubnet(); + doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient(); } @@ -314,4 +319,15 @@ public class AAINetworkResourcesTest extends TestDataSetup{ aaiNetworkResources.deleteNetworkInstanceGroup(instanceGroup); verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class)); } + + @Test + public void updateSubnetTest() throws Exception { + + doReturn(new org.onap.aai.domain.yang.Subnet()).when(MOCK_aaiObjectMapper).mapSubnet(subnet); + doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Subnet.class)); + + aaiNetworkResources.updateSubnet(network, subnet); + + verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Subnet.class)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json index 087f8a3971..a9cef565df 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json @@ -5,7 +5,7 @@ "networkName": "APP-C-24595-T-IST-04AShared_data_vDB_net_1", "networkType": "CONTRAIL30_BASIC", "modelCustomizationUuid": "8edf06ef-fd40-42cf-a054-0fc09108d3f0", - "networkTechnology": "NEUTRON", + "networkTechnology": "CONTRAIL", "subnets": [ { "subnetName": "APP-C-24595-T-IST-04AShared_data_vDB_net_1_subnet_1", @@ -35,7 +35,7 @@ "requestId": "6cfde724-76c7-4747-bcb3-67a59a46ca95", "serviceInstanceId": "testServiceInstanceId1" }, - "contrailRequest": false, + "contrailRequest": true, "skipAAI": true, "messageId": "175264dc-fb6b-4aae-ba42-8c77a63fec12", "synchronous": true diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json new file mode 100644 index 0000000000..bd06f5f86f --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json @@ -0,0 +1,68 @@ +{ + "cloudSiteId": "cloudRegionId", + "tenantId": "tenantId", + "vnfId": "vnfId", + "vnfType": "vnfType", + "vfModuleId": "vfModuleId", + "vfModuleName": "vfModuleName", + "vfModuleType": "vfModuleModelName", + "vnfVersion": "serviceModelVersion", + "modelCustomizationUuid": "vfModuleModelCustomizationUuid", + "skipAAI": true, + "backout": true, + "failIfExists": true, + "msoRequest": + { + "requestId": "requestId", + "serviceInstanceId": "serviceInstanceId" + }, + + "vfModuleParams": + { + "vnf_id": "vnfId", + "vnf_name": "vnfName", + "vf_module_id": "vfModuleId", + "vf_module_index": "1", + "vf_module_name": "vfModuleName", + "environment_context": "environmentContext", + "fw_0_subint_ctrl_port_0_ip": "ip0,ip1", + "fw_0_subint_ctrl_port_0_ip_0": "ip0", + "fw_0_subint_ctrl_port_0_ip_1": "ip1", + "fw_0_subint_ctrl_port_0_net_ids": "networkId0", + "fw_0_subint_ctrl_port_0_net_names": "1", + "fw_subint_ctrl_port_0_subintcount": "1", + "fw_0_subint_ctrl_port_0_v6_ip": "ip0,ip1", + "fw_0_subint_ctrl_port_0_v6_ip_0": "ip0", + "fw_0_subint_ctrl_port_0_v6_ip_1": "ip1", + "fw_0_subint_ctrl_port_0_vlan_ids": "1", + "fw_subint_ctrl_port_0_floating_ip": "floatingIpV40", + "fw_subint_ctrl_port_0_floating_v6_ip": "floatingIpV60", + "workload_context": "workloadContext", + "key1": "value2", + "key3": "value3", + "availability_zone_0": "zone0", + "availability_zone_1": "zone1", + "availability_zone_2": "zone2", + "vnfNetworkRole0_net_fqdn": "netFqdnValue0", + "vnfNetworkRole0_net_id": "neutronId0", + "vnfNetworkRole0_net_name": "netName0", + "vnfNetworkRole0_subnet_id": "subnetId0", + "vnfNetworkRole0_v6_subnet_id": "subnetId1", + "vmType0_name_0": "vmName0", + "vmType0_name_1": "vmName1", + "vmType0_names": "vmName0,vmName1", + "vmType0_vmNetworkRole0_floating_ip": "floatingIpV40", + "vmType0_vmNetworkRole0_floating_v6_ip": "floatingIpV60", + "vmType0_vmNetworkRole0_route_prefixes": "[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]", + "vmNetworkRole0_ATT_VF_VLAN_FILTER": "heatVlanFilter0,heatVlanFilter1", + "vmType0_vmNetworkRole0_ip_0": "ip0", + "vmType0_vmNetworkRole0_ip_1": "ip1", + "vmType0_vmNetworkRole0_ips": "ip0,ip1", + "vmType0_vmNetworkRole0_v6_ip_0": "ip2", + "vmType0_vmNetworkRole0_v6_ip_1": "ip3", + "vmType0_vmNetworkRole0_v6_ips": "ip2,ip3", + "paramOne": "paramOneValue", + "paramTwo": "paramTwoValue", + "paramThree": "paramThreeValue" + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java index 7e4397ec29..e91dc43af9 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java @@ -245,18 +245,22 @@ public class AAIResourcesClient extends AAIClient { String json; try { json = this.createClient(uri).get(String.class) - .orElseThrow(() -> createException(c, uri.build() + " not found in A&AI")); + .orElseThrow(() -> createException(c, uri.build() + " not found in A&AI", Optional.empty())); } catch (NotFoundException e) { - throw createException(c, "could not construct uri for use with A&AI"); + throw createException(c, "could not construct uri for use with A&AI", Optional.of(e)); } return new AAIResultWrapper(json); } - private RuntimeException createException(Class<? extends RuntimeException> c, String message) { + private RuntimeException createException(Class<? extends RuntimeException> c, String message, Optional<Throwable> t) { RuntimeException e; try { - e = c.getConstructor(String.class).newInstance(message); + if (t.isPresent()) { + e = c.getConstructor(String.class, Throwable.class).newInstance(message, t.get()); + } else { + e = c.getConstructor(String.class).newInstance(message); + } } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e1) { throw new IllegalArgumentException("could not create instance for " + c.getName()); diff --git a/common/src/main/java/org/onap/so/constants/Defaults.java b/common/src/main/java/org/onap/so/constants/Defaults.java index abbd522b4e..06c6fae467 100644 --- a/common/src/main/java/org/onap/so/constants/Defaults.java +++ b/common/src/main/java/org/onap/so/constants/Defaults.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.so.constants; public enum Defaults { diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java index cc2ccb5c2e..9624dcd578 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java @@ -32,8 +32,10 @@ public class MDCTaskDecorator implements TaskDecorator { Map<String, String> contextMap = MDC.getCopyOfContextMap(); return () -> { try { - MDC.setContextMap(contextMap); - runnable.run(); + if(contextMap!=null){ + MDC.setContextMap(contextMap); + runnable.run(); + } } finally { MDC.clear(); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index b3ee40bb8b..dfcf9ffc46 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -2392,4 +2392,4 @@ public class ServiceInstancesTest extends BaseTest{ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); } -}
\ No newline at end of file +} |