From 2ff435b28384a066017b690cf8a876a2cdd52d29 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 12 Oct 2018 14:03:02 -0400 Subject: 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) --- .../infrastructure/aai/tasks/AAIUpdateTasks.java | 77 ++++++++++++---------- .../infrastructure/sdnc/tasks/SDNCAssignTasks.java | 4 +- .../workflow/tasks/WorkflowAction.java | 1 + .../workflow/tasks/WorkflowActionBBTasks.java | 17 +++-- .../onap/so/client/aai/mapper/AAIObjectMapper.java | 5 +- .../network/mapper/NetworkAdapterObjectMapper.java | 23 +++++-- .../adapter/vnf/mapper/VnfAdapterObjectMapper.java | 2 +- .../vnf/mapper/VnfAdapterVfModuleObjectMapper.java | 2 +- .../client/orchestration/AAINetworkResources.java | 7 ++ 9 files changed, 82 insertions(+), 56 deletions(-) (limited to 'bpmn/so-bpmn-tasks/src/main/java/org') 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 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 subnetMap = response.getSubnetMap(); + List 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); -- cgit 1.2.3-korg