aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterDeleteTasks.java66
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidator.java220
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java217
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java232
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java922
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java71
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java47
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java5
13 files changed, 1112 insertions, 723 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterDeleteTasks.java
new file mode 100644
index 0000000000..87466bbbd4
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterDeleteTasks.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.adapter.cnf.tasks;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.adapter.cnf.CnfAdapterClient;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CnfAdapterDeleteTasks {
+ private static final Logger logger = LoggerFactory.getLogger(CnfAdapterDeleteTasks.class);
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private CnfAdapterClient cnfAdapterClient;
+
+ /**
+ * This method is used for deleting the instance with Multicloud K8s Plugin.
+ *
+ * @param execution
+ * @return
+ */
+ public void deleteInstance(BuildingBlockExecution execution) {
+ try {
+ logger.debug("Running delete instance - Helm");
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ String heatStackId = vfModule.getHeatStackId();
+ execution.setVariable("heatStackId", heatStackId);
+ cnfAdapterClient.deleteVfModule(heatStackId);
+ } catch (Exception ex) {
+ logger.error("Exception occurred", ex);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidator.java
new file mode 100644
index 0000000000..6d90070b96
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/AaiResourceIdValidator.java
@@ -0,0 +1,220 @@
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import java.util.Map;
+import java.util.Optional;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
+import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.ServiceInstances;
+import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AaiResourceIdValidator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AaiResourceIdValidator.class);
+
+ private static final String SERVICE_INSTANCE = "serviceInstance";
+ private static final String NAME_EXISTS_WITH_DIFF_VERSION_ID = "(%s) and different version id (%s)";
+ private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI =
+ "WorkflowAction was unable to verify if the instance name already exist in AAI.";
+ private static final String NAME_EXISTS_MULTIPLE =
+ "(%s) and multiple combination of model-version-id + service-type + global-customer-id";
+ private static final String NAME_EXISTS_WITH_DIFF_COMBINATION =
+ "(%s) and global-customer-id (%s), service-type (%s), model-version-id (%s)";
+ private static final String NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID =
+ "(%s), same parent and different customization id (%s)";
+ private static final String NAME_EXISTS_WITH_DIFF_PARENT = "(%s) id (%s) and different parent relationship";
+
+
+ private final BBInputSetupUtils bbInputSetupUtils;
+
+ public AaiResourceIdValidator(BBInputSetupUtils bbInputSetupUtils) {
+ this.bbInputSetupUtils = bbInputSetupUtils;
+ }
+
+ protected String validateResourceIdInAAI(String generatedResourceId, WorkflowType type, String instanceName,
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws Exception {
+ try {
+ if ("SERVICE".equalsIgnoreCase(type.toString())) {
+ return validateServiceResourceIdInAAI(generatedResourceId, instanceName, reqDetails);
+ } else if ("NETWORK".equalsIgnoreCase(type.toString())) {
+ return validateNetworkResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
+ workflowResourceIds);
+ } else if ("VNF".equalsIgnoreCase(type.toString())) {
+ return validateVnfResourceIdInAAI(generatedResourceId, instanceName, reqDetails, workflowResourceIds);
+ } else if ("VFMODULE".equalsIgnoreCase(type.toString())) {
+ return validateVfModuleResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
+ workflowResourceIds);
+ } else if ("VOLUMEGROUP".equalsIgnoreCase(type.toString())) {
+ return validateVolumeGroupResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
+ workflowResourceIds);
+ } else if ("CONFIGURATION".equalsIgnoreCase(type.toString())) {
+ return validateConfigurationResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
+ workflowResourceIds);
+ }
+ return generatedResourceId;
+ } catch (DuplicateNameException dne) {
+ throw dne;
+ } catch (Exception ex) {
+ LOGGER.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex);
+ throw new IllegalStateException(
+ WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI);
+ }
+ }
+
+ protected String validateServiceResourceIdInAAI(String generatedResourceId, String instanceName,
+ RequestDetails reqDetails) throws DuplicateNameException {
+ String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId();
+ String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType();
+ if (instanceName != null) {
+ Optional<ServiceInstance> serviceInstanceAAI =
+ bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName);
+ if (serviceInstanceAAI.isPresent()) {
+ if (serviceInstanceAAI.get().getModelVersionId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelVersionId())) {
+ return serviceInstanceAAI.get().getServiceInstanceId();
+ } else {
+ throw new DuplicateNameException(SERVICE_INSTANCE, String.format(NAME_EXISTS_WITH_DIFF_VERSION_ID,
+ instanceName, reqDetails.getModelInfo().getModelVersionId()));
+ }
+ } else {
+ ServiceInstances aaiServiceInstances =
+ bbInputSetupUtils.getAAIServiceInstancesGloballyByName(instanceName);
+ if (aaiServiceInstances != null) {
+ if (aaiServiceInstances.getServiceInstance() != null
+ && !aaiServiceInstances.getServiceInstance().isEmpty()) {
+ if (aaiServiceInstances.getServiceInstance().size() > 1) {
+ throw new DuplicateNameException(SERVICE_INSTANCE,
+ String.format(NAME_EXISTS_MULTIPLE, instanceName));
+ } else {
+ ServiceInstance si = aaiServiceInstances.getServiceInstance().stream().findFirst().get();
+ Map<String, String> keys =
+ bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId());
+
+ throw new DuplicateNameException(SERVICE_INSTANCE, String.format(
+ NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName,
+ keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId),
+ keys.get(
+ AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType),
+ si.getModelVersionId()));
+ }
+ }
+ }
+ }
+ }
+ return generatedResourceId;
+ }
+
+ protected String validateNetworkResourceIdInAAI(String generatedResourceId, String instanceName,
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds)
+ throws DuplicateNameException, MultipleObjectsFoundException {
+ Optional<L3Network> network = bbInputSetupUtils
+ .getRelatedNetworkByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
+ if (network.isPresent()) {
+ if (network.get().getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return network.get().getNetworkId();
+ } else {
+ throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
+ instanceName, network.get().getModelCustomizationId()));
+ }
+ }
+ if (bbInputSetupUtils.existsAAINetworksGloballyByName(instanceName)) {
+ throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName,
+ workflowResourceIds.getServiceInstanceId()));
+ }
+ return generatedResourceId;
+ }
+
+ protected String validateVnfResourceIdInAAI(String generatedResourceId, String instanceName,
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
+ Optional<GenericVnf> vnf = bbInputSetupUtils
+ .getRelatedVnfByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
+ if (vnf.isPresent()) {
+ if (vnf.get().getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return vnf.get().getVnfId();
+ } else {
+ throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
+ instanceName, vnf.get().getModelCustomizationId()));
+ }
+ }
+ GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName);
+ if (vnfs != null) {
+ throw new DuplicateNameException("generic-vnf",
+ String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName, vnfs.getGenericVnf().get(0).getVnfId()));
+ }
+ return generatedResourceId;
+ }
+
+ protected String validateVfModuleResourceIdInAAI(String generatedResourceId, String instanceName,
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
+ GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
+ if (vnf != null && vnf.getVfModules() != null) {
+ for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
+ if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) {
+ if (vfModule.getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return vfModule.getVfModuleId();
+ } else {
+ throw new DuplicateNameException("vfModule",
+ String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName,
+ reqDetails.getModelInfo().getModelCustomizationId()));
+ }
+ }
+ }
+ }
+ if (bbInputSetupUtils.existsAAIVfModuleGloballyByName(instanceName)) {
+ throw new DuplicateNameException("vfModule", instanceName);
+ }
+ return generatedResourceId;
+ }
+
+ protected String validateVolumeGroupResourceIdInAAI(String generatedResourceId, String instanceName,
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
+ Optional<VolumeGroup> volumeGroup =
+ bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName);
+ if (volumeGroup.isPresent()) {
+ if (volumeGroup.get().getVfModuleModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return volumeGroup.get().getVolumeGroupId();
+ } else {
+ throw new DuplicateNameException("volumeGroup", volumeGroup.get().getVolumeGroupName());
+ }
+ }
+ if (bbInputSetupUtils.existsAAIVolumeGroupGloballyByName(instanceName)) {
+ throw new DuplicateNameException("volumeGroup", instanceName);
+ }
+ return generatedResourceId;
+ }
+
+ protected String validateConfigurationResourceIdInAAI(String generatedResourceId, String instanceName,
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
+ Optional<org.onap.aai.domain.yang.Configuration> configuration =
+ bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance(
+ workflowResourceIds.getServiceInstanceId(), instanceName);
+ if (configuration.isPresent()) {
+ if (configuration.get().getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return configuration.get().getConfigurationId();
+ } else {
+ throw new DuplicateNameException("configuration", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
+ instanceName, configuration.get().getConfigurationId()));
+ }
+ }
+ if (bbInputSetupUtils.existsAAIConfigurationGloballyByName(instanceName)) {
+ throw new DuplicateNameException("configuration", instanceName);
+ }
+ return generatedResourceId;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
new file mode 100644
index 0000000000..b8699838e2
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
@@ -0,0 +1,217 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Modifications Copyright (c) 2021 Nokia
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Tech Mahindra
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
+import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONFIGURATION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.VOLUMEGROUP;
+
+@Component
+public class ExecuteBuildingBlockBuilder {
+
+ private static final Logger logger = LoggerFactory.getLogger(ExecuteBuildingBlockBuilder.class);
+
+ private static final String VNF = "Vnf";
+ private static final String PNF = "Pnf";
+ private static final String VFMODULE = "VfModule";
+ private static final String NETWORK = "Network";
+
+ protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows,
+ List<Resource> resourceList, String requestId, String apiVersion, String resourceId, String requestAction,
+ String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
+ boolean replaceVnf) {
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ for (OrchestrationFlow orchFlow : orchFlows) {
+ if (orchFlow.getFlowName().contains(SERVICE)) {
+ if (!replaceVnf) {
+ workflowResourceIds.setServiceInstanceId(resourceId);
+ }
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.SERVICE, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ } else if (orchFlow.getFlowName().contains(VNF) || (orchFlow.getFlowName().contains(CONTROLLER)
+ && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VNF, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ } else if (orchFlow.getFlowName().contains(PNF) || (orchFlow.getFlowName().contains(CONTROLLER)
+ && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.PNF, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ } else if (orchFlow.getFlowName().contains(NETWORK)
+ && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORK, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow,
+ requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
+ true, false);
+ } else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER)
+ && (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ List<Resource> vfModuleResourcesSorted;
+ if (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE)
+ || requestAction.equals("activateInstance")) {
+ vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceList.stream()
+ .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
+ } else {
+ vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream()
+ .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
+ }
+ for (Resource resource : vfModuleResourcesSorted) {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
+ requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null,
+ false, null));
+ }
+ } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) {
+ if (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
+ || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) {
+ logger.debug("Replacing workflow resource id by volume group id");
+ resourceId = workflowResourceIds.getVolumeGroupId();
+ }
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VOLUMEGROUP, orchFlow,
+ requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
+ false, false);
+ } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORKCOLLECTION, orchFlow,
+ requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
+ false, false);
+ } else if (orchFlow.getFlowName().contains(CONFIGURATION)) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.CONFIGURATION, orchFlow,
+ requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
+ false, true);
+ } else {
+ flowsToExecute
+ .add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, requestAction,
+ false, vnfType, workflowResourceIds, requestDetails, false, null, null, false, null));
+ }
+ }
+ return flowsToExecute;
+ }
+
+ protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId,
+ Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte,
+ String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
+ boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration,
+ ReplaceInstanceRelatedInformation replaceInfo) {
+
+ BuildingBlock buildingBlock =
+ new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString())
+ .setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey)
+ .setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse(""));
+ Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(buildingBlock::setBpmnAction);
+ Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(buildingBlock::setBpmnScope);
+ String oldVolumeGroupName = "";
+ if (replaceInfo != null) {
+ oldVolumeGroupName = replaceInfo.getOldVolumeGroupName();
+ }
+ if (resource != null
+ && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
+ || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) {
+ logger.debug("Setting resourceId to volume group id for volume group flow on replace");
+ resourceId = workflowResourceIds.getVolumeGroupId();
+ }
+
+ ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion)
+ .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType)
+ .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock)
+ .setRequestDetails(requestDetails).setOldVolumeGroupName(oldVolumeGroupName);
+
+ if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) {
+ ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName);
+ executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
+ }
+ return executeBuildingBlock;
+ }
+
+ protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
+ int count = 0;
+ for (Resource resource : vfModuleResources) {
+ if (resource.isBaseVfModule()) {
+ Collections.swap(vfModuleResources, 0, count);
+ break;
+ }
+ count++;
+ }
+ return vfModuleResources;
+ }
+
+ protected List<Resource> sortVfModulesByBaseLast(List<Resource> vfModuleResources) {
+ int count = 0;
+ for (Resource resource : vfModuleResources) {
+ if (resource.isBaseVfModule()) {
+ Collections.swap(vfModuleResources, vfModuleResources.size() - 1, count);
+ break;
+ }
+ count++;
+ }
+ return vfModuleResources;
+ }
+
+ private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList,
+ WorkflowType workflowType, OrchestrationFlow orchFlow, String requestId, String apiVersion,
+ String resourceId, String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds,
+ RequestDetails requestDetails, boolean isVirtualLink, boolean isConfiguration) {
+
+ resourceList.stream().filter(resource -> resource.getResourceType().equals(workflowType))
+ .forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource,
+ apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails,
+ isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration, null)));
+ }
+
+ private ConfigurationResourceKeys getConfigurationResourceKeys(Resource resource, String vnfcName) {
+ ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
+ Optional.ofNullable(vnfcName).ifPresent(configurationResourceKeys::setVnfcName);
+ configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
+ configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
+ configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
+ return configurationResourceKeys;
+ }
+
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java
new file mode 100644
index 0000000000..3556cc024c
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java
@@ -0,0 +1,232 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Tech Mahindra
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
+import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
+import org.onap.so.db.catalog.beans.CvnfcCustomization;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.serviceinstancebeans.Networks;
+import org.onap.so.serviceinstancebeans.Pnfs;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.VfModules;
+import org.onap.so.serviceinstancebeans.Vnfs;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.USER_PARAM_SERVICE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
+
+@Component
+public class UserParamsServiceTraversal {
+
+ private static final Logger logger = LoggerFactory.getLogger(UserParamsServiceTraversal.class);
+
+ private final CatalogDbClient catalogDbClient;
+ private final ExceptionBuilder exceptionBuilder;
+
+ UserParamsServiceTraversal(CatalogDbClient catalogDbClient, ExceptionBuilder exceptionBuilder) {
+ this.catalogDbClient = catalogDbClient;
+ this.exceptionBuilder = exceptionBuilder;
+ }
+
+ protected List<Resource> getResourceListFromUserParams(DelegateExecution execution,
+ List<Map<String, Object>> userParams, String serviceModelVersionId, String requestAction)
+ throws IOException {
+ List<Resource> resourceList = new ArrayList<>();
+ boolean foundVfModuleOrVG = false;
+ String vnfCustomizationUUID = "";
+ String vfModuleCustomizationUUID = "";
+ if (userParams != null) {
+ for (Map<String, Object> params : userParams) {
+ if (params.containsKey(USER_PARAM_SERVICE)) {
+ ObjectMapper obj = new ObjectMapper();
+ String input = obj.writeValueAsString(params.get(USER_PARAM_SERVICE));
+ Service validate = obj.readValue(input, Service.class);
+ resourceList.add(
+ new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
+ if (validate.getResources().getVnfs() != null) {
+ for (Vnfs vnf : validate.getResources().getVnfs()) {
+ resourceList.add(new Resource(WorkflowType.VNF,
+ vnf.getModelInfo().getModelCustomizationId(), false));
+ if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
+ vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
+ }
+ if (vnf.getVfModules() != null) {
+ for (VfModules vfModule : vnf.getVfModules()) {
+ VfModuleCustomization vfModuleCustomization =
+ catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(
+ vfModule.getModelInfo().getModelCustomizationUuid());
+ if (vfModuleCustomization != null) {
+
+ if (vfModuleCustomization.getVfModule() != null
+ && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
+ && vfModuleCustomization.getVolumeHeatEnv() != null) {
+ resourceList.add(new Resource(WorkflowType.VOLUMEGROUP,
+ vfModuleCustomization.getModelCustomizationUUID(), false));
+ foundVfModuleOrVG = true;
+ }
+
+ if ((vfModuleCustomization.getVfModule() != null)
+ && ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
+ && vfModuleCustomization.getHeatEnvironment() != null))
+ || (vfModuleCustomization.getVfModule().getModelName() != null
+ && vfModuleCustomization.getVfModule().getModelName()
+ .contains("helm"))) {
+ foundVfModuleOrVG = true;
+ Resource resource = new Resource(WorkflowType.VFMODULE,
+ vfModuleCustomization.getModelCustomizationUUID(), false);
+ resource.setBaseVfModule(
+ vfModuleCustomization.getVfModule().getIsBase() != null
+ && vfModuleCustomization.getVfModule().getIsBase());
+ resourceList.add(resource);
+ if (vfModule.getModelInfo() != null
+ && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
+ vfModuleCustomizationUUID =
+ vfModule.getModelInfo().getModelCustomizationUuid();
+ }
+ if (!vnfCustomizationUUID.isEmpty()
+ && !vfModuleCustomizationUUID.isEmpty()) {
+ List<CvnfcConfigurationCustomization> configs =
+ traverseCatalogDbForConfiguration(
+ validate.getModelInfo().getModelVersionId(),
+ vnfCustomizationUUID, vfModuleCustomizationUUID);
+ for (CvnfcConfigurationCustomization config : configs) {
+ Resource configResource = new Resource(WorkflowType.CONFIGURATION,
+ config.getConfigurationResource().getModelUUID(), false);
+ resource.setVnfCustomizationId(
+ vnf.getModelInfo().getModelCustomizationId());
+ resource.setVfModuleCustomizationId(
+ vfModule.getModelInfo().getModelCustomizationId());
+ resourceList.add(configResource);
+ }
+ }
+ }
+ if (!foundVfModuleOrVG) {
+ buildAndThrowException(execution,
+ "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
+ }
+ }
+ }
+ }
+ }
+ }
+ if (validate.getResources().getPnfs() != null) {
+ for (Pnfs pnf : validate.getResources().getPnfs()) {
+ resourceList.add(new Resource(WorkflowType.PNF,
+ pnf.getModelInfo().getModelCustomizationId(), false));
+ }
+ }
+ if (validate.getResources().getNetworks() != null) {
+ for (Networks network : validate.getResources().getNetworks()) {
+ resourceList.add(new Resource(WorkflowType.NETWORK,
+ network.getModelInfo().getModelCustomizationId(), false));
+ }
+ if (requestAction.equals(CREATE_INSTANCE)) {
+ String networkColCustId =
+ queryCatalogDbForNetworkCollection(execution, serviceModelVersionId);
+ if (networkColCustId != null) {
+ resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ return resourceList;
+ }
+
+
+ private List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID,
+ String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
+ List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
+ try {
+ List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
+ vnfCustomizationUUID, vfModuleCustomizationUUID);
+ for (CvnfcCustomization cvnfc : cvnfcCustomizations) {
+ for (CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()) {
+ if (customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
+ configurations.add(customization);
+ }
+ }
+ }
+ logger.debug("found {} fabric configuration(s)", configurations.size());
+ return configurations;
+ } catch (Exception ex) {
+ logger.error("Error in finding configurations", ex);
+ return configurations;
+ }
+ }
+
+ private String queryCatalogDbForNetworkCollection(DelegateExecution execution, String serviceModelVersionId) {
+ org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(serviceModelVersionId);
+ if (service != null) {
+ CollectionResourceCustomization networkCollection = this.findCatalogNetworkCollection(execution, service);
+ if (networkCollection != null) {
+ return networkCollection.getModelCustomizationUUID();
+ }
+ }
+ return null;
+ }
+
+ private CollectionResourceCustomization findCatalogNetworkCollection(DelegateExecution execution,
+ org.onap.so.db.catalog.beans.Service service) {
+ CollectionResourceCustomization networkCollection = null;
+ int count = 0;
+ for (CollectionResourceCustomization collectionCustom : service.getCollectionResourceCustomizations()) {
+ if (catalogDbClient.getNetworkCollectionResourceCustomizationByID(
+ collectionCustom.getModelCustomizationUUID()) != null) {
+ networkCollection = collectionCustom;
+ count++;
+ }
+ }
+ if (count == 0) {
+ return null;
+ } else if (count > 1) {
+ buildAndThrowException(execution,
+ "Found multiple Network Collections in the Service model, only one per Service is supported.");
+ }
+ return networkCollection;
+ }
+
+ private void buildAndThrowException(DelegateExecution execution, String msg) {
+ logger.error(msg);
+ execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+}
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 5d95f973bf..4be497c469 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
@@ -6,7 +6,7 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
- * Modifications Copyright (c) 2020 Nokia
+ * Modifications Copyright (c) 2021 Nokia
* ================================================================================
* Modifications Copyright (c) 2020 Tech Mahindra
* ================================================================================
@@ -26,27 +26,14 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import org.apache.commons.lang3.SerializationUtils;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.javatuples.Pair;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.GenericVnfs;
-import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.ServiceInstances;
import org.onap.aai.domain.yang.Vnfc;
import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.aai.domain.yang.VpnBinding;
@@ -62,22 +49,17 @@ import org.onap.so.bpmn.common.BBConstants;
import org.onap.so.bpmn.infrastructure.workflow.tasks.utils.WorkflowResourceIdsUtils;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
-import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
-import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
-import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIConfigurationResources;
import org.onap.so.client.orchestration.AAIEntityNotFoundException;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
-import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
-import org.onap.so.db.catalog.beans.CvnfcCustomization;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
@@ -86,68 +68,56 @@ import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.ModelType;
-import org.onap.so.serviceinstancebeans.Networks;
-import org.onap.so.serviceinstancebeans.Pnfs;
import org.onap.so.serviceinstancebeans.RelatedInstance;
import org.onap.so.serviceinstancebeans.RelatedInstanceList;
import org.onap.so.serviceinstancebeans.RequestDetails;
-import org.onap.so.serviceinstancebeans.Service;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
-import org.onap.so.serviceinstancebeans.VfModules;
-import org.onap.so.serviceinstancebeans.Vnfs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.USER_PARAM_SERVICE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
@Component
public class WorkflowAction {
- private static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
+
private static final String SERVICE_INSTANCES = "serviceInstances";
- private static final String SERVICE_INSTANCE = "serviceInstance";
private static final String VF_MODULES = "vfModules";
- private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI =
- "WorkflowAction was unable to verify if the instance name already exist in AAI.";
private static final String VNF_TYPE = "vnfType";
- private static final String SERVICE = "Service";
- private static final String VNF = "Vnf";
- private static final String PNF = "Pnf";
- private static final String VFMODULE = "VfModule";
- private static final String VOLUMEGROUP = "VolumeGroup";
- private static final String NETWORK = "Network";
- private static final String NETWORKCOLLECTION = "NetworkCollection";
private static final String CONFIGURATION = "Configuration";
- private static final String ASSIGNINSTANCE = "assignInstance";
- private static final String CREATEINSTANCE = "createInstance";
- private static final String REPLACEINSTANCE = "replaceInstance";
- private static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
- private static final String USERPARAMSERVICE = "service";
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 SERVICE_TYPE_TRANSPORT = "TRANSPORT";
private static final String SERVICE_TYPE_BONDING = "BONDING";
private static final String CLOUD_OWNER = "DEFAULT";
- private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
- private static final String NAME_EXISTS_WITH_DIFF_VERSION_ID = "(%s) and different version id (%s)";
- private static final String NAME_EXISTS_MULTIPLE =
- "(%s) and multiple combination of model-version-id + service-type + global-customer-id";
- private static final String NAME_EXISTS_WITH_DIFF_COMBINATION =
- "(%s) and global-customer-id (%s), service-type (%s), model-version-id (%s)";
- private static final String NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID =
- "(%s), same parent and different customization id (%s)";
- private static final String NAME_EXISTS_WITH_DIFF_PARENT = "(%s) id (%s) and different parent relationship";
private static final String CREATENETWORKBB = "CreateNetworkBB";
private static final String ACTIVATENETWORKBB = "ActivateNetworkBB";
private static final String VOLUMEGROUP_DELETE_PATTERN = "(Un|De)(.*)Volume(.*)";
private static final String VOLUMEGROUP_CREATE_PATTERN = "(A|C)(.*)Volume(.*)";
- private static final String CONTROLLER = "Controller";
private static final String DEFAULT_CLOUD_OWNER = "org.onap.so.cloud-owner";
private static final String HOMING = "homing";
@@ -167,6 +137,12 @@ public class WorkflowAction {
private VrfValidation vrfValidation;
@Autowired
private Environment environment;
+ @Autowired
+ private UserParamsServiceTraversal userParamsServiceTraversal;
+ @Autowired
+ private AaiResourceIdValidator aaiResourceIdValidator;
+ @Autowired
+ private ExecuteBuildingBlockBuilder executeBuildingBlockBuilder;
public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
this.bbInputSetupUtils = bbInputSetupUtils;
@@ -200,8 +176,7 @@ public class WorkflowAction {
String serviceInstanceId = getServiceInstanceId(execution, resourceId, resourceType);
fillExecution(execution, requestDetails.getRequestInfo().getSuppressRollback(), resourceId, resourceType);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
-
+ List<ExecuteBuildingBlock> flowsToExecute;
if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) {
String errorMessage = "Could not resume Macro flow. Error loading execution path.";
flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage);
@@ -218,142 +193,19 @@ public class WorkflowAction {
final String serviceType =
Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse("");
if (isALaCarte) {
- if (orchFlows == null || orchFlows.isEmpty()) {
- orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true,
- cloudOwner, serviceType);
- }
- Resource resourceKey = getResourceKey(sIRequest, resourceType);
-
- ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation();
- if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE)
- || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS))
- && resourceType.equals(WorkflowType.VFMODULE)) {
- logger.debug("Build a BB list for replacing BB modules");
- ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution,
- sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId,
- vnfType, orchFlows, apiVersion, resourceKey, replaceInfo);
- orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo);
-
- createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds,
- requestDetails, requestAction, resourceId, flowsToExecute, vnfType, orchFlows,
- apiVersion, resourceKey, replaceInfo);
- } else {
- if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
- addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId,
- workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute,
- vnfType, apiVersion, resourceKey, replaceInfo, orchFlows);
- }
- orchFlows =
- orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION))
- .collect(Collectors.toList());
-
- for (OrchestrationFlow orchFlow : orchFlows) {
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey,
- apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds,
- requestDetails, false, null, null, false, replaceInfo);
- flowsToExecute.add(ebb);
- }
- }
+ flowsToExecute = loadExecuteBuildingBlocksForAlaCarte(orchFlows, execution, requestAction,
+ resourceType, cloudOwner, serviceType, sIRequest, requestId, workflowResourceIds,
+ requestDetails, resourceId, vnfType, apiVersion);
} else {
- boolean foundRelated = false;
- boolean containsService = false;
- List<Resource> resourceList = new ArrayList<>();
- List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
- if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
- // SERVICE-MACRO-ASSIGN will always get user params with a
- // service.
- if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- containsService = isContainsService(sIRequest);
- if (containsService) {
- traverseUserParamsService(execution, resourceList, sIRequest, requestAction);
- }
- } else {
- buildAndThrowException(execution,
- "Service-Macro-Assign request details must contain user params with a service");
- }
- } else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
- // SERVICE-MACRO-CREATE will get user params with a service,
- // a service with a network, a service with a
- // networkcollection, OR an empty service.
- // If user params is just a service or null and macro
- // queries the SI and finds a VNF, macro fails.
-
- if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- containsService = isContainsService(sIRequest);
- }
- if (containsService) {
- foundRelated = traverseUserParamsService(execution, resourceList, sIRequest, requestAction);
- }
- if (!foundRelated) {
- traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds);
- }
- } else if (resourceType == WorkflowType.SERVICE
- && ("activateInstance".equalsIgnoreCase(requestAction)
- || "unassignInstance".equalsIgnoreCase(requestAction)
- || "deleteInstance".equalsIgnoreCase(requestAction)
- || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) {
- // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and
- // SERVICE-MACRO-DELETE
- // Will never get user params with service, macro will have
- // to query the SI in AAI to find related instances.
- traverseAAIService(execution, resourceList, resourceId, aaiResourceIds);
- } else if (resourceType == WorkflowType.SERVICE
- && "deactivateInstance".equalsIgnoreCase(requestAction)) {
- resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
- } else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
- || ("recreateInstance".equalsIgnoreCase(requestAction)))) {
- traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
- workflowResourceIds.getVnfId(), aaiResourceIds);
- } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) {
- customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
- workflowResourceIds.getVnfId(), aaiResourceIds);
- } else {
- buildAndThrowException(execution, "Current Macro Request is not supported");
- }
- StringBuilder foundObjects = new StringBuilder();
- for (WorkflowType type : WorkflowType.values()) {
- foundObjects.append(type).append(" - ").append(
- (int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count())
- .append(" ");
- }
- logger.info("Found {}", foundObjects);
-
- if (orchFlows == null || orchFlows.isEmpty()) {
- orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, isALaCarte,
- cloudOwner, serviceType);
- }
- boolean vnfReplace = false;
- if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
- || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) {
- vnfReplace = true;
- }
- flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceList, requestId, apiVersion,
- resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace);
- if (isNetworkCollectionInTheResourceList(resourceList)) {
- logger.info("Sorting for Vlan Tagging");
- flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
- }
- // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE
- if (resourceType == WorkflowType.SERVICE
- && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE))
- && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
- execution.setVariable(HOMING, true);
- execution.setVariable("calledHoming", false);
- }
- if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)
- || requestAction.equalsIgnoreCase(CREATEINSTANCE))) {
- generateResourceIds(flowsToExecute, resourceList, serviceInstanceId);
- } else {
- updateResourceIdsFromAAITraversal(flowsToExecute, resourceList, aaiResourceIds,
- serviceInstanceId);
- }
+ flowsToExecute = loadExecuteBuildingBlocksForMacro(sIRequest, resourceType, requestAction,
+ execution, serviceInstanceId, resourceId, workflowResourceIds, orchFlows, cloudOwner,
+ serviceType, requestId, apiVersion, vnfType, requestDetails);
}
}
// If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified,
// enable it.
- if (sIRequest.getRequestDetails().getRequestParameters() != null
- && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams = getListOfUserParams(sIRequest);
+ List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ if (sIRequest.getRequestDetails().getRequestParameters() != null && userParams != null) {
for (Map<String, Object> params : userParams) {
if (params.containsKey(HOMINGSOLUTION)) {
execution.setVariable(HOMING, !"none".equals(params.get(HOMINGSOLUTION)));
@@ -388,6 +240,151 @@ public class WorkflowAction {
}
}
+ private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForAlaCarte(List<OrchestrationFlow> orchFlows,
+ DelegateExecution execution, String requestAction, WorkflowType resourceType, String cloudOwner,
+ String serviceType, ServiceInstancesRequest sIRequest, String requestId,
+ WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, String resourceId, String vnfType,
+ String apiVersion) throws Exception {
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ if (orchFlows == null || orchFlows.isEmpty()) {
+ orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true, cloudOwner,
+ serviceType);
+ }
+ Resource resourceKey = getResourceKey(sIRequest, resourceType);
+
+ ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation();
+ if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE)
+ || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS))
+ && resourceType.equals(WorkflowType.VFMODULE)) {
+ logger.debug("Build a BB list for replacing BB modules");
+ ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution, sIRequest, requestId,
+ workflowResourceIds, requestDetails, requestAction, resourceId, vnfType, orchFlows, apiVersion,
+ resourceKey, replaceInfo);
+ orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo);
+
+ createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds, requestDetails,
+ requestAction, resourceId, flowsToExecute, vnfType, orchFlows, apiVersion, resourceKey,
+ replaceInfo);
+ } else {
+ if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATE_INSTANCE)) {
+ addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, workflowResourceIds,
+ requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey,
+ replaceInfo, orchFlows);
+ }
+ orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION))
+ .collect(Collectors.toList());
+
+ for (OrchestrationFlow orchFlow : orchFlows) {
+ ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds,
+ requestDetails, false, null, null, false, replaceInfo);
+ flowsToExecute.add(ebb);
+ }
+ }
+ return flowsToExecute;
+ }
+
+ private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForMacro(ServiceInstancesRequest sIRequest,
+ WorkflowType resourceType, String requestAction, DelegateExecution execution, String serviceInstanceId,
+ String resourceId, WorkflowResourceIds workflowResourceIds, List<OrchestrationFlow> orchFlows,
+ String cloudOwner, String serviceType, String requestId, String apiVersion, String vnfType,
+ RequestDetails requestDetails) throws IOException, VrfBondingServiceException {
+ List<ExecuteBuildingBlock> flowsToExecute;
+ boolean containsService = false;
+ List<Resource> resourceList = new ArrayList<>();
+ List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
+ List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
+ // SERVICE-MACRO-ASSIGN will always get user params with a
+ // service.
+
+ if (userParams != null) {
+ containsService = isContainsService(sIRequest);
+ if (containsService) {
+ resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, userParams,
+ serviceInstanceId, requestAction);
+ }
+ } else {
+ buildAndThrowException(execution,
+ "Service-Macro-Assign request details must contain user params with a service");
+ }
+ } else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATE_INSTANCE)) {
+ // SERVICE-MACRO-CREATE will get user params with a service,
+ // a service with a network, a service with a
+ // network collection, OR an empty service.
+ // If user params is just a service or null and macro
+ // queries the SI and finds a VNF, macro fails.
+
+ if (userParams != null) {
+ containsService = isContainsService(sIRequest);
+ }
+ if (containsService) {
+ resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, userParams,
+ serviceInstanceId, requestAction);
+ }
+ if (!foundRelated(resourceList)) {
+ traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds);
+ }
+ } else if (resourceType == WorkflowType.SERVICE && ("activateInstance".equalsIgnoreCase(requestAction)
+ || "unassignInstance".equalsIgnoreCase(requestAction)
+ || "deleteInstance".equalsIgnoreCase(requestAction)
+ || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) {
+ // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and
+ // SERVICE-MACRO-DELETE
+ // Will never get user params with service, macro will have
+ // to query the SI in AAI to find related instances.
+ traverseAAIService(execution, resourceList, resourceId, aaiResourceIds);
+ } else if (resourceType == WorkflowType.SERVICE && "deactivateInstance".equalsIgnoreCase(requestAction)) {
+ resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
+ } else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
+ || ("recreateInstance".equalsIgnoreCase(requestAction)))) {
+ traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
+ workflowResourceIds.getVnfId(), aaiResourceIds);
+ } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) {
+ customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
+ workflowResourceIds.getVnfId(), aaiResourceIds);
+ } else {
+ buildAndThrowException(execution, "Current Macro Request is not supported");
+ }
+ StringBuilder foundObjects = new StringBuilder();
+ for (WorkflowType type : WorkflowType.values()) {
+ foundObjects.append(type).append(" - ")
+ .append((int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count())
+ .append(" ");
+ }
+ logger.info("Found {}", foundObjects);
+
+ if (orchFlows == null || orchFlows.isEmpty()) {
+ orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, false, cloudOwner,
+ serviceType);
+ }
+ boolean vnfReplace = false;
+ if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
+ || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) {
+ vnfReplace = true;
+ }
+ flowsToExecute = executeBuildingBlockBuilder.buildExecuteBuildingBlockList(orchFlows, resourceList, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace);
+ if (isNetworkCollectionInTheResourceList(resourceList)) {
+ logger.info("Sorting for Vlan Tagging");
+ flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
+ }
+ // By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE
+ if (resourceType == WorkflowType.SERVICE
+ && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE))
+ && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
+ execution.setVariable(HOMING, true);
+ execution.setVariable("calledHoming", false);
+ }
+ if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)
+ || requestAction.equalsIgnoreCase(CREATE_INSTANCE))) {
+ generateResourceIds(flowsToExecute, resourceList, serviceInstanceId);
+ } else {
+ updateResourceIdsFromAAITraversal(flowsToExecute, resourceList, aaiResourceIds, serviceInstanceId);
+ }
+ return flowsToExecute;
+ }
+
private void setExecutionVariables(DelegateExecution execution, List<ExecuteBuildingBlock> flowsToExecute,
List<String> flowNames) {
execution.setVariable("flowNames", flowNames);
@@ -400,14 +397,12 @@ public class WorkflowAction {
private boolean isContainsService(ServiceInstancesRequest sIRequest) {
boolean containsService;
- List<Map<String, Object>> userParams = getListOfUserParams(sIRequest);
- containsService = userParams.stream().anyMatch(param -> param.containsKey(USERPARAMSERVICE));
+ List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ containsService = userParams.stream().anyMatch(param -> param.containsKey(USER_PARAM_SERVICE));
return containsService;
}
- private List<Map<String, Object>> getListOfUserParams(ServiceInstancesRequest sIRequest) {
- return sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- }
+
private List<ExecuteBuildingBlock> loadExecuteBuildingBlocks(DelegateExecution execution, String requestId,
String errorMessage) {
@@ -446,9 +441,9 @@ public class WorkflowAction {
requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey,
replaceInfo, configOrchFlows);
} else {
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion,
- resourceId, requestAction, true, vnfType, workflowResourceIds, requestDetails, false, null,
- null, false, replaceInfo);
+ ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds,
+ requestDetails, false, null, null, false, replaceInfo);
flowsToExecute.add(ebb);
}
}
@@ -596,35 +591,50 @@ public class WorkflowAction {
}
workflowIdsCopy.setConfigurationId(configuration.getConfigurationId());
for (OrchestrationFlow orchFlow : result) {
- if (!isReplace) {
- dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
- dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
- } else {
- if (orchFlow.getFlowName().contains("Delete")) {
+ if (!isReplace || (isReplace && (orchFlow.getFlowName().contains("Delete")))) {
+ if (!isReplace) {
dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
} else {
- dataObj.getResourceKey().setVfModuleCustomizationId(replaceVfModuleCustomizationUUID);
- dataObj.getResourceKey().setVnfCustomizationId(replaceVnfModuleCustomizationUUID);
+ if (orchFlow.getFlowName().contains("Delete")) {
+ dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
+ dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
+ } else {
+ dataObj.getResourceKey().setVfModuleCustomizationId(replaceVfModuleCustomizationUUID);
+ dataObj.getResourceKey().setVnfCustomizationId(replaceVnfModuleCustomizationUUID);
+ }
}
+ dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
+ String vnfcName = vnfc.getVnfcName();
+ if (vnfcName == null || vnfcName.isEmpty()) {
+ buildAndThrowException(dataObj.getExecution(), "Exception in create execution list "
+ + ": VnfcName does not exist or is null while there is a configuration for the vfModule",
+ new Exception("Vnfc and Configuration do not match"));
+ }
+ ExecuteBuildingBlock ebb =
+ executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(),
+ dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(),
+ dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(),
+ workflowIdsCopy, dataObj.getRequestDetails(), false, null, vnfcName, true, null);
+ flowsToExecuteConfigs.add(ebb);
}
- dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
- String vnfcName = vnfc.getVnfcName();
- if (vnfcName == null || vnfcName.isEmpty()) {
- buildAndThrowException(dataObj.getExecution(), "Exception in create execution list "
- + ": VnfcName does not exist or is null while there is a configuration for the vfModule",
- new Exception("Vnfc and Configuration do not match"));
- }
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(),
- dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(),
- dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), workflowIdsCopy,
- dataObj.getRequestDetails(), false, null, vnfcName, true, null);
- flowsToExecuteConfigs.add(ebb);
}
}
return flowsToExecuteConfigs;
}
+ protected void buildAndThrowException(DelegateExecution execution, String msg) {
+ logger.error(msg);
+ execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+
+ protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
+ logger.error(msg, ex);
+ execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg + ex.getMessage());
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg + ex.getMessage());
+ }
+
protected List<OrchestrationFlow> getVfModuleReplaceBuildingBlocks(ConfigBuildingBlocksDataObject dataObj)
throws Exception {
@@ -687,29 +697,7 @@ public class WorkflowAction {
return orchFlows;
}
- protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
- int count = 0;
- for (Resource resource : vfModuleResources) {
- if (resource.isBaseVfModule()) {
- Collections.swap(vfModuleResources, 0, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
- protected List<Resource> sortVfModulesByBaseLast(List<Resource> vfModuleResources) {
- int count = 0;
- for (Resource resource : vfModuleResources) {
- if (resource.isBaseVfModule()) {
- Collections.swap(vfModuleResources, vfModuleResources.size() - 1, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
private void updateResourceIdsFromAAITraversal(List<ExecuteBuildingBlock> flowsToExecute,
List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds, String serviceInstanceId) {
@@ -1214,150 +1202,6 @@ public class WorkflowAction {
}
}
- protected boolean traverseUserParamsService(DelegateExecution execution, List<Resource> resourceList,
- ServiceInstancesRequest sIRequest, String requestAction) throws IOException {
- boolean foundRelated = false;
- boolean foundVfModuleOrVG = false;
- String vnfCustomizationUUID = "";
- String vfModuleCustomizationUUID = "";
- if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams = getListOfUserParams(sIRequest);
- for (Map<String, Object> params : userParams) {
- if (params.containsKey(USERPARAMSERVICE)) {
- ObjectMapper obj = new ObjectMapper();
- String input = obj.writeValueAsString(params.get(USERPARAMSERVICE));
- Service validate = obj.readValue(input, Service.class);
- resourceList.add(
- new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
- if (validate.getResources().getVnfs() != null) {
- for (Vnfs vnf : validate.getResources().getVnfs()) {
- resourceList.add(new Resource(WorkflowType.VNF,
- vnf.getModelInfo().getModelCustomizationId(), false));
- foundRelated = true;
- if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
- vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
- }
- if (vnf.getVfModules() != null) {
- for (VfModules vfModule : vnf.getVfModules()) {
- VfModuleCustomization vfModuleCustomization =
- catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(
- vfModule.getModelInfo().getModelCustomizationUuid());
- if (vfModuleCustomization != null) {
-
- if (vfModuleCustomization.getVfModule() != null
- && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
- && vfModuleCustomization.getVolumeHeatEnv() != null) {
- resourceList.add(new Resource(WorkflowType.VOLUMEGROUP,
- vfModuleCustomization.getModelCustomizationUUID(), false));
- foundVfModuleOrVG = true;
- }
-
- if ((vfModuleCustomization.getVfModule() != null)
- && ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
- && vfModuleCustomization.getHeatEnvironment() != null))
- || (vfModuleCustomization.getVfModule().getModelName() != null
- && vfModuleCustomization.getVfModule().getModelName()
- .contains("helm"))) {
- foundVfModuleOrVG = true;
- Resource resource = new Resource(WorkflowType.VFMODULE,
- vfModuleCustomization.getModelCustomizationUUID(), false);
- resource.setBaseVfModule(
- vfModuleCustomization.getVfModule().getIsBase() != null
- && vfModuleCustomization.getVfModule().getIsBase());
- resourceList.add(resource);
- if (vfModule.getModelInfo() != null
- && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
- vfModuleCustomizationUUID =
- vfModule.getModelInfo().getModelCustomizationUuid();
- }
- if (!vnfCustomizationUUID.isEmpty()
- && !vfModuleCustomizationUUID.isEmpty()) {
- List<CvnfcConfigurationCustomization> configs =
- traverseCatalogDbForConfiguration(
- validate.getModelInfo().getModelVersionId(),
- vnfCustomizationUUID, vfModuleCustomizationUUID);
- for (CvnfcConfigurationCustomization config : configs) {
- Resource configResource = new Resource(WorkflowType.CONFIGURATION,
- config.getConfigurationResource().getModelUUID(), false);
- resource.setVnfCustomizationId(
- vnf.getModelInfo().getModelCustomizationId());
- resource.setVfModuleCustomizationId(
- vfModule.getModelInfo().getModelCustomizationId());
- resourceList.add(configResource);
- }
- }
- }
- if (!foundVfModuleOrVG) {
- buildAndThrowException(execution,
- "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
- }
- }
- }
- }
- }
- }
- if (validate.getResources().getPnfs() != null) {
- for (Pnfs pnf : validate.getResources().getPnfs()) {
- resourceList.add(new Resource(WorkflowType.PNF,
- pnf.getModelInfo().getModelCustomizationId(), false));
- foundRelated = true;
- }
- }
- if (validate.getResources().getNetworks() != null) {
- for (Networks network : validate.getResources().getNetworks()) {
- resourceList.add(new Resource(WorkflowType.NETWORK,
- network.getModelInfo().getModelCustomizationId(), false));
- foundRelated = true;
- }
- if (requestAction.equals(CREATEINSTANCE)) {
- String networkColCustId = queryCatalogDBforNetworkCollection(execution, sIRequest);
- if (networkColCustId != null) {
- resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
- foundRelated = true;
- }
- }
- }
- break;
- }
- }
- }
- return foundRelated;
- }
-
- protected List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID,
- String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
- List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
- try {
- List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
- vnfCustomizationUUID, vfModuleCustomizationUUID);
- for (CvnfcCustomization cvnfc : cvnfcCustomizations) {
- for (CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()) {
- if (customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
- configurations.add(customization);
- }
- }
- }
- logger.debug("found {} fabric configuration(s)", configurations.size());
- return configurations;
- } catch (Exception ex) {
- logger.error("Error in finding configurations", ex);
- return configurations;
- }
- }
-
- protected String queryCatalogDBforNetworkCollection(DelegateExecution execution,
- ServiceInstancesRequest sIRequest) {
- org.onap.so.db.catalog.beans.Service service =
- catalogDbClient.getServiceByID(sIRequest.getRequestDetails().getModelInfo().getModelVersionId());
- if (service != null) {
- CollectionResourceCustomization networkCollection = this.findCatalogNetworkCollection(execution, service);
- if (networkCollection != null) {
- return networkCollection.getModelCustomizationUUID();
- }
- }
- return null;
- }
-
protected WorkflowResourceIds populateResourceIdsFromApiHandler(DelegateExecution execution) {
return WorkflowResourceIdsUtils.getWorkflowResourceIdsFromExecution(execution);
}
@@ -1397,36 +1241,6 @@ public class WorkflowAction {
}
}
- protected String validateResourceIdInAAI(String generatedResourceId, WorkflowType type, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws Exception {
- try {
- if ("SERVICE".equalsIgnoreCase(type.toString())) {
- return validateServiceResourceIdInAAI(generatedResourceId, instanceName, reqDetails);
- } else if ("NETWORK".equalsIgnoreCase(type.toString())) {
- return validateNetworkResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
- workflowResourceIds);
- } else if ("VNF".equalsIgnoreCase(type.toString())) {
- return validateVnfResourceIdInAAI(generatedResourceId, instanceName, reqDetails, workflowResourceIds);
- } else if ("VFMODULE".equalsIgnoreCase(type.toString())) {
- return validateVfModuleResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
- workflowResourceIds);
- } else if ("VOLUMEGROUP".equalsIgnoreCase(type.toString())) {
- return validateVolumeGroupResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
- workflowResourceIds);
- } else if ("CONFIGURATION".equalsIgnoreCase(type.toString())) {
- return validateConfigurationResourceIdInAAI(generatedResourceId, instanceName, reqDetails,
- workflowResourceIds);
- }
- return generatedResourceId;
- } catch (DuplicateNameException dne) {
- throw dne;
- } catch (Exception ex) {
- logger.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex);
- throw new IllegalStateException(
- WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI);
- }
- }
-
protected String convertTypeFromPlural(String type) {
if (!type.matches(SUPPORTEDTYPES)) {
return type;
@@ -1442,7 +1256,7 @@ public class WorkflowAction {
protected List<ExecuteBuildingBlock> sortExecutionPathByObjectForVlanTagging(List<ExecuteBuildingBlock> orchFlows,
String requestAction) {
List<ExecuteBuildingBlock> sortedOrchFlows = new ArrayList<>();
- if (requestAction.equals(CREATEINSTANCE)) {
+ if (requestAction.equals(CREATE_INSTANCE)) {
for (ExecuteBuildingBlock ebb : orchFlows) {
if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignNetworkBB")) {
String key = ebb.getBuildingBlock().getKey();
@@ -1510,125 +1324,6 @@ public class WorkflowAction {
return sortedOrchFlows;
}
- private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList,
- WorkflowType workflowType, OrchestrationFlow orchFlow, String requestId, String apiVersion,
- String resourceId, String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds,
- RequestDetails requestDetails, boolean isVirtualLink, boolean isConfiguration) {
-
- resourceList.stream().filter(resource -> resource.getResourceType().equals(workflowType))
- .forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource,
- apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails,
- isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration, null)));
- }
-
- protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows,
- List<Resource> resourceList, String requestId, String apiVersion, String resourceId, String requestAction,
- String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
- boolean replaceVnf) {
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
- for (OrchestrationFlow orchFlow : orchFlows) {
- if (orchFlow.getFlowName().contains(SERVICE)) {
- if (!replaceVnf) {
- workflowResourceIds.setServiceInstanceId(resourceId);
- }
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.SERVICE, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- } else if (orchFlow.getFlowName().contains(VNF) || (orchFlow.getFlowName().contains(CONTROLLER)
- && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VNF, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- } else if (orchFlow.getFlowName().contains(PNF) || (orchFlow.getFlowName().contains(CONTROLLER)
- && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.PNF, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- } else if (orchFlow.getFlowName().contains(NETWORK)
- && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORK, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- true, false);
- } else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER)
- && (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- List<Resource> vfModuleResourcesSorted;
- if (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)
- || requestAction.equals("activateInstance")) {
- vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceList.stream()
- .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
- } else {
- vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream()
- .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
- }
- for (Resource resource : vfModuleResourcesSorted) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
- requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null,
- false, null));
- }
- } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) {
- if (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
- || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) {
- logger.debug("Replacing workflow resource id by volume group id");
- resourceId = workflowResourceIds.getVolumeGroupId();
- }
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VOLUMEGROUP, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- false, false);
- } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORKCOLLECTION, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- false, false);
- } else if (orchFlow.getFlowName().contains(CONFIGURATION)) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.CONFIGURATION, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- false, true);
- } else {
- flowsToExecute
- .add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, requestAction,
- false, vnfType, workflowResourceIds, requestDetails, false, null, null, false, null));
- }
- }
- return flowsToExecute;
- }
-
- protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId,
- Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte,
- String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
- boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration,
- ReplaceInstanceRelatedInformation replaceInfo) {
-
- BuildingBlock buildingBlock =
- new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString())
- .setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey)
- .setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse(""));
- Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(buildingBlock::setBpmnAction);
- Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(buildingBlock::setBpmnScope);
- String oldVolumeGroupName = "";
- if (replaceInfo != null) {
- oldVolumeGroupName = replaceInfo.getOldVolumeGroupName();
- }
- if (resource != null
- && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
- || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) {
- logger.debug("Setting resourceId to volume group id for volume group flow on replace");
- resourceId = workflowResourceIds.getVolumeGroupId();
- }
-
- ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion)
- .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType)
- .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock)
- .setRequestDetails(requestDetails).setOldVolumeGroupName(oldVolumeGroupName);
-
- if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) {
- ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName);
- executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
- }
- return executeBuildingBlock;
- }
-
private ConfigurationResourceKeys getConfigurationResourceKeys(Resource resource, String vnfcName) {
ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
Optional.ofNullable(vnfcName).ifPresent(configurationResourceKeys::setVnfcName);
@@ -1686,18 +1381,6 @@ public class WorkflowAction {
return listToExecute;
}
- protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
- logger.error(msg, ex);
- execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg + ex.getMessage());
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg + ex.getMessage());
- }
-
- protected void buildAndThrowException(DelegateExecution execution, String msg) {
- logger.error(msg);
- execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
- }
-
public void handleRuntimeException(DelegateExecution execution) {
StringBuilder wfeExpMsg = new StringBuilder("Runtime error ");
String runtimeErrorMessage;
@@ -1724,155 +1407,20 @@ public class WorkflowAction {
protected boolean isRequestMacroServiceResume(boolean aLaCarte, WorkflowType resourceType, String requestAction,
String serviceInstanceId) {
return (!aLaCarte && resourceType == WorkflowType.SERVICE
- && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE) || requestAction.equalsIgnoreCase(CREATEINSTANCE))
+ && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE) || requestAction.equalsIgnoreCase(CREATE_INSTANCE))
&& (serviceInstanceId != null && serviceInstanceId.trim().length() > 1)
&& (bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId) != null));
}
- protected String validateServiceResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails) throws DuplicateNameException {
- String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId();
- String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType();
- if (instanceName != null) {
- Optional<ServiceInstance> serviceInstanceAAI =
- bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName);
- if (serviceInstanceAAI.isPresent()) {
- if (serviceInstanceAAI.get().getModelVersionId()
- .equalsIgnoreCase(reqDetails.getModelInfo().getModelVersionId())) {
- return serviceInstanceAAI.get().getServiceInstanceId();
- } else {
- throw new DuplicateNameException(SERVICE_INSTANCE, String.format(NAME_EXISTS_WITH_DIFF_VERSION_ID,
- instanceName, reqDetails.getModelInfo().getModelVersionId()));
- }
- } else {
- ServiceInstances aaiServiceInstances =
- bbInputSetupUtils.getAAIServiceInstancesGloballyByName(instanceName);
- if (aaiServiceInstances != null) {
- if (aaiServiceInstances.getServiceInstance() != null
- && !aaiServiceInstances.getServiceInstance().isEmpty()) {
- if (aaiServiceInstances.getServiceInstance().size() > 1) {
- throw new DuplicateNameException(SERVICE_INSTANCE,
- String.format(NAME_EXISTS_MULTIPLE, instanceName));
- } else {
- ServiceInstance si = aaiServiceInstances.getServiceInstance().stream().findFirst().get();
- Map<String, String> keys =
- bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId());
-
- throw new DuplicateNameException(SERVICE_INSTANCE, String.format(
- NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName,
- keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId),
- keys.get(
- AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType),
- si.getModelVersionId()));
- }
- }
- }
- }
- }
- return generatedResourceId;
- }
-
- protected String validateNetworkResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds)
- throws DuplicateNameException, MultipleObjectsFoundException {
- Optional<L3Network> network = bbInputSetupUtils
- .getRelatedNetworkByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
- if (network.isPresent()) {
- if (network.get().getModelCustomizationId()
- .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
- return network.get().getNetworkId();
- } else {
- throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
- instanceName, network.get().getModelCustomizationId()));
- }
- }
- if (bbInputSetupUtils.existsAAINetworksGloballyByName(instanceName)) {
- throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName,
- workflowResourceIds.getServiceInstanceId()));
- }
- return generatedResourceId;
- }
-
- protected String validateVnfResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
- Optional<GenericVnf> vnf = bbInputSetupUtils
- .getRelatedVnfByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
- if (vnf.isPresent()) {
- if (vnf.get().getModelCustomizationId()
- .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
- return vnf.get().getVnfId();
- } else {
- throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
- instanceName, vnf.get().getModelCustomizationId()));
- }
- }
- GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName);
- if (vnfs != null) {
- throw new DuplicateNameException("generic-vnf",
- String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName, vnfs.getGenericVnf().get(0).getVnfId()));
- }
- return generatedResourceId;
- }
-
- protected String validateVfModuleResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
- GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
- if (vnf != null && vnf.getVfModules() != null) {
- for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
- if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) {
- if (vfModule.getModelCustomizationId()
- .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
- return vfModule.getVfModuleId();
- } else {
- throw new DuplicateNameException("vfModule",
- String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName,
- reqDetails.getModelInfo().getModelCustomizationId()));
- }
- }
- }
- }
- if (bbInputSetupUtils.existsAAIVfModuleGloballyByName(instanceName)) {
- throw new DuplicateNameException("vfModule", instanceName);
- }
- return generatedResourceId;
- }
-
- protected String validateVolumeGroupResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
- Optional<VolumeGroup> volumeGroup =
- bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName);
- if (volumeGroup.isPresent()) {
- if (volumeGroup.get().getVfModuleModelCustomizationId()
- .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
- return volumeGroup.get().getVolumeGroupId();
- } else {
- throw new DuplicateNameException("volumeGroup", volumeGroup.get().getVolumeGroupName());
- }
- }
- if (bbInputSetupUtils.existsAAIVolumeGroupGloballyByName(instanceName)) {
- throw new DuplicateNameException("volumeGroup", instanceName);
- }
- return generatedResourceId;
+ protected boolean foundRelated(List<Resource> resourceList) {
+ return (containsWorkflowType(resourceList, WorkflowType.VNF)
+ || containsWorkflowType(resourceList, WorkflowType.PNF)
+ || containsWorkflowType(resourceList, WorkflowType.NETWORK)
+ || containsWorkflowType(resourceList, WorkflowType.NETWORKCOLLECTION));
}
- protected String validateConfigurationResourceIdInAAI(String generatedResourceId, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
- Optional<org.onap.aai.domain.yang.Configuration> configuration =
- bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance(
- workflowResourceIds.getServiceInstanceId(), instanceName);
- if (configuration.isPresent()) {
- if (configuration.get().getModelCustomizationId()
- .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
- return configuration.get().getConfigurationId();
- } else {
- throw new DuplicateNameException("configuration", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID,
- instanceName, configuration.get().getConfigurationId()));
- }
- }
- if (bbInputSetupUtils.existsAAIConfigurationGloballyByName(instanceName)) {
- throw new DuplicateNameException("configuration", instanceName);
- }
- return generatedResourceId;
+ protected boolean containsWorkflowType(List<Resource> resourceList, WorkflowType workflowType) {
+ return resourceList.stream().anyMatch(resource -> resource.getResourceType().equals(workflowType));
}
private void fillExecutionDefault(DelegateExecution execution) {
@@ -1904,7 +1452,7 @@ public class WorkflowAction {
WorkflowResourceIds workflowResourceIds) throws Exception {
if (resource.isGenerated() && requestAction.equalsIgnoreCase("createInstance")
&& requestDetails.getRequestInfo().getInstanceName() != null) {
- return validateResourceIdInAAI(resource.getResourceId(), resource.getResourceType(),
+ return aaiResourceIdValidator.validateResourceIdInAAI(resource.getResourceId(), resource.getResourceType(),
requestDetails.getRequestInfo().getInstanceName(), requestDetails, workflowResourceIds);
} else {
return resource.getResourceId();
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 217b3a848e..b756772188 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
@@ -52,6 +52,9 @@ import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
import org.onap.so.serviceinstancebeans.RequestReferences;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
import org.slf4j.Logger;
@@ -78,6 +81,7 @@ public class WorkflowActionBBTasks {
private static final String ROLLBACKTOCREATEDNOCONFIGURATION = "RollbackToCreatedNoConfiguration";
private static final String REPLACEINSTANCE = "replaceInstance";
private static final String VFMODULE = "VfModule";
+ private static final String CONFIGURATION_PATTERN = "(Ad|De)(.*)FabricConfiguration(.*)";
protected String maxRetries = "mso.rainyDay.maxRetries";
private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class);
@@ -99,22 +103,26 @@ public class WorkflowActionBBTasks {
private RequestsDbListenerRunner requestsDbListener;
public void selectBB(DelegateExecution execution) {
- List<ExecuteBuildingBlock> flowsToExecute =
- (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- execution.setVariable("MacroRollback", false);
try {
- flowManipulatorListenerRunner.modifyFlows(flowsToExecute, new DelegateExecutionImpl(execution));
- } catch (NullPointerException ex) {
- workflowAction.buildAndThrowException(execution, "Error in FlowManipulator Modify Flows", ex);
- }
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
+ List<ExecuteBuildingBlock> flowsToExecute =
+ (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ execution.setVariable("MacroRollback", false);
+ try {
+ flowManipulatorListenerRunner.modifyFlows(flowsToExecute, new DelegateExecutionImpl(execution));
+ } catch (NullPointerException ex) {
+ workflowAction.buildAndThrowException(execution, "Error in FlowManipulator Modify Flows", ex);
+ }
+ int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
- ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence);
+ ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence);
- execution.setVariable("buildingBlock", ebb);
- currentSequence++;
- execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size());
- execution.setVariable(G_CURRENT_SEQUENCE, currentSequence);
+ execution.setVariable("buildingBlock", ebb);
+ currentSequence++;
+ execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size());
+ execution.setVariable(G_CURRENT_SEQUENCE, currentSequence);
+ } catch (Exception e) {
+ workflowAction.buildAndThrowException(execution, "Internal Error occured during selectBB", e);
+ }
}
public void updateFlowStatistics(DelegateExecution execution) {
@@ -417,12 +425,9 @@ public class WorkflowActionBBTasks {
String handlingCode = (String) execution.getVariable(HANDLINGCODE);
final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
- String requestAction = (String) execution.getVariable(G_ACTION);
ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1);
String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName();
- if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)
- && !(requestAction.equalsIgnoreCase("replaceInstance")
- || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments"))) {
+ if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)) {
postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute);
}
}
@@ -430,15 +435,32 @@ public class WorkflowActionBBTasks {
protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution, ExecuteBuildingBlock ebb,
List<ExecuteBuildingBlock> flowsToExecute) {
try {
+ String requestAction = (String) execution.getVariable(G_ACTION);
String serviceInstanceId = ebb.getWorkflowResourceIds().getServiceInstanceId();
String vnfId = ebb.getWorkflowResourceIds().getVnfId();
String vfModuleId = ebb.getResourceId();
ebb.getWorkflowResourceIds().setVfModuleId(vfModuleId);
- String serviceModelUUID =
- bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
- String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
- String vfModuleCustomizationUUID =
- bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
+ String serviceModelUUID = "";
+ String vnfCustomizationUUID = "";
+ String vfModuleCustomizationUUID = "";
+ if (requestAction.equalsIgnoreCase("replaceInstance")
+ || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) {
+ for (RelatedInstanceList relatedInstList : ebb.getRequestDetails().getRelatedInstanceList()) {
+ RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
+ if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
+ vnfCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
+ }
+ if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
+ serviceModelUUID = relatedInstance.getModelInfo().getModelVersionId();
+ }
+ }
+ vfModuleCustomizationUUID = ebb.getRequestDetails().getModelInfo().getModelCustomizationId();
+ } else {
+ serviceModelUUID = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
+ vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
+ vfModuleCustomizationUUID =
+ bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
+ }
List<Vnfc> vnfcs = workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, Types.VNFC);
logger.debug("Vnfc Size: {}", vnfcs.size());
for (Vnfc vnfc : vnfcs) {
@@ -458,8 +480,9 @@ public class WorkflowActionBBTasks {
ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb,
configurationId, configurationResourceKeys);
flowsToExecute.add(addConfigBB);
- flowsToExecute.forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
- executeBB.getBuildingBlock().getBpmnFlowName()));
+ flowsToExecute.stream()
+ .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
+ executeBB.getBuildingBlock().getBpmnFlowName()));
execution.setVariable("flowsToExecute", flowsToExecute);
execution.setVariable(COMPLETED, false);
} else {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
new file mode 100644
index 0000000000..5e16097304
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Tech Mahindra
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+public final class WorkflowActionConstants {
+
+ private WorkflowActionConstants() {
+ throw new IllegalStateException("Utility class");
+ }
+
+ static final String USER_PARAM_SERVICE = "service";
+ static final String CREATE_INSTANCE = "createInstance";
+ static final String FABRIC_CONFIGURATION = "FabricConfiguration";
+ static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
+ static final String SERVICE = "Service";
+ static final String CONTROLLER = "Controller";
+ static final String NETWORKCOLLECTION = "NetworkCollection";
+ static final String CONFIGURATION = "Configuration";
+ static final String ASSIGNINSTANCE = "assignInstance";
+ static final String REPLACEINSTANCE = "replaceInstance";
+ static final String VOLUMEGROUP = "VolumeGroup";
+ static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
index 2119ced951..564ee91fb2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
@@ -84,7 +84,7 @@ public class SkipCDSBuildingBlockListener implements FlowManipulator {
VnfResourceCustomization vrc = catalogDbClient.findVnfResourceCustomizationInList(customizationUUID,
vnfResourceCustomizations);
if (null != vrc) {
- boolean skipConfigVNF = vrc.isSkipPostInstConf();
+ boolean skipConfigVNF = vrc.isSkipPostInstConf().booleanValue();
currentSequenceSkipCheck(execution, skipConfigVNF);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java
index 6589ae77f5..83f61e3a4f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java
@@ -34,7 +34,7 @@ public class SkipConfigVnfListener implements FlowManipulator {
if (vnfResourceCustomizations != null && !vnfResourceCustomizations.isEmpty()) {
VnfResourceCustomization vrc =
catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations);
- boolean skipConfigVNF = vrc.isSkipPostInstConf();
+ boolean skipConfigVNF = vrc.isSkipPostInstConf().booleanValue();
if (skipConfigVNF) {
execution.setVariable(BBConstants.G_CURRENT_SEQUENCE,
((int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE)) + 1);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java
index b74aa9056d..da36a6f040 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java
@@ -54,14 +54,14 @@ public class CnfAdapterClient {
@Autowired
private Environment env;
- private static final String INSTANCE_CREATE_PATH = "/api/multicloud-k8s/v1/v1/instance";
+ private static final String INSTANCE_CREATE_PATH = "/api/cnf-adapter/v1/instance";
@Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000))
public InstanceResponse createVfModule(InstanceRequest request) throws CnfAdapterClientException {
try {
// String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well
// for configuration
- String uri = "https://localhost:32780"; // TODO: What is the correct uri?
+ String uri = "http://so-cnf-adapter:8090";
String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString();
HttpEntity<?> entity = getHttpEntity(request);
ResponseEntity<InstanceResponse> result =
@@ -76,12 +76,31 @@ public class CnfAdapterClient {
}
}
+
+ @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000))
+ public void deleteVfModule(String heatStackId) throws CnfAdapterClientException {
+ try {
+ // String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well
+ // for configuration
+ String uri = "http://so-cnf-adapter:8090";
+ String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH + "/" + heatStackId).build().toString();
+ HttpEntity<?> entity = new HttpEntity<>(getHttpHeaders());
+ restTemplate.exchange(endpoint, HttpMethod.DELETE, entity, String.class);
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling CNF Adapter, e");
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ }
+ }
+
@Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000))
public InstanceResponse healthcheck() throws CnfAdapterClientException {
try {
// String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well
// for configuration
- String uri = "https://localhost:32780"; // TODO: What is the correct uri?
+ String uri = "http://so-cnf-adapter:8090";
String endpoint = UriBuilder.fromUri(uri).path("/api/cnf-adapter/v1/healthcheck").build().toString();
HttpEntity<?> entity = new HttpEntity<>(getHttpHeaders());
ResponseEntity<InstanceResponse> result =
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java
index e38bcc2664..13ccb4eb92 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java
@@ -7,15 +7,21 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({"id", "request", "namespace", "resources"})
+@JsonPropertyOrder({"id", "request", "namespace", "release-name", "resources"})
public class InstanceResponse {
@JsonProperty("id")
private String id;
+
@JsonProperty("request")
private InstanceRequest request;
+
@JsonProperty("namespace")
private String namespace;
+
+ @JsonProperty("release-name")
+ private String releaseName;
+
@JsonProperty("resources")
private List<Resource> resources = null;
@@ -59,4 +65,14 @@ public class InstanceResponse {
this.resources = resources;
}
+ @JsonProperty("release-name")
+ public String getReleaseName() {
+ return releaseName;
+ }
+
+ @JsonProperty("release-name")
+ public void setReleaseName(String releaseName) {
+ this.releaseName = releaseName;
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java
index 6278d48e03..7291b713ca 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java
@@ -21,18 +21,16 @@
package org.onap.so.client.adapter.vnf.mapper;
import java.io.Serializable;
+import com.fasterxml.jackson.annotation.JsonProperty;
public class AttributeNameValue implements Serializable {
private static final long serialVersionUID = -5215028275587848311L;
+ @JsonProperty("attribute_name")
private String attributeName;
+ @JsonProperty("attribute_value")
private transient Object attributeValue;
- public AttributeNameValue(String attributeName, Object attributeValue) {
- this.attributeName = attributeName;
- this.attributeValue = attributeValue;
- }
-
public String getAttributeName() {
return attributeName;
}
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 59da22f8e1..7c686bd165 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
@@ -235,7 +235,10 @@ public class VnfAdapterVfModuleObjectMapper {
logger.error("No value tag found for attribute: {}", attributeName);
throw new MissingValueTagException("No value tag found for " + attributeName);
}
- directives.append(new AttributeNameValue(attributeName, attributeValue.toString()));
+ String nameValue = new StringBuilder().append("{\"attribute_name\": \"").append(attributeName)
+ .append("\", \"attribute_value\": \"").append(attributeValue.toString()).append("\"}")
+ .toString();
+ directives.append(nameValue);
if (i < (srcMap.size() - 1 + noOfDirectivesSize))
directives.append(", ");
i++;