aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql14
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java16
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfInstantiateBB.bpmn74
-rw-r--r--bpmn/so-bpmn-tasks/pom.xml9
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java167
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceConfiguration.java80
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java39
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java106
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java54
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java1
-rwxr-xr-xbpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java4
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java27
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java2
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java1
21 files changed, 607 insertions, 20 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
index 4e7c4102e3..7087b6c3e3 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
@@ -42,7 +42,8 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I
('VNF-Config-Update', 'applyUpdatedConfig', 'Vnf', true, true, '7','7', 'DEFAULT', '*'),
('CNF-Macro-Upgrade', 'upgradeCnf', 'Vnf', false,true, '7', '7','DEFAULT', '*'),
('PNF-Macro-Delete', 'deleteInstance', 'Pnf', false,true, '7', '7','DEFAULT', '*'),
-('PNF-Macro-Create', 'createInstance', 'Pnf', false,true, '7', '7','DEFAULT', '*');
+('PNF-Macro-Create', 'createInstance', 'Pnf', false,true, '7', '7','DEFAULT', '*'),
+('Cnf-Create', 'createInstance', 'Cnf', true, true, '7','7','DEFAULT', '*');
INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, SCOPE, ACTION, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES
@@ -281,7 +282,8 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, SC
('PNF-Macro-Create', '4', 'ControllerExecutionBB', 'pnf' , 'config-deploy', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'PNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
('PNF-Macro-Create', '5', 'ActivatePnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'PNF-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
('PNF-Macro-Delete', '1', 'DeactivatePnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'PNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('PNF-Macro-Delete', '2', 'UnassignPnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'PNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT'));
+('PNF-Macro-Delete', '2', 'UnassignPnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'PNF-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('CNF-Create', '1', 'CnfInstantiateBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Cnf-Create' and CLOUD_OWNER = 'DEFAULT'));
INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY, SECONDARY_POLICY, REG_EX_ERROR_MESSAGE, SERVICE_ROLE)
@@ -447,7 +449,8 @@ VALUES
('StatusCheckBB', 'NO_VALIDATE', 'CUSTOM'),
('HealthCheckBB', 'NO_VALIDATE', 'CUSTOM'),
('UpgradeVfModuleBB', 'NO_VALIDATE', 'CUSTOM'),
-('VfModuleUpgradeStatusBB', 'NO_VALIDATE', 'CUSTOM');
+('VfModuleUpgradeStatusBB', 'NO_VALIDATE', 'CUSTOM'),
+('CnfInstantiateBB', 'CNF', 'ACTIVATE');
INSERT INTO orchestration_status_state_transition_directive (resource_type, orchestration_status, target_action, flow_directive)
@@ -879,7 +882,8 @@ VALUES
('CONFIGURATION', 'PENDING DELETE', 'DEACTIVATE', 'FAIL'),
('CONFIGURATION', 'PENDING ACTIVATION', 'DEACTIVATE', 'FAIL'),
('CONFIGURATION', 'PENDING', 'DEACTIVATE', 'FAIL'),
-('VNF','CONFIGDEPLOYED','ACTIVATE','CONTINUE');
+('VNF','CONFIGDEPLOYED','ACTIVATE','CONTINUE'),
+('CNF','PRECREATED','ACTIVATE','CONTINUE');
INSERT INTO vnf_components_recipe (VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, VERSION, ORCHESTRATION_URI, RECIPE_TIMEOUT)
@@ -923,4 +927,4 @@ VALUES
('VNFQuiesceTrafficActivity',NULL,'VNFResumeTrafficActivity',NULL),
('EtsiVnfInstantiateBB',NULL,'EtsiVnfDeleteBB',NULL),
('AddFabricConfigurationBB',NULL,'DeleteFabricConfigurationBB',NULL),
-('CreateChildServiceBB',NULL,'DeleteChildServiceBB',NULL); \ No newline at end of file
+('CreateChildServiceBB',NULL,'DeleteChildServiceBB',NULL);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 0c5e2d1410..178612c4bd 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -8,6 +8,8 @@
* ================================================================================
* Modifications Copyright (c) 2020 Nokia
* ================================================================================
+ * Modifications Copyright (c) 2023 Nordix Foundation
+ * ================================================================================
* 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
@@ -410,7 +412,7 @@ public class BBInputSetup implements JavaDelegate {
if (modelType.equals(ModelType.network)) {
parameter.getLookupKeyMap().put(ResourceKey.NETWORK_ID, parameter.getResourceId());
this.populateL3Network(parameter);
- } else if (modelType.equals(ModelType.vnf)) {
+ } else if (modelType.equals(ModelType.vnf) || modelType.equals(ModelType.cnf)) {
parameter.getLookupKeyMap().put(ResourceKey.GENERIC_VNF_ID, parameter.getResourceId());
this.populateGenericVnf(parameter);
} else if (modelType.equals(ModelType.volumeGroup) || (modelType.equals(ModelType.vfModule)
@@ -897,7 +899,8 @@ public class BBInputSetup implements JavaDelegate {
break;
}
}
- if (vnf == null && parameter.getBbName().equalsIgnoreCase(AssignFlows.VNF.toString())) {
+ if ((vnf == null && parameter.getBbName().equalsIgnoreCase(AssignFlows.VNF.toString()))
+ || (parameter.getRequestDetails() != null && this.isCnf(parameter.getRequestDetails()))) {
vnf = createGenericVnf(parameter.getLookupKeyMap(), parameter.getInstanceName(), parameter.getPlatform(),
parameter.getLineOfBusiness(), parameter.getResourceId(), generatedVnfType,
parameter.getInstanceParams(), parameter.getProductFamilyId(), parameter.getApplicationId());
@@ -914,6 +917,15 @@ public class BBInputSetup implements JavaDelegate {
}
}
+ private boolean isCnf(final RequestDetails requestDetails) {
+ logger.debug("Executing isCNF to check the model type is CNF");
+ if (requestDetails.getModelInfo() != null) {
+ return ModelType.cnf.equals(requestDetails.getModelInfo().getModelType());
+ }
+ logger.debug("Not a CNF model type:{}", requestDetails);
+ return false;
+ }
+
protected boolean instanceGroupInList(GenericVnf vnf, String instanceGroupId) {
for (InstanceGroup instanceGroup : vnf.getInstanceGroups()) {
if (instanceGroup.getId() != null && instanceGroup.getId().equalsIgnoreCase(instanceGroupId)) {
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfInstantiateBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfInstantiateBB.bpmn
new file mode 100644
index 0000000000..a94e6aa2ca
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfInstantiateBB.bpmn
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0x13ohc" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.12.0">
+ <bpmn:process id="CnfInstantiateBB" name="&#10;Invoke CNFM" isExecutable="true">
+ <bpmn:startEvent id="StartEvent_0ru3x55">
+ <bpmn:outgoing>SequenceFlow_016sgof</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_016sgof" sourceRef="StartEvent_0ru3x55" targetRef="ServiceTask_11" />
+ <bpmn:endEvent id="EndEvent_001k15i">
+ <bpmn:incoming>Flow_1xcu3yl</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:serviceTask id="ServiceTask_11" name="Create &#10;CreateAsRequest" camunda:asyncAfter="true" camunda:expression="${CnfInstantiateTask.createCreateAsRequest(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_016sgof</bpmn:incoming>
+ <bpmn:outgoing>Flow_1s7gtbc</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_1y5x7jl" name="Invoke CNFM" camunda:asyncAfter="true" camunda:expression="${CnfInstantiateTask.invokeCnfmWithCreateAsRequest(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>Flow_1s7gtbc</bpmn:incoming>
+ <bpmn:outgoing>Flow_1luy180</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_1s7gtbc" sourceRef="ServiceTask_11" targetRef="Activity_1y5x7jl" />
+ <bpmn:sequenceFlow id="Flow_1luy180" sourceRef="Activity_1y5x7jl" targetRef="Activity_0oa5fst" />
+ <bpmn:serviceTask id="Activity_00w0lnj" name="Invoke CNFM Instance Request" camunda:asyncAfter="true" camunda:expression="${CnfInstantiateTask.invokeCnfmWithInstantiateAsRequest(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>Flow_0xq0uda</bpmn:incoming>
+ <bpmn:outgoing>Flow_1xcu3yl</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_0oa5fst" name="Create&#10;AsInstance Request" camunda:asyncAfter="true" camunda:expression="${CnfInstantiateTask.createAsInstanceRequest(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>Flow_1luy180</bpmn:incoming>
+ <bpmn:outgoing>Flow_0xq0uda</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_0xq0uda" sourceRef="Activity_0oa5fst" targetRef="Activity_00w0lnj" />
+ <bpmn:sequenceFlow id="Flow_1xcu3yl" sourceRef="Activity_00w0lnj" targetRef="EndEvent_001k15i" />
+ </bpmn:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CnfInstantiateBB">
+ <bpmndi:BPMNEdge id="Flow_1luy180_di" bpmnElement="Flow_1luy180">
+ <di:waypoint x="550" y="117" />
+ <di:waypoint x="620" y="117" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1s7gtbc_di" bpmnElement="Flow_1s7gtbc">
+ <di:waypoint x="400" y="117" />
+ <di:waypoint x="450" y="117" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_016sgof_di" bpmnElement="SequenceFlow_016sgof">
+ <di:waypoint x="218" y="117" />
+ <di:waypoint x="300" y="117" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0xq0uda_di" bpmnElement="Flow_0xq0uda">
+ <di:waypoint x="720" y="117" />
+ <di:waypoint x="770" y="117" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1xcu3yl_di" bpmnElement="Flow_1xcu3yl">
+ <di:waypoint x="870" y="117" />
+ <di:waypoint x="912" y="117" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="StartEvent_0ru3x55_di" bpmnElement="StartEvent_0ru3x55">
+ <dc:Bounds x="182" y="99" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_1jf7hlc_di" bpmnElement="ServiceTask_11">
+ <dc:Bounds x="300" y="77" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1y5x7jl_di" bpmnElement="Activity_1y5x7jl">
+ <dc:Bounds x="450" y="77" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_001k15i_di" bpmnElement="EndEvent_001k15i">
+ <dc:Bounds x="912" y="99" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0oa5fst_di" bpmnElement="Activity_0oa5fst">
+ <dc:Bounds x="620" y="77" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_00w0lnj_di" bpmnElement="Activity_00w0lnj">
+ <dc:Bounds x="770" y="77" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml
index 64db71339d..64a79349ab 100644
--- a/bpmn/so-bpmn-tasks/pom.xml
+++ b/bpmn/so-bpmn-tasks/pom.xml
@@ -11,6 +11,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <so-cnfm-lcm-api.version>1.9.0-SNAPSHOT</so-cnfm-lcm-api.version>
+ <jqno.equalsverifier.version>2.5.1</jqno.equalsverifier.version>
</properties>
<build>
<plugins>
@@ -227,7 +229,7 @@
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
- <version>2.5.1</version>
+ <version>${jqno.equalsverifier.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -245,5 +247,10 @@
<artifactId>so-sdn-clients</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm</groupId>
+ <artifactId>so-cnfm-lcm-api</artifactId>
+ <version>${so-cnfm-lcm-api.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java
new file mode 100644
index 0000000000..ab20a08e74
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java
@@ -0,0 +1,167 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.cnfm.tasks;
+
+import static java.util.Objects.isNull;
+import static org.onap.so.cnfm.lcm.model.utils.AdditionalParamsConstants.CLOUD_OWNER_PARAM_KEY;
+import static org.onap.so.cnfm.lcm.model.utils.AdditionalParamsConstants.CLOUD_REGION_PARAM_KEY;
+import static org.onap.so.cnfm.lcm.model.utils.AdditionalParamsConstants.SERVICE_INSTANCE_ID_PARAM_KEY;
+import static org.onap.so.cnfm.lcm.model.utils.AdditionalParamsConstants.SERVICE_INSTANCE_NAME_PARAM_KEY;
+import static org.onap.so.cnfm.lcm.model.utils.AdditionalParamsConstants.TENANT_ID_PARAM_KEY;
+import java.util.Optional;
+import org.apache.groovy.util.Maps;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.cnfm.lcm.model.AsInstance;
+import org.onap.so.cnfm.lcm.model.CreateAsRequest;
+import org.onap.so.cnfm.lcm.model.InstantiateAsRequest;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+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
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Raviteja Karumuri (raviteja.karumuri@est.tech)
+ */
+@Component
+public class CnfInstantiateTask {
+ private static final String CREATE_AS_REQUEST_OBJECT = "CreateAsRequestObject";
+ private static final String INSTANTIATE_AS_REQUEST_OBJECT = "InstantiateAsRequest";
+ private static final String AS_INSTANCE_ID = "asInstanceid";
+ private static final Logger LOGGER = LoggerFactory.getLogger(CnfInstantiateTask.class);
+ private final ExceptionBuilder exceptionUtil;
+ private final CnfmHttpServiceProvider cnfmHttpServiceProvider;
+
+ @Autowired
+ public CnfInstantiateTask(final CnfmHttpServiceProvider cnfmHttpServiceProvider,
+ final ExceptionBuilder exceptionUtil) {
+ this.cnfmHttpServiceProvider = cnfmHttpServiceProvider;
+ this.exceptionUtil = exceptionUtil;
+ }
+
+ public void createCreateAsRequest(final BuildingBlockExecution execution) {
+ try {
+ LOGGER.debug("Executing createAsRequest task ...");
+ final ExecuteBuildingBlock executeBuildingBlock =
+ (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
+
+ final GeneralBuildingBlock generalBuildingBlock = execution.getGeneralBuildingBlock();
+
+ final RequestDetails requestDetails = executeBuildingBlock.getRequestDetails();
+ LOGGER.debug("RequestDetails: {}", requestDetails);
+
+ if (isNull(requestDetails) && isNull(requestDetails.getModelInfo())
+ && isNull(requestDetails.getRequestInfo()) && isNull(requestDetails.getCloudConfiguration())
+ && isNull(generalBuildingBlock)) {
+ LOGGER.error("Missing Mandatory attribute from RequestDetails: {} or GeneralBuildingBlock: {}",
+ requestDetails, generalBuildingBlock);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000,
+ "Missing Mandatory attribute from RequestDetails or GeneralBuildingBlock", ONAPComponents.SO);
+ }
+
+ final ModelInfo modelInfo = requestDetails.getModelInfo();
+ final CloudConfiguration cloudConfiguration = requestDetails.getCloudConfiguration();
+ final ServiceInstance serviceInstance = generalBuildingBlock.getServiceInstance();
+
+ final CreateAsRequest createAsRequest = new CreateAsRequest().asdId(modelInfo.getModelVersionId())
+ .asInstanceName(requestDetails.getRequestInfo().getInstanceName())
+ .additionalParams(Maps.of(CLOUD_OWNER_PARAM_KEY, cloudConfiguration.getCloudOwner(),
+ CLOUD_REGION_PARAM_KEY, cloudConfiguration.getLcpCloudRegionId(), TENANT_ID_PARAM_KEY,
+ cloudConfiguration.getTenantId(), SERVICE_INSTANCE_ID_PARAM_KEY,
+ serviceInstance.getServiceInstanceId(), SERVICE_INSTANCE_NAME_PARAM_KEY,
+ serviceInstance.getServiceInstanceName()));
+
+ LOGGER.debug("Adding CreateAsRequest to execution {}", createAsRequest);
+
+ execution.setVariable(CREATE_AS_REQUEST_OBJECT, createAsRequest);
+ LOGGER.debug("Finished executing createAsRequest task ...");
+
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to create CreateAsRequest", exception);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2001, exception);
+ }
+ }
+
+ public void invokeCnfmWithCreateAsRequest(final BuildingBlockExecution execution) {
+ try {
+ final CreateAsRequest createAsRequest = execution.getVariable(CREATE_AS_REQUEST_OBJECT);
+
+ final Optional<AsInstance> optional = cnfmHttpServiceProvider.invokeCreateAsRequest(createAsRequest);
+
+ if (optional.isEmpty()) {
+ LOGGER.error("Unable to invoke CNFM for CreateAsRequest : {}", createAsRequest);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2003,
+ "Unable to invoke CNFM for CreateAsRequest", ONAPComponents.SO);
+ }
+
+ final AsInstance asInstance = optional.orElseThrow();
+ execution.setVariable(AS_INSTANCE_ID, asInstance.getAsInstanceid());
+ LOGGER.debug("Successfully invoked CNFM response: {}", asInstance);
+
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to invoke CNFM AsCreateRequest", exception);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2004, exception);
+ }
+ }
+
+ public void createAsInstanceRequest(final BuildingBlockExecution execution) {
+ try {
+ LOGGER.debug("Executing createAsInstanceRequest task ...");
+
+ final InstantiateAsRequest instantiateAsRequest = new InstantiateAsRequest();
+
+ LOGGER.debug("Adding InstantiateAsRequest to execution {}", instantiateAsRequest);
+
+ execution.setVariable(INSTANTIATE_AS_REQUEST_OBJECT, instantiateAsRequest);
+ LOGGER.debug("Finished executing createAsInstanceRequest task ...");
+
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to create CreateAsInstanceRequest", exception);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2002, exception);
+ }
+ }
+
+ public void invokeCnfmWithInstantiateAsRequest(final BuildingBlockExecution execution) {
+ try {
+ final InstantiateAsRequest instantiateAsRequest = execution.getVariable(INSTANTIATE_AS_REQUEST_OBJECT);
+ final String asInstanceId = execution.getVariable(AS_INSTANCE_ID);
+ cnfmHttpServiceProvider.invokeInstantiateAsRequest(instantiateAsRequest, asInstanceId);
+ LOGGER.debug("Successfully invoked CNFM instantiate AS request: {}", asInstanceId);
+
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to invoke CNFM InstantiateAsRequest", exception);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2005, exception);
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceConfiguration.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceConfiguration.java
new file mode 100644
index 0000000000..1028c28e77
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceConfiguration.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.cnfm.tasks;
+
+import javax.ws.rs.core.MediaType;
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
+import org.onap.so.configuration.rest.HttpComponentsClientConfiguration;
+import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.onap.so.rest.service.HttpRestServiceProviderImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.client.BufferingClientHttpRequestFactory;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @author waqas.ikram@est.tech
+ * @author Raviteja Karumuri (raviteja.karumuri@est.tech)
+ */
+@Configuration
+public class CnfmHttpServiceConfiguration {
+
+ private static final Logger logger = LoggerFactory.getLogger(CnfmHttpServiceConfiguration.class);
+ public static final String CNFM_REST_TEMPLATE_CLIENT_BEAN = "cnfmRestTemplateBean";
+ public static final String CNFM_HTTP_REST_SERVICE_PROVIDER_BEAN = "cnfmHttpRestServiceProvider";
+
+ @Bean
+ @Qualifier(CNFM_REST_TEMPLATE_CLIENT_BEAN)
+ public RestTemplate cnfmRestTemplateBean(
+ @Autowired final HttpComponentsClientConfiguration httpComponentsClientConfiguration) {
+ logger.debug("Setting up cnfm RestTemplate bean...");
+ final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory =
+ httpComponentsClientConfiguration.httpComponentsClientHttpRequestFactory();
+
+ final RestTemplate restTemplate =
+ new RestTemplate(new BufferingClientHttpRequestFactory(clientHttpRequestFactory));
+ restTemplate.getInterceptors().add(new SOSpringClientFilter());
+ restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
+ return restTemplate;
+
+ }
+
+ @Bean
+ @Qualifier(CNFM_HTTP_REST_SERVICE_PROVIDER_BEAN)
+ public HttpRestServiceProvider cnfmHttpRestServiceProvider(
+ @Qualifier(CNFM_REST_TEMPLATE_CLIENT_BEAN) @Autowired final RestTemplate restTemplate) {
+
+ logger.debug("Setting up cnfm HttpRestServiceProvider bean...");
+ final HttpHeaders hearders = new HttpHeaders();
+ hearders.add(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ hearders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+
+ return new HttpRestServiceProviderImpl(restTemplate, hearders);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java
new file mode 100644
index 0000000000..5e9112f3e0
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.cnfm.tasks;
+
+import java.util.Optional;
+import org.onap.so.cnfm.lcm.model.AsInstance;
+import org.onap.so.cnfm.lcm.model.CreateAsRequest;
+import org.onap.so.cnfm.lcm.model.InstantiateAsRequest;
+
+/**
+ * @author Sagar Shetty (sagar.shetty@est.tech)
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Raviteja Karumuri (raviteja.karumuri@est.tech)
+ *
+ */
+public interface CnfmHttpServiceProvider {
+
+ Optional<AsInstance> invokeCreateAsRequest(final CreateAsRequest createAsRequest);
+
+ void invokeInstantiateAsRequest(InstantiateAsRequest instantiateAsRequest, String asInstanceId);
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java
new file mode 100644
index 0000000000..3f78896b5d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.cnfm.tasks;
+
+import static org.onap.so.bpmn.infrastructure.adapter.cnfm.tasks.CnfmHttpServiceConfiguration.CNFM_HTTP_REST_SERVICE_PROVIDER_BEAN;
+import java.util.Optional;
+import org.onap.so.cnfm.lcm.model.AsInstance;
+import org.onap.so.cnfm.lcm.model.CreateAsRequest;
+import org.onap.so.rest.exceptions.HttpResouceNotFoundException;
+import org.onap.so.rest.exceptions.InvalidRestRequestException;
+import org.onap.so.rest.exceptions.RestProcessingException;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.onap.so.cnfm.lcm.model.InstantiateAsRequest;
+
+@Service
+public class CnfmHttpServiceProviderImpl implements CnfmHttpServiceProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CnfmHttpServiceProviderImpl.class);
+ private final CnfmUrlProvider cnfmUrlProvider;
+ private final HttpRestServiceProvider httpServiceProvider;
+
+ @Autowired
+ public CnfmHttpServiceProviderImpl(final CnfmUrlProvider cnfmUrlProvider,
+ @Qualifier(CNFM_HTTP_REST_SERVICE_PROVIDER_BEAN) final HttpRestServiceProvider httpServiceProvider) {
+ this.cnfmUrlProvider = cnfmUrlProvider;
+ this.httpServiceProvider = httpServiceProvider;
+ }
+
+ @Override
+ public Optional<AsInstance> invokeCreateAsRequest(final CreateAsRequest createAsRequest) {
+ try {
+ final String url = cnfmUrlProvider.getCreateAsRequestUrl();
+ final ResponseEntity<AsInstance> response =
+ httpServiceProvider.postHttpRequest(createAsRequest, url, AsInstance.class);
+
+ final HttpStatus httpStatus = response.getStatusCode();
+ if (httpStatus.is2xxSuccessful()) {
+ if (!response.hasBody()) {
+ LOGGER.error("Received response without body: {}", response);
+ return Optional.empty();
+ }
+
+ final AsInstance asInstance = response.getBody();
+ if (asInstance.getAsInstanceid() == null || asInstance.getAsInstanceid().isEmpty()) {
+ LOGGER.error("Received invalid response missing asInstanceid: {}", response);
+ return Optional.empty();
+ }
+ return Optional.of(asInstance);
+ }
+ LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value());
+ return Optional.empty();
+
+ } catch (final RestProcessingException | InvalidRestRequestException
+ | HttpResouceNotFoundException httpInvocationException) {
+ LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException);
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public void invokeInstantiateAsRequest(InstantiateAsRequest instantiateAsRequest, String asInstanceId) {
+ try {
+
+ final String url = cnfmUrlProvider.getInstantiateAsRequestUrl(asInstanceId);
+ final ResponseEntity<AsInstance> response =
+ httpServiceProvider.postHttpRequest(instantiateAsRequest, url, AsInstance.class);
+
+ final HttpStatus httpStatus = response.getStatusCode();
+ if (httpStatus.is2xxSuccessful() && !(response.hasBody())) {
+ LOGGER.error("Response received without body: {}", response);
+ }
+ LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value());
+
+ } catch (final RestProcessingException | InvalidRestRequestException
+ | HttpResouceNotFoundException httpInvocationException) {
+ LOGGER.error("Unexpected error while processing instantiation request", httpInvocationException);
+ }
+
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java
new file mode 100644
index 0000000000..cef2f3f818
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.cnfm.tasks;
+
+import java.net.URI;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * @author Sagar Shetty (sagar.shetty@est.tech)
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Raviteja Karumuri (raviteja.karumuri@est.tech)
+ *
+ */
+@Service
+public class CnfmUrlProvider {
+
+ private final URI baseUri;
+
+ @Autowired
+ public CnfmUrlProvider(@Value("${cnfm.endpoint:http://so-cnfm-lcm.onap:9888}") final String baseUrl) {
+ this.baseUri = UriComponentsBuilder.fromHttpUrl(baseUrl).path("/so/so-cnfm/v1/api/aslcm/v1").build().toUri();
+ }
+
+ public String getCreateAsRequestUrl() {
+ return UriComponentsBuilder.fromUri(baseUri).pathSegment("as_instances").build().toString();
+ }
+
+ public String getInstantiateAsRequestUrl(String asInstanceId) {
+ return UriComponentsBuilder.fromUri(baseUri).pathSegment("as_instances").pathSegment(asInstanceId)
+ .pathSegment("instantiate").build().toString();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java
index c3c0047fff..fc3d6ab96c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java
@@ -58,6 +58,8 @@ import org.springframework.web.client.RestTemplate;
@Configuration
public class VnfmAdapterCreateVnfTaskConfiguration {
+ public static final String VNFM_HTTP_REST_SERVICE_PROVIDER_BEAN = "vnfmHttpRestServiceProvider";
+
private static final Logger logger = LoggerFactory.getLogger(VnfmAdapterCreateVnfTaskConfiguration.class);
@Value("${rest.http.client.configuration.ssl.trustStore:#{null}}")
@@ -73,7 +75,8 @@ public class VnfmAdapterCreateVnfTaskConfiguration {
private String keyStorePassword;
@Bean
- public HttpRestServiceProvider databaseHttpRestServiceProvider(
+ @Qualifier(VNFM_HTTP_REST_SERVICE_PROVIDER_BEAN)
+ public HttpRestServiceProvider vnfmHttpRestServiceProvider(
@Qualifier(CONFIGURABLE_REST_TEMPLATE) @Autowired final RestTemplate restTemplate,
@Autowired final VnfmBasicHttpConfigProvider etsiVnfmAdapter) {
if (trustStore != null) {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
index ac2e0bf17a..94213bb93f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
@@ -20,6 +20,7 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmAdapterCreateVnfTaskConfiguration.VNFM_HTTP_REST_SERVICE_PROVIDER_BEAN;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse;
@@ -31,6 +32,7 @@ import org.onap.so.rest.service.HttpRestServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -50,7 +52,7 @@ public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvide
@Autowired
public VnfmAdapterServiceProviderImpl(final VnfmAdapterUrlProvider urlProvider,
- final HttpRestServiceProvider httpServiceProvider) {
+ @Qualifier(VNFM_HTTP_REST_SERVICE_PROVIDER_BEAN) final HttpRestServiceProvider httpServiceProvider) {
this.urlProvider = urlProvider;
this.httpServiceProvider = httpServiceProvider;
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
index f233de2baa..b9d06789bd 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
@@ -154,6 +154,7 @@ public class OrchestrationStatusValidator {
orchestrationStatus = serviceInstance.getOrchestrationStatus();
break;
case VNF:
+ case CNF:
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
orchestrationStatus = genericVnf.getOrchestrationStatus();
break;
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 64e623ba98..64ae9cb5e0 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
@@ -112,7 +112,7 @@ public class WorkflowAction {
private static final String VNF_TYPE = "vnfType";
private static final String CONFIGURATION = "Configuration";
private static final String SUPPORTEDTYPES =
- "vnfs|pnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups";
+ "vnfs|pnfs|cnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups";
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..0a60724b6c 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
@@ -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;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java
index 75151d9c6a..2a9e42a602 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ public class VnfmAdapterCreateVnfTaskConfigurationTest {
final VnfmAdapterCreateVnfTaskConfiguration objUnderTest = new VnfmAdapterCreateVnfTaskConfiguration();
final HttpRestServiceProvider actual =
- objUnderTest.databaseHttpRestServiceProvider(restTemplate, getVnfmBasicHttpConfigProvider());
+ objUnderTest.vnfmHttpRestServiceProvider(restTemplate, getVnfmBasicHttpConfigProvider());
assertNotNull(actual);
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java
index 6b9b39e5a9..bfe315c969 100644
--- a/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java
@@ -37,7 +37,9 @@ public enum ModelType {
pnf("pnf"),
networkInstanceGroup("networkInstanceGroup"),
instanceGroup("instanceGroup"),
- vpnBinding("vpnBinding");
+ vpnBinding("vpnBinding"),
+ cnf("cnf");
+
final String name;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index 64c42a0498..af507c6d56 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -376,7 +376,9 @@ public class MsoRequest {
aq.setInstanceGroupId(servInsReq.getInstanceGroupId());
aq.setInstanceGroupName(requestInfo.getInstanceName());
}
- if (ModelType.vnf.name().equalsIgnoreCase(requestScope)) {
+
+ if (ModelType.vnf.name().equalsIgnoreCase(requestScope)
+ || ModelType.cnf.name().equalsIgnoreCase(requestScope)) {
if (requestInfo != null) {
aq.setVnfName(requestInfo.getInstanceName());
}
@@ -712,7 +714,8 @@ public class MsoRequest {
} else if (requestScope.equalsIgnoreCase(ModelType.vfModule.name())) {
vnfType = serviceModelName + "/" + vnfModelName;
sir.setVolumeGroupInstanceId(volumeGroupId);
- } else if (requestScope.equalsIgnoreCase(ModelType.vnf.name()))
+ } else if (requestScope.equalsIgnoreCase(ModelType.vnf.name())
+ || requestScope.equalsIgnoreCase(ModelType.cnf.name()))
vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName();
return vnfType;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
index a0f3e1a20a..4338e6109e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -406,7 +406,8 @@ public class RequestHandlerUtils extends AbstractRestHandler {
if (StringUtils.isNotBlank(instanceId)) {
if (ModelType.service.name().equalsIgnoreCase(requestScope)) {
currentActiveReq.setServiceInstanceId(instanceId);
- } else if (ModelType.vnf.name().equalsIgnoreCase(requestScope)) {
+ } else if (ModelType.vnf.name().equalsIgnoreCase(requestScope)
+ || ModelType.cnf.name().equalsIgnoreCase(requestScope)) {
currentActiveReq.setVnfId(instanceId);
} else if (ModelType.vfModule.name().equalsIgnoreCase(requestScope)) {
currentActiveReq.setVfModuleId(instanceId);
@@ -547,6 +548,9 @@ public class RequestHandlerUtils extends AbstractRestHandler {
requestScope = ModelType.vnf.name();
} else if (requestUri.contains(ModelType.pnf.name())) {
requestScope = ModelType.pnf.name();
+
+ } else if (requestUri.contains(ModelType.cnf.name())) {
+ requestScope = ModelType.cnf.name();
} else {
requestScope = ModelType.service.name();
}
@@ -727,6 +731,8 @@ public class RequestHandlerUtils extends AbstractRestHandler {
recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
} else if (modelInfo.getModelType().equals(ModelType.instanceGroup)) {
recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
+ } else if (modelInfo.getModelType().equals(ModelType.cnf)) {
+ recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
}
if (recipeLookupResult == null) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 353daf8afb..021807703e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -7,6 +7,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2023 Nordix Foundation.
+ * ================================================================================
* 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
@@ -379,6 +381,28 @@ public class ServiceInstances extends AbstractRestHandler {
}
@POST
+ @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/cnfs")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Operation(description = "Create CNF on a specified version and serviceInstance", responses = @ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
+ @Transactional
+ public Response createCnfInstance(String request, @PathParam("version") String version,
+ @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext)
+ throws ApiException {
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ try {
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId,
+ requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
+ } catch (Exception e) {
+ logger.error("Error in cnf", e);
+ throw e;
+ }
+ }
+
+ @POST
@Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/upgrade")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@@ -946,7 +970,8 @@ public class ServiceInstances extends AbstractRestHandler {
requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId,
currentActiveReq);
if ((action == Action.replaceInstance || action == Action.replaceInstanceRetainAssignments)
- && (requestScope.equals(ModelType.vnf.toString()) || requestScope.equals(ModelType.vfModule.toString()))
+ && (requestScope.equals(ModelType.vnf.toString()) || requestScope.equals(ModelType.vfModule.toString())
+ || requestScope.equals(ModelType.cnf.toString()))
&& sir.getRequestDetails().getCloudConfiguration() == null) {
CloudConfiguration cloudConfiguration =
getCloudConfigurationOnReplace(requestScope, instanceIdMap, currentActiveReq);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java
index e24ecd4eac..723bdd558b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java
@@ -24,5 +24,5 @@ package org.onap.so.apihandlerinfra.vnfbeans;
* Enum for Status values returned by API Handler to Tail-F
*/
public enum ModelType {
- service, vnf, vfModule, volumeGroup, network
+ service, vnf, vfModule, volumeGroup, network, cnf
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java
index 74f58a210c..c69c0a7aab 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java
@@ -23,6 +23,7 @@ package org.onap.so.db.catalog.beans;
public enum ResourceType {
SERVICE("Service", "SERVICE_INSTANCE_ID"),
VNF("Vnf", "GENERIC_VNF_ID"),
+ CNF("Cnf", "GENERIC_VNF_ID"),
VOLUME_GROUP("VolumeGroup", "VOLUME_GROUP_ID"),
VF_MODULE("VfModule", "VF_MODULE_ID"),
NETWORK("Network", "NETWORK_ID"),