aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy9
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java107
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy36
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java21
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfAdapterCallback.xml21
6 files changed, 127 insertions, 69 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy
index c1199aefd7..23231df6be 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy
@@ -477,7 +477,7 @@ class NetworkUtils {
networkStartAddress = subnet.getNetworkStartAddress()
}
if (element == "cidr-mask") {
- xmlBuild += "<cidr>"+networkStartAddress+"/"+var+"</cidr>"
+ xmlBuild += "<cidr>"+networkStartAddress+"/"+ subnet.getCidrMask() +"</cidr>"
}
}
if (element == "dhcp-enabled") {
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
index 8aff0f715d..78af8768f9 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
@@ -365,16 +365,15 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
// TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead.
execution.setVariable("WorkflowResponse", callback)
+ callback = utils.removeXmlPreamble(callback)
+
Node root = new XmlParser().parseText(callback)
if (root.name().endsWith('Exception')) {
vnfAdapterWorkflowException(execution, callback)
}
} catch (Exception e) {
- e.printStackTrace()
- callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback
- String msg = "Received error from VnfAdapter: " + callback
- msoLogger.debug(getProcessKey(execution) + ': ' + msg)
- exceptionUtil.buildWorkflowException(execution, 7020, msg)
+ msoLogger.debug("Error encountered within VnfAdapterRest ProcessCallback method", e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Error encountered within VnfAdapterRest ProcessCallback method")
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java
index ba9426d88a..6c2df13c61 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java
@@ -76,43 +76,54 @@ public class ExecuteBuildingBlockRainyDay {
Map<ResourceKey, String> lookupKeyMap = (Map<ResourceKey, String>) execution.getVariable("lookupKeyMap");
String serviceType = ASTERISK;
boolean aLaCarte = (boolean) execution.getVariable("aLaCarte");
- try {
- serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getModelInfoServiceInstance().getServiceType();
- } catch (Exception ex) {
- // keep default serviceType value
- }
- String vnfType = ASTERISK;
- try {
- for(GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs()) {
- if(vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) {
- vnfType = vnf.getVnfType();
+ boolean suppressRollback = (boolean) execution.getVariable("suppressRollback");
+ String handlingCode = "";
+ if(suppressRollback){
+ handlingCode = "Abort";
+ }else{
+ try {
+ serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getModelInfoServiceInstance().getServiceType();
+ } catch (Exception ex) {
+ // keep default serviceType value
+ }
+ String vnfType = ASTERISK;
+ try {
+ for(GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs()) {
+ if(vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) {
+ vnfType = vnf.getVnfType();
+ }
}
+ } catch (Exception ex) {
+ // keep default vnfType value
}
- } catch (Exception ex) {
- // keep default vnfType value
- }
- WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
- String errorCode = ASTERISK;
- try {
- errorCode = "" + workflowException.getErrorCode();
- } catch (Exception ex) {
- // keep default errorCode value
- }
- String workStep = ASTERISK;
- try {
- workStep = workflowException.getWorkStep();
- } catch (Exception ex) {
- // keep default workStep value
- }
- //Extract error data to be returned to WorkflowAction
- execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage());
- RainyDayHandlerStatus rainyDayHandlerStatus;
- String handlingCode = "";
- rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,serviceType,vnfType,errorCode,workStep);
- if(rainyDayHandlerStatus==null){
- rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,ASTERISK,ASTERISK,ASTERISK,ASTERISK);
+ WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
+ String errorCode = ASTERISK;
+ try {
+ errorCode = "" + workflowException.getErrorCode();
+ } catch (Exception ex) {
+ // keep default errorCode value
+ }
+ String workStep = ASTERISK;
+ try {
+ workStep = workflowException.getWorkStep();
+ } catch (Exception ex) {
+ // keep default workStep value
+ }
+ //Extract error data to be returned to WorkflowAction
+ execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage());
+ RainyDayHandlerStatus rainyDayHandlerStatus;
+ rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,serviceType,vnfType,errorCode,workStep);
if(rainyDayHandlerStatus==null){
- handlingCode = "Abort";
+ rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,ASTERISK,ASTERISK,ASTERISK,ASTERISK);
+ if(rainyDayHandlerStatus==null){
+ handlingCode = "Abort";
+ }else{
+ if(primaryPolicy){
+ handlingCode = rainyDayHandlerStatus.getPolicy();
+ }else{
+ handlingCode = rainyDayHandlerStatus.getSecondaryPolicy();
+ }
+ }
}else{
if(primaryPolicy){
handlingCode = rainyDayHandlerStatus.getPolicy();
@@ -120,26 +131,20 @@ public class ExecuteBuildingBlockRainyDay {
handlingCode = rainyDayHandlerStatus.getSecondaryPolicy();
}
}
- }else{
- if(primaryPolicy){
- handlingCode = rainyDayHandlerStatus.getPolicy();
- }else{
- handlingCode = rainyDayHandlerStatus.getSecondaryPolicy();
+ if(!primaryPolicy){
+ try{
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+ request.setRetryStatusMessage("Retries have been exhausted.");
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch(Exception ex){
+ msoLogger.debug(ex.toString());
+ msoLogger.error("Failed to update Request Db Infra Active Requests with Retry Status");
+ }
}
- }
- if(!primaryPolicy){
- try{
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- request.setRetryStatusMessage("Retries have been exhausted.");
- requestDbclient.updateInfraActiveRequests(request);
- } catch(Exception ex){
- msoLogger.debug(ex.toString());
- msoLogger.error("Failed to update Request Db Infra Active Requests with Retry Status");
+ if(handlingCode.equals("RollbackToAssigned")&&!aLaCarte){
+ handlingCode = "Rollback";
}
}
- if(handlingCode.equals("RollbackToAssigned")&&!aLaCarte){
- handlingCode = "Rollback";
- }
msoLogger.debug("RainyDayHandler Status Code is: " + handlingCode);
execution.setVariable(HANDLING_CODE, handlingCode);
} catch (Exception e) {
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy
index 77edd2dc6d..72cde00877 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy
@@ -7,9 +7,9 @@
* 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.
@@ -34,14 +34,14 @@ import static org.junit.Assert.*;
@RunWith(MockitoJUnitRunner.class)
public class VnfAdapterRestV1Test {
-
+
@Before
public void init()
{
MockitoAnnotations.initMocks(this)
}
-
+
@Test
public void testPreProcessRequest() {
@@ -59,11 +59,11 @@ public class VnfAdapterRestV1Test {
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
-
+
VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1()
vnfAdapterRestV1.preProcessRequest(mockExecution)
-
+
MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
//debugger.printInvocations(mockExecution)
@@ -78,7 +78,7 @@ public class VnfAdapterRestV1Test {
verify(mockExecution).setVariable("VNFREST_vnfAdapterUrl","http://localhost:18080/vnfs/rest/v1/vnfs/6d2e2469-8708-47c3-a0d4-73fa28a8a50b/vf-modules")
}
-
+
def rollbackReq = """
<rollbackVolumeGroupRequest>
<volumeGroupRollback>
@@ -97,7 +97,7 @@ public class VnfAdapterRestV1Test {
<notificationUrl>http://localhost:8080/mso/WorkflowMessage/VNFAResponse/683ca1ac-2145-4a00-9484-20d48bd701aa</notificationUrl>
</rollbackVolumeGroupRequest>
"""
-
+
@Test
public void testGetVolumeGroupId() {
Node root = new XmlParser().parseText(rollbackReq)
@@ -106,13 +106,29 @@ public class VnfAdapterRestV1Test {
assertEquals('8a07b246-155e-4b08-b56e-76e98a3c2d66', volGrpId)
}
-
+
@Test
public void testGetMessageId() {
Node root = new XmlParser().parseText(rollbackReq)
-
+
VnfAdapterRestV1 p = new VnfAdapterRestV1()
def messageId = p.getMessageIdForVolumeGroupRollback(root)
assertEquals('683ca1ac-2145-4a00-9484-20d48bd701aa', messageId)
}
+
+ @Test
+ public void testProcessCallback() {
+
+ String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfAdapterCallback.xml");
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+
+ when(mockExecution.getVariable("VNFAResponse_MESSAGE")).thenReturn(sdncAdapterWorkflowRequest)
+ when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
+
+ VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1()
+ vnfAdapterRestV1.processCallback(mockExecution)
+
+ verify(mockExecution).setVariable("testProcessKeyResponse" ,sdncAdapterWorkflowRequest)
+
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
index fc2de4307b..9af9b2f2c9 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
@@ -91,7 +91,9 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
vnf.setVnfType("vnft1");
- delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("suppressRollback", false);
+
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
@@ -113,6 +115,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("suppressRollback", false);
+
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode(ASTERISK);
rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
@@ -136,7 +140,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", true);
doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class));
-
+ delegateExecution.setVariable("suppressRollback", false);
+
executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
@@ -147,6 +152,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
doThrow(RuntimeException.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class));
delegateExecution.setVariable("aLaCarte", true);
executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
+ delegateExecution.setVariable("suppressRollback", false);
assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
}
@@ -157,6 +163,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("suppressRollback", false);
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
@@ -180,6 +187,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", false);
+ delegateExecution.setVariable("suppressRollback", false);
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
@@ -203,6 +211,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("suppressRollback", false);
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
@@ -220,4 +229,12 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
assertEquals("RollbackToAssigned", delegateExecution.getVariable("handlingCode"));
}
+ @Test
+ public void suppressRollbackTest() throws Exception {
+ delegateExecution.setVariable("suppressRollback", true);
+ delegateExecution.setVariable("aLaCarte", true);
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
+ assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfAdapterCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfAdapterCallback.xml
new file mode 100644
index 0000000000..d63a5ecbaf
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/vnfAdapterMocks/vnfAdapterCallback.xml
@@ -0,0 +1,21 @@
+
+
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<createVfModuleResponse>
+ <messageId>255ca199-7f53-4800-8ab0-c55954b3ff0f</messageId>
+ <rollback>
+ <cloudSiteId>mtwnj1a</cloudSiteId>
+ <messageId>255ca199-7f53-4800-8ab0-c55954b3ff0f</messageId>
+ <msoRequest/>
+ <tenantId>c2141e3fcae940fcb4797ec9115e5a7a</tenantId>
+ <vfModuleCreated>true</vfModuleCreated>
+ <vfModuleId>b70a3ba5-d172-4e9e-98f6-39516446b25b</vfModuleId>
+ <vfModuleStackId>USISTDMTWNJVVHP529_migrated.base.module-0/hnportal-1902-1214-1217-144843702565</vfModuleStackId>
+ <vnfId>USISTDMTWNJVVHP529_migrated.base.module-0/hnportal-1902-1214-1217-144843702565</vnfId>
+ </rollback>
+ <vfModuleCreated>true</vfModuleCreated>
+ <vfModuleId>b70a3ba5-d172-4e9e-98f6-39516446b25b</vfModuleId>
+ <vfModuleOutputs/>
+ <vfModuleStackId>USISTDMTWNJVVHP529_migrated.base.module-0/hnportal-1902-1214-1217-144843702565</vfModuleStackId>
+ <vnfId>e64e62e1-7c02-4148-ad9c-e51406da508a</vnfId>
+</createVfModuleResponse> \ No newline at end of file