diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-03-10 10:56:41 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-03-12 09:54:12 -0400 |
commit | f99e4a56e6b9ec09ece48a7b111c9ec286220264 (patch) | |
tree | aa6b58ca16295b592cb4343da52c3ac6465a0351 /bpmn/so-bpmn-tasks/src/main | |
parent | 308c3c2085864e04848e53a589773ff2e6e2c76a (diff) |
add instance group support to SO
add create support
add delete support
added naming service support
Change-Id: Iaf4f2bdae8ea55aca71d6e9b818a76e90db0b012
Issue-ID: SO-1616
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
7 files changed, 135 insertions, 109 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/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/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); + } } |