2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.workflow.tasks;
23 import java.sql.Timestamp;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.Optional;
27 import java.util.UUID;
28 import javax.persistence.EntityNotFoundException;
29 import org.camunda.bpm.engine.delegate.DelegateExecution;
30 import org.onap.aai.domain.yang.GenericVnf;
31 import org.onap.aai.domain.yang.InstanceGroup;
32 import org.onap.aai.domain.yang.L3Network;
33 import org.onap.aai.domain.yang.ServiceInstance;
34 import org.onap.aai.domain.yang.VfModule;
35 import org.onap.aai.domain.yang.Vnfc;
36 import org.onap.aai.domain.yang.VolumeGroup;
37 import org.onap.so.bpmn.common.DelegateExecutionImpl;
38 import org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner;
39 import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner;
40 import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse;
41 import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder;
42 import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
43 import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
44 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
45 import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
46 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
47 import org.onap.aaiclient.client.aai.AAIObjectType;
48 import org.onap.aaiclient.client.aai.entities.Configuration;
49 import org.onap.so.client.exception.ExceptionBuilder;
50 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
51 import org.onap.so.db.catalog.client.CatalogDbClient;
52 import org.onap.so.db.request.beans.InfraActiveRequests;
53 import org.onap.so.db.request.client.RequestsDbClient;
54 import org.onap.so.serviceinstancebeans.RequestReferences;
55 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
58 import org.springframework.beans.factory.annotation.Autowired;
59 import org.springframework.core.env.Environment;
60 import org.springframework.stereotype.Component;
61 import com.fasterxml.jackson.core.JsonProcessingException;
62 import com.fasterxml.jackson.databind.ObjectMapper;
65 public class WorkflowActionBBTasks {
67 private static final String G_CURRENT_SEQUENCE = "gCurrentSequence";
68 private static final String G_REQUEST_ID = "mso-request-id";
69 private static final String G_ALACARTE = "aLaCarte";
70 private static final String G_ACTION = "requestAction";
71 private static final String RETRY_COUNT = "retryCount";
72 private static final String FABRIC_CONFIGURATION = "FabricConfiguration";
73 private static final String ADD_FABRIC_CONFIGURATION_BB = "AddFabricConfigurationBB";
74 private static final String COMPLETED = "completed";
75 private static final String HANDLINGCODE = "handlingCode";
76 private static final String ROLLBACKTOCREATED = "RollbackToCreated";
77 protected String maxRetries = "mso.rainyDay.maxRetries";
78 private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class);
81 private RequestsDbClient requestDbclient;
83 private WorkflowAction workflowAction;
85 private WorkflowActionBBFailure workflowActionBBFailure;
87 private Environment environment;
89 private BBInputSetupUtils bbInputSetupUtils;
91 private CatalogDbClient catalogDbClient;
93 private FlowManipulatorListenerRunner flowManipulatorListenerRunner;
95 private RequestsDbListenerRunner requestsDbListener;
97 public void selectBB(DelegateExecution execution) {
98 List<ExecuteBuildingBlock> flowsToExecute =
99 (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
100 execution.setVariable("MacroRollback", false);
102 flowManipulatorListenerRunner.modifyFlows(flowsToExecute, new DelegateExecutionImpl(execution));
103 int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
105 ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence);
107 execution.setVariable("buildingBlock", ebb);
109 if (currentSequence >= flowsToExecute.size()) {
110 execution.setVariable(COMPLETED, true);
112 execution.setVariable(COMPLETED, false);
114 execution.setVariable(G_CURRENT_SEQUENCE, currentSequence);
117 public void updateFlowStatistics(DelegateExecution execution) {
119 int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
120 if (currentSequence > 1) {
121 InfraActiveRequests request = this.getUpdatedRequest(execution, currentSequence);
122 requestDbclient.updateInfraActiveRequests(request);
124 } catch (Exception ex) {
126 "Bpmn Flow Statistics was unable to update Request Db with the new completion percentage. Competion percentage may be invalid.",
131 protected InfraActiveRequests getUpdatedRequest(DelegateExecution execution, int currentSequence) {
132 List<ExecuteBuildingBlock> flowsToExecute =
133 (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
134 String requestId = (String) execution.getVariable(G_REQUEST_ID);
135 InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
136 ExecuteBuildingBlock completedBB = flowsToExecute.get(currentSequence - 2);
137 ExecuteBuildingBlock nextBB = flowsToExecute.get(currentSequence - 1);
138 int completedBBs = currentSequence - 1;
139 int totalBBs = flowsToExecute.size();
140 int remainingBBs = totalBBs - completedBBs;
141 String statusMessage = this.getStatusMessage(completedBB.getBuildingBlock().getBpmnFlowName(),
142 nextBB.getBuildingBlock().getBpmnFlowName(), completedBBs, remainingBBs);
143 Long percentProgress = this.getPercentProgress(completedBBs, totalBBs);
144 request.setFlowStatus(statusMessage);
145 request.setProgress(percentProgress);
146 request.setLastModifiedBy("CamundaBPMN");
150 protected Long getPercentProgress(int completedBBs, int totalBBs) {
151 double ratio = (completedBBs / (totalBBs * 1.0));
152 int percentProgress = (int) (ratio * 95);
153 return new Long(percentProgress + 5);
156 protected String getStatusMessage(String completedBB, String nextBB, int completedBBs, int remainingBBs) {
157 return "Execution of " + completedBB + " has completed successfully, next invoking " + nextBB
158 + " (Execution Path progress: BBs completed = " + completedBBs + "; BBs remaining = " + remainingBBs
162 public void sendSyncAck(DelegateExecution execution) {
163 final String requestId = (String) execution.getVariable(G_REQUEST_ID);
164 final String resourceId = (String) execution.getVariable("resourceId");
165 ServiceInstancesResponse serviceInstancesResponse = new ServiceInstancesResponse();
166 RequestReferences requestRef = new RequestReferences();
167 requestRef.setInstanceId(resourceId);
168 requestRef.setRequestId(requestId);
169 serviceInstancesResponse.setRequestReferences(requestRef);
170 ObjectMapper mapper = new ObjectMapper();
171 String jsonRequest = "";
173 jsonRequest = mapper.writeValueAsString(serviceInstancesResponse);
174 } catch (JsonProcessingException e) {
175 workflowAction.buildAndThrowException(execution,
176 "Could not marshall ServiceInstancesRequest to Json string to respond to API Handler.", e);
178 WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
179 callbackResponse.setStatusCode(200);
180 callbackResponse.setMessage("Success");
181 callbackResponse.setResponse(jsonRequest);
182 String processKey = execution.getProcessEngineServices().getRepositoryService()
183 .getProcessDefinition(execution.getProcessDefinitionId()).getKey();
184 WorkflowContextHolder.getInstance().processCallback(processKey, execution.getProcessInstanceId(), requestId,
186 logger.info("Successfully sent sync ack.");
187 updateInstanceId(execution);
190 public void sendErrorSyncAck(DelegateExecution execution) {
191 final String requestId = (String) execution.getVariable(G_REQUEST_ID);
193 ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
194 String errorMsg = (String) execution.getVariable("WorkflowActionErrorMessage");
195 if (errorMsg == null) {
196 errorMsg = "WorkflowAction failed unexpectedly.";
198 String processKey = exceptionBuilder.getProcessKey(execution);
199 String buildworkflowException =
200 "<aetgt:WorkflowException xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\"><aetgt:ErrorMessage>"
202 + "</aetgt:ErrorMessage><aetgt:ErrorCode>7000</aetgt:ErrorCode></aetgt:WorkflowException>";
203 WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
204 callbackResponse.setStatusCode(500);
205 callbackResponse.setMessage("Fail");
206 callbackResponse.setResponse(buildworkflowException);
207 WorkflowContextHolder.getInstance().processCallback(processKey, execution.getProcessInstanceId(), requestId,
209 execution.setVariable("sentSyncResponse", true);
210 } catch (Exception ex) {
211 logger.error(" Sending Sync Error Activity Failed. {}", ex.getMessage(), ex);
215 public void updateRequestStatusToComplete(DelegateExecution execution) {
217 final String requestId = (String) execution.getVariable(G_REQUEST_ID);
218 InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
219 final String action = (String) execution.getVariable(G_ACTION);
220 final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
221 final String resourceName = (String) execution.getVariable("resourceName");
222 String statusMessage = (String) execution.getVariable("StatusMessage");
223 String macroAction = "";
224 if (statusMessage == null) {
226 macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly.";
228 macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly.";
231 macroAction = statusMessage;
233 execution.setVariable("finalStatusMessage", macroAction);
234 Timestamp endTime = new Timestamp(System.currentTimeMillis());
235 request.setEndTime(endTime);
236 request.setFlowStatus("Successfully completed all Building Blocks");
237 request.setStatusMessage(macroAction);
238 request.setProgress(Long.valueOf(100));
239 request.setRequestStatus("COMPLETE");
240 request.setLastModifiedBy("CamundaBPMN");
241 requestsDbListener.post(request, new DelegateExecutionImpl(execution));
242 requestDbclient.updateInfraActiveRequests(request);
243 } catch (Exception ex) {
244 workflowAction.buildAndThrowException(execution, "Error Updating Request Database", ex);
248 public void checkRetryStatus(DelegateExecution execution) {
249 String handlingCode = (String) execution.getVariable(HANDLINGCODE);
250 String requestId = (String) execution.getVariable(G_REQUEST_ID);
251 String retryDuration = (String) execution.getVariable("RetryDuration");
252 int retryCount = (int) execution.getVariable(RETRY_COUNT);
255 envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries));
256 } catch (Exception ex) {
257 logger.error("Could not read maxRetries from config file. Setting max to 5 retries", ex);
260 int nextCount = retryCount + 1;
261 if ("Retry".equals(handlingCode)) {
262 workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
264 InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
265 request.setRetryStatusMessage(
266 "Retry " + nextCount + "/" + envMaxRetries + " will be started in " + retryDuration);
267 requestDbclient.updateInfraActiveRequests(request);
268 } catch (Exception ex) {
269 logger.warn("Failed to update Request Db Infra Active Requests with Retry Status", ex);
271 if (retryCount < envMaxRetries) {
272 int currSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
273 execution.setVariable(G_CURRENT_SEQUENCE, currSequence - 1);
274 execution.setVariable(RETRY_COUNT, nextCount);
276 workflowAction.buildAndThrowException(execution,
277 "Exceeded maximum retries. Ending flow with status Abort");
280 execution.setVariable(RETRY_COUNT, 0);
285 * Rollback will only handle Create/Activate/Assign Macro flows. Execute layer will rollback the flow its currently
288 public void rollbackExecutionPath(DelegateExecution execution) {
289 if (!(boolean) execution.getVariable("isRollback")) {
290 List<ExecuteBuildingBlock> flowsToExecute =
291 (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
292 List<ExecuteBuildingBlock> rollbackFlows = new ArrayList();
293 int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
294 int listSize = flowsToExecute.size();
295 for (int i = listSize - 1; i >= 0; i--) {
296 if (i > currentSequence - 1) {
297 flowsToExecute.remove(i);
299 String flowName = flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName();
300 if (flowName.startsWith("Assign")) {
301 flowName = flowName.replaceFirst("Assign", "Unassign");
302 } else if (flowName.startsWith("Create")) {
303 flowName = flowName.replaceFirst("Create", "Delete");
304 } else if (flowName.startsWith("Activate")) {
305 flowName = flowName.replaceFirst("Activate", "Deactivate");
306 } else if (flowName.startsWith("Add")) {
307 flowName = flowName.replaceFirst("Add", "Delete");
308 } else if (flowName.startsWith("VNF")) {
309 if (flowName.startsWith("VNFSet")) {
310 flowName = flowName.replaceFirst("VNFSet", "VNFUnset");
311 } else if (flowName.startsWith("VNFLock")) {
312 flowName = flowName.replaceFirst("VNFLock", "VNFUnlock");
313 } else if (flowName.startsWith("VNFStop")) {
314 flowName = flowName.replaceFirst("VNFStop", "VNFStart");
315 } else if (flowName.startsWith("VNFQuiesce")) {
316 flowName = flowName.replaceFirst("VNFQuiesce", "VNFResume");
323 flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(flowName);
324 rollbackFlows.add(flowsToExecute.get(i));
328 String handlingCode = (String) execution.getVariable(HANDLINGCODE);
329 List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>();
330 rollbackFlowsFiltered.addAll(rollbackFlows);
331 if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode)) {
332 for (int i = 0; i < rollbackFlows.size(); i++) {
333 if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Unassign") && !rollbackFlows
334 .get(i).getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) {
335 rollbackFlowsFiltered.remove(rollbackFlows.get(i));
336 } else if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Delete")
337 && ROLLBACKTOCREATED.equals(handlingCode)) {
338 rollbackFlowsFiltered.remove(rollbackFlows.get(i));
343 workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
344 if (rollbackFlows.isEmpty())
345 execution.setVariable("isRollbackNeeded", false);
347 execution.setVariable("isRollbackNeeded", true);
348 execution.setVariable("flowsToExecute", rollbackFlowsFiltered);
349 execution.setVariable(HANDLINGCODE, "PreformingRollback");
350 execution.setVariable("isRollback", true);
351 execution.setVariable(G_CURRENT_SEQUENCE, 0);
352 execution.setVariable(RETRY_COUNT, 0);
354 workflowAction.buildAndThrowException(execution,
355 "Rollback has already been called. Cannot rollback a request that is currently in the rollback state.");
359 protected void updateInstanceId(DelegateExecution execution) {
361 String requestId = (String) execution.getVariable(G_REQUEST_ID);
362 String resourceId = (String) execution.getVariable("resourceId");
363 WorkflowType resourceType = (WorkflowType) execution.getVariable("resourceType");
364 InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
365 if (resourceType == WorkflowType.SERVICE) {
366 request.setServiceInstanceId(resourceId);
367 } else if (resourceType == WorkflowType.VNF) {
368 request.setVnfId(resourceId);
369 } else if (resourceType == WorkflowType.VFMODULE) {
370 request.setVfModuleId(resourceId);
371 } else if (resourceType == WorkflowType.VOLUMEGROUP) {
372 request.setVolumeGroupId(resourceId);
373 } else if (resourceType == WorkflowType.NETWORK) {
374 request.setNetworkId(resourceId);
375 } else if (resourceType == WorkflowType.CONFIGURATION) {
376 request.setConfigurationId(resourceId);
377 } else if (resourceType == WorkflowType.INSTANCE_GROUP) {
378 request.setInstanceGroupId(resourceId);
380 setInstanceName(resourceId, resourceType, request);
381 request.setLastModifiedBy("CamundaBPMN");
382 requestDbclient.updateInfraActiveRequests(request);
383 } catch (Exception ex) {
384 logger.error("Exception in updateInstanceId", ex);
385 workflowAction.buildAndThrowException(execution, "Failed to update Request db with instanceId");
389 public void postProcessingExecuteBB(DelegateExecution execution) {
390 List<ExecuteBuildingBlock> flowsToExecute =
391 (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
392 String handlingCode = (String) execution.getVariable(HANDLINGCODE);
393 final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
394 int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
395 ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1);
396 String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName();
397 if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)) {
398 postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute);
402 protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution, ExecuteBuildingBlock ebb,
403 List<ExecuteBuildingBlock> flowsToExecute) {
405 String serviceInstanceId = ebb.getWorkflowResourceIds().getServiceInstanceId();
406 String vnfId = ebb.getWorkflowResourceIds().getVnfId();
407 String vfModuleId = ebb.getResourceId();
408 ebb.getWorkflowResourceIds().setVfModuleId(vfModuleId);
409 String serviceModelUUID =
410 bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
411 String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
412 String vfModuleCustomizationUUID =
413 bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
415 workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, AAIObjectType.VNFC);
416 logger.debug("Vnfc Size: {}", vnfcs.size());
417 for (Vnfc vnfc : vnfcs) {
418 String modelCustomizationId = vnfc.getModelCustomizationId();
419 logger.debug("Processing Vnfc: {}", modelCustomizationId);
420 CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
421 vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId);
422 if (fabricConfig != null && fabricConfig.getConfigurationResource() != null
423 && fabricConfig.getConfigurationResource().getToscaNodeType() != null
424 && fabricConfig.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
425 String configurationId = getConfigurationId(vnfc);
426 ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
427 configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId);
428 configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID);
429 configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID);
430 configurationResourceKeys.setVnfcName(vnfc.getVnfcName());
431 ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb,
432 configurationId, configurationResourceKeys);
433 flowsToExecute.add(addConfigBB);
434 flowsToExecute.stream()
435 .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
436 executeBB.getBuildingBlock().getBpmnFlowName()));
437 execution.setVariable("flowsToExecute", flowsToExecute);
438 execution.setVariable(COMPLETED, false);
440 logger.debug("No cvnfcCustomization found for customizationId: {}", modelCustomizationId);
443 } catch (EntityNotFoundException e) {
444 logger.debug("Will not be running Fabric Config Building Blocks", e);
445 } catch (Exception e) {
446 String errorMessage = "Error occurred in post processing of Vf Module create";
447 execution.setVariable(HANDLINGCODE, ROLLBACKTOCREATED);
448 execution.setVariable("WorkflowActionErrorMessage", errorMessage);
449 logger.error(errorMessage, e);
453 protected String getConfigurationId(Vnfc vnfc) {
454 List<Configuration> configurations =
455 workflowAction.getRelatedResourcesInVnfc(vnfc, Configuration.class, AAIObjectType.CONFIGURATION);
456 if (!configurations.isEmpty()) {
457 Configuration configuration = configurations.get(0);
458 return configuration.getConfigurationId();
460 return UUID.randomUUID().toString();
464 protected ExecuteBuildingBlock getExecuteBBForConfig(String bbName, ExecuteBuildingBlock ebb,
465 String configurationId, ConfigurationResourceKeys configurationResourceKeys) {
466 BuildingBlock buildingBlock =
467 new BuildingBlock().setBpmnFlowName(bbName).setMsoId(UUID.randomUUID().toString());
469 WorkflowResourceIds workflowResourceIds = ebb.getWorkflowResourceIds();
470 workflowResourceIds.setConfigurationId(configurationId);
471 ExecuteBuildingBlock configBB = new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte())
472 .setApiVersion(ebb.getApiVersion()).setRequestAction(ebb.getRequestAction())
473 .setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId())
474 .setRequestDetails(ebb.getRequestDetails()).setBuildingBlock(buildingBlock)
475 .setWorkflowResourceIds(workflowResourceIds).setConfigurationResourceKeys(configurationResourceKeys);
479 protected void setInstanceName(String resourceId, WorkflowType resourceType, InfraActiveRequests request) {
480 logger.debug("Setting instanceName in infraActiveRequest");
482 if (resourceType == WorkflowType.SERVICE && request.getServiceInstanceName() == null) {
483 ServiceInstance service = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
484 if (service != null) {
485 request.setServiceInstanceName(service.getServiceInstanceName());
487 } else if (resourceType == WorkflowType.VNF && request.getVnfName() == null) {
488 GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(resourceId);
490 request.setVnfName(vnf.getVnfName());
492 } else if (resourceType == WorkflowType.VFMODULE && request.getVfModuleName() == null) {
493 VfModule vfModule = bbInputSetupUtils.getAAIVfModule(request.getVnfId(), resourceId);
494 if (vfModule != null) {
495 request.setVfModuleName(vfModule.getVfModuleName());
497 } else if (resourceType == WorkflowType.VOLUMEGROUP && request.getVolumeGroupName() == null) {
498 Optional<VolumeGroup> volumeGroup =
499 bbInputSetupUtils.getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId);
500 if (volumeGroup.isPresent()) {
501 request.setVolumeGroupName(volumeGroup.get().getVolumeGroupName());
503 } else if (resourceType == WorkflowType.NETWORK && request.getNetworkName() == null) {
504 L3Network network = bbInputSetupUtils.getAAIL3Network(resourceId);
505 if (network != null) {
506 request.setNetworkName(network.getNetworkName());
508 } else if (resourceType == WorkflowType.CONFIGURATION && request.getConfigurationName() == null) {
509 org.onap.aai.domain.yang.Configuration configuration =
510 bbInputSetupUtils.getAAIConfiguration(resourceId);
511 if (configuration != null) {
512 request.setConfigurationName(configuration.getConfigurationName());
514 } else if (resourceType == WorkflowType.INSTANCE_GROUP && request.getInstanceGroupName() == null) {
515 InstanceGroup instanceGroup = bbInputSetupUtils.getAAIInstanceGroup(resourceId);
516 if (instanceGroup != null) {
517 request.setInstanceGroupName(instanceGroup.getInstanceGroupName());
520 } catch (Exception ex) {
521 logger.error("Exception in setInstanceName", ex);