summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/main/java
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-14 19:54:00 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-14 19:55:59 -0500
commitf950d102e204be4f23b675997648c370ad2c0c3b (patch)
treebc2adc620f5c82625c7ec6605f45b313344cbf70 /adapters/mso-openstack-adapters/src/main/java
parent1d69925fef5c972f045081db9b5e4795d96c6f84 (diff)
fix issue where we attempt audit with no servers
fix issue where we attempt audit with no servers Change-Id: I47f76121c616bf65a5f8be73910adcc0d7088bdb Issue-ID: SO-1513 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-openstack-adapters/src/main/java')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java8
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java12
3 files changed, 17 insertions, 5 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
index 38b00688a7..aace75ff99 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
@@ -60,7 +60,7 @@ public class AuditStackService {
auth);
ExternalTaskClient client = ExternalTaskClient.create()
.baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(5).addInterceptor(interceptor)
- .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
+ .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(5000, 2, 30000)).build();
client.subscribe("InventoryAudit").lockDuration(5000)
.handler(auditStack::executeExternalTask).open();
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java
index b0369395ed..ffbe1b4c46 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java
@@ -24,9 +24,11 @@ import java.util.Collections;
import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.audit.beans.AuditInventory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@@ -49,6 +51,7 @@ public class AuditStackServiceData {
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService){
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
+ setupMDC(externalTask);
boolean success = false;
try {
logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries());
@@ -78,6 +81,11 @@ public class AuditStackServiceData {
}
+ private void setupMDC(ExternalTask externalTask) {
+ String msoRequestId = (String)externalTask.getVariable("mso-request-id");
+ if(msoRequestId != null && !msoRequestId.isEmpty())
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
+ }
protected long calculateRetryDelay(int currentRetries){
int retrySequence = RETRY_SEQUENCE.length - currentRetries;
long retryMultiplier = Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier","6000"));
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java
index dfe5912fbf..da833c7b07 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java
@@ -65,10 +65,14 @@ public class HeatStackAudit {
.filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
List<Resource> resourceGroups = resources.getList().stream()
.filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")).collect(Collectors.toList());
- Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources);
- Set<Vserver> vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups,
- vserversToAudit);
- return auditVservers.auditVservers(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion);
+ if(novaResources.isEmpty())
+ return true;
+ else{
+ Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources);
+ Set<Vserver> vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups,
+ vserversToAudit);
+ return auditVservers.auditVservers(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion);
+ }
} catch (Exception e) {
logger.error("Error during auditing stack resources", e);
return false;