aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSagarS <sagar.shetty@est.tech>2022-06-16 13:22:13 +0100
committerSagarS <sagar.shetty@est.tech>2022-06-16 15:35:44 +0100
commit12161045e46f6edd422f265e509c1b21d4f4e07e (patch)
tree738e52ebd08e597617d9958054f53b93d0716144
parent9267b3ae36ce0ade8d7f7bcd44ff648e78d3a14e (diff)
[SO] CNF Invoke AS instance updates
Change-Id: I221df282a8cf1b9b4b0c579517393d2818eafaf2 Signed-off-by: SagarS <sagar.shetty@est.tech> Issue-ID: SO-3905
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfInstantiateBB.bpmn48
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java42
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java31
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java11
5 files changed, 113 insertions, 23 deletions
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
index 1ed80eeeab..a94e6aa2ca 100644
--- 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
@@ -1,12 +1,12 @@
<?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.0.0">
+<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_1luy180</bpmn:incoming>
+ <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>
@@ -17,22 +17,43 @@
<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="EndEvent_001k15i" />
+ <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="SequenceFlow_016sgof_di" bpmnElement="SequenceFlow_016sgof">
- <di:waypoint x="218" y="117" />
- <di:waypoint x="300" y="117" />
+ <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="Flow_1luy180_di" bpmnElement="Flow_1luy180">
- <di:waypoint x="550" y="117" />
- <di:waypoint x="622" y="117" />
+ <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>
@@ -40,10 +61,13 @@
<dc:Bounds x="450" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_001k15i_di" bpmnElement="EndEvent_001k15i">
- <dc:Bounds x="622" y="99" width="36" height="36" />
+ <dc:Bounds x="912" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="StartEvent_0ru3x55_di" bpmnElement="StartEvent_0ru3x55">
- <dc:Bounds x="182" y="99" width="36" height="36" />
+ <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>
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
index 6d7b3e9287..927be4db61 100644
--- 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
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -35,6 +35,7 @@ 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;
@@ -46,13 +47,15 @@ import org.springframework.stereotype.Component;
/**
* This class performs CNF Instantiation
- *
+ *
* @author sagar.shetty@est.tech
* @author Waqas Ikram (waqas.ikram@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;
@@ -120,6 +123,7 @@ public class CnfInstantiateTask {
}
final AsInstance asInstance = optional.get();
+ execution.setVariable(AS_INSTANCE_ID, asInstance.getAsInstanceid());
LOGGER.debug("Successfully invoked CNFM response: {}", asInstance);
} catch (final Exception exception) {
@@ -128,4 +132,34 @@ public class CnfInstantiateTask {
}
}
+ 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, 2001, 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(createAsRequest, 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, 2004, exception);
+ }
+ }
+
}
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
index 4ff346543f..abf3508fe6 100644
--- 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
@@ -22,7 +22,7 @@ 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)
@@ -33,4 +33,6 @@ 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
index f861855b99..bb789607e4 100644
--- 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
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -34,6 +34,7 @@ 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 {
@@ -80,4 +81,28 @@ public class CnfmHttpServiceProviderImpl implements CnfmHttpServiceProvider {
}
}
+ @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()) {
+ if (!response.hasBody()) {
+ LOGGER.error("Received response 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
index 3a0e4de6f9..6cd5d1e262 100644
--- 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
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -44,4 +44,9 @@ public class CnfmUrlProvider {
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();
+ }
+
}