diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
11 files changed, 178 insertions, 131 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index 8711f965fd..5534a39685 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -55,6 +55,7 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; +import org.onap.so.client.orchestration.AAIInstanceGroupResources; import org.onap.so.client.orchestration.AAINetworkResources; import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; @@ -97,6 +98,8 @@ public class AAICreateTasks { @Autowired private AAIConfigurationResources aaiConfigurationResources; @Autowired + private AAIInstanceGroupResources aaiInstanceGroupResources; + @Autowired private Environment env; public void createServiceInstance(BuildingBlockExecution execution) { @@ -450,6 +453,16 @@ public class AAICreateTasks { } } + public void createInstanceGroupVnf(BuildingBlockExecution execution){ + try{ + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, execution.getLookupMap().get(ResourceKey.INSTANCE_GROUP_ID)); + aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + public void createNetworkPolicies(BuildingBlockExecution execution) { try{ String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java index 4908cda26a..6e4a5f3d15 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java @@ -32,6 +32,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +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.VfModule; @@ -43,6 +44,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; +import org.onap.so.client.orchestration.AAIInstanceGroupResources; import org.onap.so.client.orchestration.AAINetworkResources; import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; @@ -76,6 +78,8 @@ public class AAIDeleteTasks { private AAIVolumeGroupResources aaiVolumeGroupResources; @Autowired private AAIConfigurationResources aaiConfigurationResources; + @Autowired + private AAIInstanceGroupResources aaiInstanceGroupResources; public void deleteVfModule(BuildingBlockExecution execution) throws Exception { GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); @@ -162,6 +166,15 @@ public class AAIDeleteTasks { } } + public void deleteInstanceGroupVnf(BuildingBlockExecution execution) { + try { + InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, execution.getLookupMap().get(ResourceKey.INSTANCE_GROUP_ID)); + aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + public void deleteNetworkPolicies(BuildingBlockExecution execution) { try{ String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java index 932558d8ad..1815fcd827 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java @@ -9,9 +9,9 @@ * 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. @@ -43,6 +43,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import static org.apache.commons.lang3.StringUtils.*; @Component public class VnfAdapterCreateTasks { @@ -91,25 +92,27 @@ public class VnfAdapterCreateTasks { public void createVfModule(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - + ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); VolumeGroup volumeGroup = null; try { volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); - } catch(BBObjectNotFoundException bbException) { + } catch(BBObjectNotFoundException bbException) { } CloudRegion cloudRegion = gBBInput.getCloudRegion(); RequestContext requestContext = gBBInput.getRequestContext(); OrchestrationContext orchestrationContext = gBBInput.getOrchContext(); String sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()); String sdncVnfQueryResponse = execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()); - + CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse); execution.setVariable(VNFREST_REQUEST, createVfModuleRequest.toXmlString()); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java index aaa9e51d15..8cb7cbbe91 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java @@ -7,9 +7,9 @@ * 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. @@ -38,22 +38,22 @@ import org.springframework.stereotype.Component; @Component public class AuditTasks { - + private static final Logger logger = LoggerFactory.getLogger(AuditTasks.class); @Autowired private ExceptionBuilder exceptionUtil; - + @Autowired private ExtractPojosForBB extractPojosForBB; - + @Autowired private Environment env; - + public void isAuditNeeded(BuildingBlockExecution execution) { - try { + try { logger.debug("auditInventoryNeeded Value: {}", env.getProperty("mso.infra.auditInventory")); - execution.setVariable("auditInventoryNeeded",env.getProperty("mso.infra.auditInventory")); + execution.setVariable("auditInventoryNeeded", Boolean.parseBoolean(env.getProperty("mso.infra.auditInventory"))); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -66,14 +66,14 @@ public class AuditTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } - + private AuditInventory createAuditInventory(BuildingBlockExecution execution) throws BBObjectNotFoundException { AuditInventory auditInventory = new AuditInventory(); - + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - + auditInventory.setCloudOwner(cloudRegion.getCloudOwner()); auditInventory.setCloudRegion(cloudRegion.getLcpCloudRegionId()); auditInventory.setTenantId(cloudRegion.getTenantId()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java index bba883e727..752c39a0a6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -25,14 +27,15 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class CloudSiteCatalogUtils { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CloudSiteCatalogUtils.class); + private static final Logger logger = LoggerFactory.getLogger(CloudSiteCatalogUtils.class); @Autowired private ExceptionBuilder exceptionUtil; @@ -46,17 +49,17 @@ public class CloudSiteCatalogUtils { if (cloudRegionId != null) { Optional<CloudSite> cloudSite = getCloudSite(cloudRegionId); if (!cloudSite.isPresent()) { - msoLogger.debug("Cloud Region with cloudRegionId " + cloudRegionId + " not found in Catalog DB"); + logger.debug("Cloud Region with cloudRegionId {} not found in Catalog DB", cloudRegionId); exceptionUtil.buildAndThrowWorkflowException(execution, 404, "Cloud Region with cloudRegionId " + cloudRegionId + " not found in Catalog DB"); } if (cloudSite.get().getIdentityService() == null) { - msoLogger.debug("No identityService found for Cloud Region with cloudRegionId " + cloudRegionId + " in Catalog DB"); + logger.debug("No identityService found for Cloud Region with cloudRegionId {} in Catalog DB", cloudRegionId); exceptionUtil.buildAndThrowWorkflowException(execution, 404, "No identityService found for Cloud Region with cloudRegionId " + cloudRegionId + " in Catalog DB"); } String identityUrl = cloudSite.get().getIdentityService().getIdentityUrl(); - msoLogger.debug("identityUrl from Catalog DB is: " + identityUrl); + logger.debug("identityUrl from Catalog DB is: {}", identityUrl); execution.setVariable("identityUrl", identityUrl); } } @@ -73,4 +76,4 @@ public class CloudSiteCatalogUtils { return(Optional.of(catalogDbClient.getCloudSiteByClliAndAicVersion(id,"2.5"))); } } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java index 75f293655f..a622520a71 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java @@ -108,6 +108,10 @@ public class OrchestrationStatusValidator { org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID)); orchestrationStatus = configuration.getOrchestrationStatus(); break; + case INSTANCE_GROUP: + org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, execution.getLookupMap().get(ResourceKey.INSTANCE_GROUP_ID)); + orchestrationStatus = instanceGroup.getOrchestrationStatus(); + break; case NO_VALIDATE: //short circuit and exit method execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.VALIDATION_SKIPPED); 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 8a3a778b06..d87b11a1a6 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 @@ -108,7 +108,7 @@ public class WorkflowAction { private static final String ASSIGNINSTANCE = "assignInstance"; private static final String CREATEINSTANCE = "createInstance"; private static final String USERPARAMSERVICE = "service"; - private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances"; + private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups"; private static final String HOMINGSOLUTION = "Homing_Solution"; private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; private static final String G_SERVICE_TYPE = "serviceType"; @@ -202,17 +202,25 @@ public class WorkflowAction { orchFlows = filterOrchFlows(sIRequest, orchFlows, resourceType, execution); String key = ""; ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo(); - if(modelInfo.getModelType().equals(ModelType.service)) { - key = modelInfo.getModelVersionId(); - } else { - key = modelInfo.getModelCustomizationId(); + if(modelInfo != null) { + if(modelInfo.getModelType().equals(ModelType.service)) { + key = modelInfo.getModelVersionId(); + } else { + key = modelInfo.getModelCustomizationId(); + } } + boolean isConfiguration = isConfiguration(orchFlows); Resource resourceKey = new Resource(resourceType, key, aLaCarte); + List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks(sIRequest, orchFlows, requestId, resourceKey, apiVersion, resourceId, requestAction, aLaCarte, vnfType, + workflowResourceIds, requestDetails, isConfiguration); for (OrchestrationFlow orchFlow : orchFlows) { - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false); - flowsToExecute.add(ebb); + if(!orchFlow.getFlowName().contains("Configuration")) { + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false); + flowsToExecute.add(ebb); + } } + flowsToExecute.addAll(configBuildingBlocks); } else { boolean foundRelated = false; boolean containsService = false; @@ -339,6 +347,53 @@ public class WorkflowAction { buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex); } } + + protected boolean isConfiguration(List<OrchestrationFlow> orchFlows) { + for(OrchestrationFlow flow : orchFlows) { + if(flow.getFlowName().contains("Configuration")) { + return true; + } + } + return false; + } + + protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ServiceInstancesRequest sIRequest, List<OrchestrationFlow> orchFlows, String requestId, Resource resourceKey, + String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, + WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean isConfiguration) { + List<OrchestrationFlow> result = new ArrayList<>(orchFlows); + result = orchFlows.stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList()); + String vnfCustomizationUUID = ""; + String vfModuleCustomizationUUID = sIRequest.getRequestDetails().getModelInfo().getModelCustomizationUuid(); + RelatedInstanceList[] relatedInstanceList = sIRequest.getRequestDetails().getRelatedInstanceList(); + if (relatedInstanceList != null) { + for (RelatedInstanceList relatedInstList : relatedInstanceList) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { + vnfCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationUuid(); + } + } + } + + List<VnfVfmoduleCvnfcConfigurationCustomization> fabricCustomizations = traverseCatalogDbForConfiguration(vnfCustomizationUUID, vfModuleCustomizationUUID); + List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>(); + for(VnfVfmoduleCvnfcConfigurationCustomization fabricConfig : fabricCustomizations) { + + if (requestAction.equals(CREATEINSTANCE)) { + workflowResourceIds.setConfigurationId(UUID.randomUUID().toString()); + } else { + //TODO AAI lookup for configuration update/delete + } + for(OrchestrationFlow orchFlow : result) { + resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID); + resourceKey.setCvnfModuleCustomizationId(fabricConfig.getCvnfcCustomization().getModelCustomizationUUID()); + resourceKey.setVnfCustomizationId(vnfCustomizationUUID); + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true); + flowsToExecuteConfigs.add(ebb); + } + } + return flowsToExecuteConfigs; + } protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) { int count = 0; @@ -698,9 +753,9 @@ public class WorkflowAction { vfModuleCustomizationUUID = vfModule.getModelInfo().getModelCustomizationUuid(); } if(!vnfCustomizationUUID.equals("")&&!vfModuleCustomizationUUID.equals("")){ - List<String> configs = traverseCatalogDbForConfiguration(vnfCustomizationUUID,vfModuleCustomizationUUID); - for(String config : configs){ - Resource configResource = new Resource(WorkflowType.CONFIGURATION,config,false); + List<VnfVfmoduleCvnfcConfigurationCustomization> configs = traverseCatalogDbForConfiguration(vnfCustomizationUUID,vfModuleCustomizationUUID); + for(VnfVfmoduleCvnfcConfigurationCustomization config : configs){ + Resource configResource = new Resource(WorkflowType.CONFIGURATION,config.getConfigurationResource().getModelUUID(),false); resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId()); resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId()); resourceCounter.add(configResource); @@ -734,20 +789,19 @@ public class WorkflowAction { } return foundRelated; } - - protected List<String> traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) { - List<String> configurations = new ArrayList<>(); + protected List<VnfVfmoduleCvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) { + List<VnfVfmoduleCvnfcConfigurationCustomization> configurations = new ArrayList<>(); try{ List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(vnfCustomizationUUID, vfModuleCustomizationUUID); for(CvnfcCustomization cvnfc : cvnfcCustomizations){ for(VnfVfmoduleCvnfcConfigurationCustomization customization : cvnfc.getVnfVfmoduleCvnfcConfigurationCustomization()){ if(customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)){ - configurations.add(customization.getConfigurationResource().getModelUUID()); + configurations.add(customization); } } } - logger.debug("found {} configurations" , configurations.size() ); + logger.debug("found {} configuration(s)" , configurations.size() ); return configurations; } catch (Exception ex){ logger.error("Error in finding configurations", ex); @@ -774,6 +828,7 @@ public class WorkflowAction { workflowResourceIds.setVfModuleId((String) execution.getVariable("vfModuleId")); workflowResourceIds.setVnfId((String) execution.getVariable("vnfId")); workflowResourceIds.setVolumeGroupId((String) execution.getVariable("volumeGroupId")); + workflowResourceIds.setInstanceGroupId((String) execution.getVariable("instanceGroupId")); return workflowResourceIds; } @@ -1048,7 +1103,7 @@ public class WorkflowAction { executeBuildingBlock.setRequestId(requestId); executeBuildingBlock.setBuildingBlock(buildingBlock); executeBuildingBlock.setRequestDetails(requestDetails); - if(isConfiguration){ + if(resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))){ ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); if (resource != null){ configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId()); @@ -1120,7 +1175,7 @@ public class WorkflowAction { } if (resourceType.equals(WorkflowType.VFMODULE)) { - List<String> fabricCustomizations = traverseCatalogDbForConfiguration(vnfCustomizationUUID, vfModuleCustomizationUUID); + List<VnfVfmoduleCvnfcConfigurationCustomization> fabricCustomizations = traverseCatalogDbForConfiguration(vnfCustomizationUUID, vfModuleCustomizationUUID); if (fabricCustomizations.isEmpty()) { result = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList()); } 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 2e91a52f65..33a89e0b82 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 @@ -161,6 +161,7 @@ public class WorkflowActionBBTasks { WorkflowContextHolder.getInstance().processCallback(processKey, execution.getProcessInstanceId(), requestId, callbackResponse); logger.info("Successfully sent sync ack."); + updateInstanceId(execution); } public void sendErrorSyncAck(DelegateExecution execution) { @@ -303,100 +304,31 @@ public class WorkflowActionBBTasks { workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state."); } } - - protected void updateRequestErrorStatusMessage(DelegateExecution execution) { - try { - String requestId = (String) execution.getVariable(G_REQUEST_ID); - InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); - String errorMsg = retrieveErrorMessage(execution); - if(errorMsg == null || errorMsg.equals("")){ - errorMsg = "Failed to determine error message"; - } - request.setStatusMessage(errorMsg); - logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg); - requestDbclient.updateInfraActiveRequests(request); - } catch (Exception e) { - logger.error("Failed to update Request db with the status message after retry or rollback has been initialized.",e); - } - } - - public void abortCallErrorHandling(DelegateExecution execution) { - String msg = "Flow has failed. Rainy day handler has decided to abort the process."; - logger.error(msg); - throw new BpmnError(msg); - } - public void updateRequestStatusToFailed(DelegateExecution execution) { - try { + protected void updateInstanceId(DelegateExecution execution){ + try{ String requestId = (String) execution.getVariable(G_REQUEST_ID); + String resourceId = (String) execution.getVariable("resourceId"); + WorkflowType resourceType = (WorkflowType) execution.getVariable("resourceType"); InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); - String errorMsg = null; - String rollbackErrorMsg = null; - boolean rollbackCompleted = (boolean) execution.getVariable("isRollbackComplete"); - boolean isRollbackFailure = (boolean) execution.getVariable("isRollback"); - ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); - - if(rollbackCompleted){ - rollbackErrorMsg = "Rollback has been completed successfully."; - request.setRollbackStatusMessage(rollbackErrorMsg); - logger.debug("Updating RequestDB to failed: Rollback has been completed successfully"); - }else{ - if(isRollbackFailure){ - rollbackErrorMsg = retrieveErrorMessage(execution); - if(rollbackErrorMsg == null || rollbackErrorMsg.equals("")){ - rollbackErrorMsg = "Failed to determine rollback error message."; - } - request.setRollbackStatusMessage(rollbackErrorMsg); - logger.debug("Updating RequestDB to failed: rollbackErrorMsg = " + rollbackErrorMsg); - }else{ - errorMsg = retrieveErrorMessage(execution); - if(errorMsg == null || errorMsg.equals("")){ - errorMsg = "Failed to determine error message"; - } - request.setStatusMessage(errorMsg); - logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg); - } - } - if(ebb!=null && ebb.getBuildingBlock()!=null){ - String flowStatus = ebb.getBuildingBlock().getBpmnFlowName() + " has failed."; - request.setFlowStatus(flowStatus); - execution.setVariable("flowStatus", flowStatus); + if(resourceType == WorkflowType.SERVICE){ + request.setServiceInstanceId(resourceId); + }else if(resourceType == WorkflowType.VNF){ + request.setVnfId(resourceId); + }else if(resourceType == WorkflowType.VFMODULE){ + request.setVfModuleId(resourceId); + }else if(resourceType == WorkflowType.VOLUMEGROUP){ + request.setVolumeGroupId(resourceId); + }else if(resourceType == WorkflowType.NETWORK){ + request.setNetworkId(resourceId); + }else if(resourceType == WorkflowType.CONFIGURATION){ + request.setConfigurationId(resourceId); + }else if(resourceType == WorkflowType.INSTANCE_GROUP){ + request.setInstanceGroupId(resourceId); } - - request.setProgress(Long.valueOf(100)); - request.setRequestStatus("FAILED"); - request.setLastModifiedBy("CamundaBPMN"); requestDbclient.updateInfraActiveRequests(request); - } catch (Exception e) { - workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e); + }catch(Exception ex){ + workflowAction.buildAndThrowException(execution, "Failed to update Request db with instanceId"); } } - - private String retrieveErrorMessage (DelegateExecution execution){ - String errorMsg = ""; - try { - WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException"); - if(exception != null && (exception.getErrorMessage()!=null || !exception.getErrorMessage().equals(""))){ - errorMsg = exception.getErrorMessage(); - } - } catch (Exception ex) { - //log error and attempt to extact WorkflowExceptionMessage - logger.error("Failed to extract workflow exception from execution.",ex); - } - - if (errorMsg == null || errorMsg.equals("")){ - try { - errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage"); - } catch (Exception ex) { - logger.error("Failed to extract workflow exception message from WorkflowException",ex); - errorMsg = "Unexpected Error in BPMN."; - } - } - return errorMsg; - } - - public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) { - execution.setVariable("isRollbackComplete", true); - updateRequestStatusToFailed(execution); - } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java index ff5ba152b9..304b4000bd 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java @@ -29,7 +29,8 @@ public enum WorkflowType { NETWORK("Network"), VIRTUAL_LINK("VirtualLink"), NETWORKCOLLECTION("NetworkCollection"), - CONFIGURATION("Configuration"); + CONFIGURATION("Configuration"), + INSTANCE_GROUP("InstanceGroup"); private final String type; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java index a96f01c3d0..3bb1d81e27 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java @@ -27,6 +27,7 @@ import javax.ws.rs.core.UriBuilder; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @@ -124,6 +125,20 @@ public class AAIConfigurationResources { serviceInstanceId); injectionHelper.getAaiClient().connect(configurationURI, serviceInstanceURI); } + + /** + * A&AI call to add configuration relationship with service instance + * + * @param configurationId + * @param serviceInstanceId + * @param aaiLabel + */ + public void connectConfigurationToServiceInstance(String configurationId, String serviceInstanceId, AAIEdgeLabel aaiLabel) { + AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + serviceInstanceId); + injectionHelper.getAaiClient().connect(configurationURI, serviceInstanceURI, aaiLabel); + } /** * A&AI call to add configuration relationship with generic-vnf diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java index 68f6e8ffa2..c325dd75ee 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java @@ -25,6 +25,7 @@ import java.util.Optional; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIResourceUri; @@ -68,5 +69,12 @@ public class AAIInstanceGroupResources { AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); return injectionHelper.getAaiClient().exists(instanceGroupUri); } - + + public void createInstanceGroupandConnectServiceInstance(InstanceGroup instanceGroup, ServiceInstance serviceInstance) { + AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup); + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + serviceInstance.getServiceInstanceId()); + injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup)).connect(instanceGroupUri, serviceInstanceURI); + } } |