aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorSagarS <sagar.shetty@est.tech>2022-05-11 14:16:29 +0100
committerSagarS <sagar.shetty@est.tech>2022-05-12 10:00:56 +0100
commitac1dbd50fb13a05f17c417c374fbdddfee4dfa4e (patch)
treecc0a41a894b4f8718779768589be683cd6004b8d /bpmn/so-bpmn-tasks
parent131fd74f717f76bc23af1ef935f6e96654f703d6 (diff)
[SO] Implementing CNFM API endpoint
Change-Id: I45202df4cd3a418414b1189cfc59bb845c37edd4 Signed-off-by: SagarS <sagar.shetty@est.tech> Issue-ID: SO-3905
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/CnfInstantiateTask.java90
-rwxr-xr-xbpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java5
3 files changed, 96 insertions, 3 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/CnfInstantiateTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/CnfInstantiateTask.java
new file mode 100644
index 0000000000..b6be7716f6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/CnfInstantiateTask.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.INPUT_PARAMETER;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter;
+import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParametersProvider;
+import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.NullInputParameter;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class performs CNF Instantiation
+ *
+ * @author sagar.shetty@est.tech
+ */
+@Component
+public class CnfInstantiateTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CnfInstantiateTask.class);
+ private final InputParametersProvider<GenericVnf> sdncInputParametersProvider;
+ private final ExtractPojosForBB extractPojosForBB;
+ private final InputParametersProvider<Map<String, Object>> userParamInputParametersProvider;
+
+ @Autowired
+ public CnfInstantiateTask(final InputParametersProvider<GenericVnf> inputParametersProvider,
+ final InputParametersProvider<Map<String, Object>> userParamInputParametersProvider,
+ final ExtractPojosForBB extractPojosForBB) {
+ this.sdncInputParametersProvider = inputParametersProvider;
+ this.userParamInputParametersProvider = userParamInputParametersProvider;
+ this.extractPojosForBB = extractPojosForBB;
+ }
+
+ public void handleCnfInstatiate(final BuildingBlockExecution execution) {
+ try {
+ LOGGER.debug("Executing handleCnfInstatiate ...");
+ final InputParameter userParamsInputParameter = getUserParamsInputParameter(execution);
+ LOGGER.debug("Finished executing handleCnfInstatiate ...");
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to get input parameters", exception);
+ execution.setVariable(INPUT_PARAMETER, NullInputParameter.NULL_INSTANCE);
+ }
+ }
+
+ private InputParameter getUserParamsInputParameter(final BuildingBlockExecution execution) {
+ final GeneralBuildingBlock generalBuildingBlock = execution.getGeneralBuildingBlock();
+ if (generalBuildingBlock != null && generalBuildingBlock.getRequestContext() != null
+ && generalBuildingBlock.getRequestContext().getRequestParameters() != null) {
+ final List<Map<String, Object>> userParams =
+ generalBuildingBlock.getRequestContext().getRequestParameters().getUserParams();
+ if (userParams != null) {
+ final Map<String, Object> params = new HashMap<>();
+ userParams.stream().forEach(obj -> {
+ params.putAll(obj);
+ });
+ LOGGER.info("User params found : {}", params);
+ if (userParams != null && !userParams.isEmpty()) {
+ return userParamInputParametersProvider.getInputParameter(params);
+ }
+ }
+ }
+ LOGGER.warn("No input parameters found in userparams ...");
+ return NullInputParameter.NULL_INSTANCE;
+ }
+}
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 ef32ac5cbb..c461c486d4 100755
--- 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
@@ -12,6 +12,8 @@
* ================================================================================
* Modifications Copyright (c) 2021 Orange
* ================================================================================
+ * Modifications Copyright (c) 2022 Ericsson. All rights reserved.
+ * ================================================================================
* 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
@@ -108,7 +110,7 @@ public class WorkflowAction {
private static final String VNF_TYPE = "vnfType";
private static final String CONFIGURATION = "Configuration";
private static final String SUPPORTEDTYPES =
- "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups";
+ "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups|cnfs";
private static final String HOMINGSOLUTION = "Homing_Solution";
private static final String SERVICE_TYPE_TRANSPORT = "TRANSPORT";
private static final String SERVICE_TYPE_BONDING = "BONDING";
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java
index 1eb5cf7437..c7b5f3c175 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java
@@ -3,7 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ================================================================================
* 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
@@ -31,7 +31,8 @@ public enum WorkflowType {
VIRTUAL_LINK("VirtualLink"),
NETWORKCOLLECTION("NetworkCollection"),
CONFIGURATION("Configuration"),
- INSTANCE_GROUP("InstanceGroup");
+ INSTANCE_GROUP("InstanceGroup"),
+ CNF("Cnf");
private final String type;