aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
authorMarcus Williams <marcus.williams@intel.com>2019-05-03 18:01:07 +0000
committerGerrit Code Review <gerrit@onap.org>2019-05-03 18:01:07 +0000
commit00b2538b48034dfb220a8ef179fb9627f93cb827 (patch)
tree90c775312003c132744aa88b78f3939e101860ed /adapters
parent38cefe5dd2658490d00a0575f38179092668f118 (diff)
parenta16bf8f9315060822c16ec92a0532b8375c1a399 (diff)
Merge "Merge remote-tracking branch 'origin/dublin'"
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java2
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/StackInfoMapper.java1
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java10
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java20
4 files changed, 31 insertions, 2 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index dc5ff0dcca..1db0411f7c 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -339,7 +339,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
workloadStack = JSON_MAPPER.treeToValue(node.at("/stacks/0"), Stack.class);
} else {
workloadStack = new Stack();
- workloadStack.setStackStatus(HeatStatus.NOTFOUND.toString());
+ workloadStack.setStackStatus("NOT_FOUND");
}
} catch (Exception e) {
logger.debug("Multicloud Get Exception mapping /stack/0: {} ", node.toString(), e);
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/StackInfoMapper.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/StackInfoMapper.java
index 8efa48ce79..d830e706f7 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/StackInfoMapper.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/StackInfoMapper.java
@@ -95,5 +95,6 @@ public class StackInfoMapper {
heatStatusMap.put("UPDATE_IN_PROGRESS", HeatStatus.UPDATING);
heatStatusMap.put("UPDATE_FAILED", HeatStatus.FAILED);
heatStatusMap.put("UPDATE_COMPLETE", HeatStatus.UPDATED);
+ heatStatusMap.put("NOT_FOUND", HeatStatus.NOTFOUND);
}
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
index b4cdcb45e2..74cf7c38c9 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
@@ -7,7 +7,7 @@
* 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
@@ -48,6 +48,7 @@ public class CreateInventoryTask {
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
setupMDC(externalTask);
boolean success = true;
+ boolean inventoryException = false;
String auditInventoryString = externalTask.getVariable("auditInventoryResult");
AAIObjectAuditList auditInventory = null;
try {
@@ -61,6 +62,10 @@ public class CreateInventoryTask {
logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", auditInventory,
externalTask.getRetries());
createInventory.createInventory(auditInventory);
+ } catch (InventoryException e) {
+ logger.error("Error during inventory of stack", e);
+ success = false;
+ inventoryException = true;
} catch (Exception e) {
logger.error("Error during inventory of stack", e);
success = false;
@@ -68,6 +73,9 @@ public class CreateInventoryTask {
if (success) {
externalTaskService.complete(externalTask);
logger.debug("The External Task Id: {} Successful", externalTask.getId());
+ } else if (inventoryException) {
+ logger.debug("The External Task Id: {} Failed, Retry not needed", externalTask.getId());
+ externalTaskService.handleBpmnError(externalTask, "AAIInventoryFailure");
} else {
if (externalTask.getRetries() == null) {
logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}",
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java
index 03622db655..8513f30d4b 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java
@@ -10,6 +10,10 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.so.objects.audit.AAIObjectAudit;
+import org.onap.so.objects.audit.AAIObjectAuditList;
+import com.fasterxml.jackson.core.JsonProcessingException;
public class CreateInventoryTaskTest {
@@ -17,6 +21,9 @@ public class CreateInventoryTaskTest {
ExternalTask externalTask;
@Mock
+ CreateAAIInventory createAAIInventory;
+
+ @Mock
ExternalTaskService externalTaskService;
@InjectMocks
@@ -33,4 +40,17 @@ public class CreateInventoryTaskTest {
inventoryTask.executeExternalTask(externalTask, externalTaskService);
Mockito.verify(externalTaskService, times(1)).handleBpmnError(externalTask, "AAIInventoryFailure");
}
+
+ @Test
+ public void testExecuteExternalTask_InventoryException() throws InventoryException, JsonProcessingException {
+ AAIObjectAuditList object = new AAIObjectAuditList();
+ AAIObjectAudit e = new AAIObjectAudit();
+ e.setDoesObjectExist(true);
+ object.getAuditList().add(e);
+ GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
+ doReturn(objectMapper.getMapper().writeValueAsString(e)).when(externalTask).getVariable("auditInventoryResult");
+ Mockito.doThrow(InventoryException.class).when(createAAIInventory).createInventory(Mockito.any());
+ inventoryTask.executeExternalTask(externalTask, externalTaskService);
+ Mockito.verify(externalTaskService, times(1)).handleBpmnError(externalTask, "AAIInventoryFailure");
+ }
}