diff options
author | Rob Daugherty <rd472p@att.com> | 2018-10-17 13:11:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-10-17 13:11:41 +0000 |
commit | 15af810c48631a9dfe24ec6b39186e3797c0143b (patch) | |
tree | 4e67c7c655ced32faf293a616db86529cf0b8aa7 /bpmn/so-bpmn-tasks/src/main/java/org | |
parent | 6ad847887d9fafce3305cd7b709154b6618ff6a7 (diff) | |
parent | 2ff435b28384a066017b690cf8a876a2cdd52d29 (diff) |
Merge "Bug fixes for casablanca"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java/org')
9 files changed, 82 insertions, 56 deletions
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); |