summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-openstack-adapters/src')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java5
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java5
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java5
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java5
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java12
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java47
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application.yaml2
8 files changed, 44 insertions, 41 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
index 7500097b6a..8edce124ec 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
@@ -87,9 +87,12 @@ public abstract class AbstractAuditService {
}
protected void setupMDC(ExternalTask externalTask) {
+ logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
String msoRequestId = externalTask.getVariable("mso-request-id");
- if (msoRequestId != null && !msoRequestId.isEmpty())
+ if (msoRequestId != null && !msoRequestId.isEmpty()) {
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
+ }
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName());
}
protected long calculateRetryDelay(int currentRetries) {
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
index 77229919cd..1e5b6de857 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
@@ -27,6 +27,7 @@ import java.util.Map;
import java.util.Optional;
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.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.objects.audit.AAIObjectAuditList;
@@ -48,9 +49,9 @@ public class AuditCreateStackService extends AbstractAuditService {
public Environment environment;
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ setupMDC(externalTask);
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
Map<String, Object> variables = new HashMap<>();
- setupMDC(externalTask);
boolean success = false;
try {
logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,
@@ -71,6 +72,7 @@ public class AuditCreateStackService extends AbstractAuditService {
if (success) {
externalTaskService.complete(externalTask, variables);
logger.debug("The External Task Id: {} Successful", externalTask.getId());
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
if (externalTask.getRetries() == null) {
logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}",
@@ -80,6 +82,7 @@ public class AuditCreateStackService extends AbstractAuditService {
} else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) {
logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId());
externalTaskService.complete(externalTask, variables);
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ",
externalTask.getId(), externalTask.getRetries() - 1,
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java
index b99eaa98d9..0aa4f9bdc3 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java
@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.Optional;
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.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.objects.audit.AAIObjectAuditList;
@@ -52,9 +53,9 @@ public class AuditDeleteStackService extends AbstractAuditService {
protected Environment env;
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ setupMDC(externalTask);
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
Map<String, Object> variables = new HashMap<>();
- setupMDC(externalTask);
boolean success = false;
try {
logger.info("Executing External Task Delete Audit Inventory. Retry Number: {}", externalTask.getRetries());
@@ -79,6 +80,7 @@ public class AuditDeleteStackService extends AbstractAuditService {
if (success) {
externalTaskService.complete(externalTask, variables);
logger.debug("The External Task Id: {} Successful", externalTask.getId());
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
if (externalTask.getRetries() == null) {
logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}",
@@ -88,6 +90,7 @@ public class AuditDeleteStackService extends AbstractAuditService {
} else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) {
logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId());
externalTaskService.complete(externalTask, variables);
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ",
externalTask.getId(), externalTask.getRetries() - 1,
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java
index c8ac9d1a58..2ef7d5b325 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java
@@ -5,6 +5,7 @@ import java.util.Map;
import java.util.Optional;
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.onap.so.objects.audit.AAIObjectAuditList;
import org.slf4j.Logger;
@@ -24,8 +25,8 @@ public class AuditQueryStackService extends AbstractAuditService {
protected AuditDataService auditDataService;
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
- AuditInventory auditInventory = externalTask.getVariable("auditInventory");
setupMDC(externalTask);
+ AuditInventory auditInventory = externalTask.getVariable("auditInventory");
boolean success = false;
Map<String, Object> variables = new HashMap<>();
try {
@@ -42,6 +43,7 @@ public class AuditQueryStackService extends AbstractAuditService {
if (success) {
externalTaskService.complete(externalTask, variables);
logger.debug("The External Task {} was Successful", externalTask.getId());
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
if (externalTask.getRetries() == null) {
logger.debug("The External Task {} Failed. Setting Retries to Default Start Value: {}",
@@ -51,6 +53,7 @@ public class AuditQueryStackService extends AbstractAuditService {
} else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) {
logger.debug("The External Task {} Failed. All Retries Exhausted", externalTask.getId());
externalTaskService.complete(externalTask, variables);
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
logger.debug("The External Task {} Failed. Decrementing Retries to {} , Retry Delay: ",
externalTask.getId(), externalTask.getRetries() - 1,
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 c106591b25..a6c61704ad 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
@@ -77,6 +77,7 @@ public class CreateInventoryTask {
if (success) {
externalTaskService.complete(externalTask);
logger.debug("The External Task Id: {} Successful", externalTask.getId());
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else if (inventoryException) {
logger.debug("The External Task Id: {} Failed, Retry not needed", externalTask.getId());
externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
@@ -89,6 +90,7 @@ public class CreateInventoryTask {
} else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) {
logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId());
externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ",
externalTask.getId(), externalTask.getRetries() - 1,
@@ -107,6 +109,8 @@ public class CreateInventoryTask {
private void setupMDC(ExternalTask externalTask) {
try {
+ logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName());
String msoRequestId = externalTask.getVariable("mso-request-id");
if (msoRequestId != null && !msoRequestId.isEmpty())
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
index 34177ff5a3..3c073af6ba 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
@@ -48,10 +48,10 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-import org.springframework.http.client.BufferingClientHttpRequestFactory;
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
+import org.onap.so.client.RestTemplateConfig;
+import javax.inject.Provider;
@Component
public class ValetClient {
@@ -75,6 +75,9 @@ public class ValetClient {
private static final String BODY = ", body=";
@Autowired
private ObjectMapper mapper;
+ @Autowired
+ private Provider<RestTemplate> templateProvider;
+
protected String baseUrl;
protected String basePath;
@@ -123,10 +126,7 @@ public class ValetClient {
}
private RestTemplate getRestTemplate() {
- RestTemplate restTemplate = new RestTemplate();
- restTemplate
- .setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()));
- return restTemplate;
+ return templateProvider.get();
}
/*
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
index c22bb327d4..2d77bf625a 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
@@ -187,11 +187,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
Holder<Map<String, String>> outputs) throws VnfException {
logger.debug("Querying VNF " + vnfNameOrId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
- long subStartTime = System.currentTimeMillis();
-
- VduInstance vduInstance = null;
+ VduInstance vduInstance;
CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null);
VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
@@ -252,7 +248,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
*/
@Override
public void rollbackVnf(VnfRollback rollback) throws VnfException {
- long startTime = System.currentTimeMillis();
// rollback may be null (e.g. if stack already existed when Create was called)
if (rollback == null) {
logger.info(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_NULL.toString(), "OpenStack", "rollbackVnf");
@@ -279,7 +274,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Use the VduPlugin to delete the VF Module.
VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
- long subStartTime = System.currentTimeMillis();
try {
// TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object
// and use that.
@@ -336,7 +330,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
logger.debug("Unable to convert " + inputValue + " to an integer!", e);
return null;
}
- } else if (type.equalsIgnoreCase("json")) {
+ } else if ("json".equalsIgnoreCase(type)) {
try {
JsonNode jsonNode = JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(inputValue));
return jsonNode;
@@ -344,7 +338,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
logger.debug("Unable to convert " + inputValue + " to a JsonNode!", e);
return null;
}
- } else if (type.equalsIgnoreCase("boolean")) {
+ } else if ("boolean".equalsIgnoreCase(type)) {
return new Boolean(inputValue.toString());
}
@@ -353,7 +347,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
}
private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) {
- Map<String, String> stringOutputs = new HashMap<String, String>();
+ Map<String, String> stringOutputs = new HashMap<>();
for (String key : stackOutputs.keySet()) {
if (stackOutputs.get(key) instanceof String) {
stringOutputs.put(key, (String) stackOutputs.get(key));
@@ -447,7 +441,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
if (objectMap == null) {
return null;
}
- Map<String, String> stringMap = new HashMap<String, String>();
+ Map<String, String> stringMap = new HashMap<>();
for (String key : objectMap.keySet()) {
if (!stringMap.containsKey(key)) {
Object obj = objectMap.get(key);
@@ -540,8 +534,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
String volumeGroupId, String baseVfModuleId, String modelCustomizationUuid, Map<String, Object> inputs,
Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException {
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
// Require a model customization ID. Every VF Module definition must have one.
if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) {
@@ -665,7 +657,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Use the VduPlugin.
VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
- long subStartTime1 = System.currentTimeMillis();
try {
vduInstance = vduPlugin.queryVdu(cloudInfo, vfModuleName);
} catch (VduException me) {
@@ -761,8 +752,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// If a Volume Group was provided, query its outputs for inclusion in Module input parameters
if (volumeGroupId != null) {
- long subStartTime2 = System.currentTimeMillis();
- VduInstance volumeVdu = null;
+ VduInstance volumeVdu;
try {
volumeVdu = vduPlugin.queryVdu(cloudInfo, volumeGroupId);
} catch (VduException me) {
@@ -811,8 +801,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
}
if (baseVfModuleId != null) {
- long subStartTime2 = System.currentTimeMillis();
- VduInstance baseVdu = null;
+ VduInstance baseVdu;
try {
baseVdu = vduPlugin.queryVdu(cloudInfo, baseVfModuleId);
} catch (MsoException me) {
@@ -887,19 +876,19 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Create the combined set of parameters from the incoming request, base-module outputs,
// volume-module outputs. Also, convert all variables to their native object types.
- HashMap<String, Object> goldenInputs = new HashMap<String, Object>();
- List<String> extraInputs = new ArrayList<String>();
+ HashMap<String, Object> goldenInputs = new HashMap<>();
+ List<String> extraInputs = new ArrayList<>();
Boolean skipInputChecks = false;
if (skipInputChecks) {
- goldenInputs = new HashMap<String, Object>();
+ goldenInputs = new HashMap<>();
for (String key : inputs.keySet()) {
goldenInputs.put(key, inputs.get(key));
}
} else {
// Build maps for the parameters (including aliases) to simplify checks
- HashMap<String, HeatTemplateParam> params = new HashMap<String, HeatTemplateParam>();
+ HashMap<String, HeatTemplateParam> params = new HashMap<>();
Set<HeatTemplateParam> paramSet = heatTemplate.getParameters();
logger.debug("paramSet has " + paramSet.size() + " entries");
@@ -909,7 +898,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Include aliases.
String alias = htp.getParamAlias();
- if (alias != null && !alias.equals("") && !params.containsKey(alias)) {
+ if (alias != null && !"".equals(alias) && !params.containsKey(alias)) {
params.put(alias, htp);
}
}
@@ -1026,7 +1015,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// Here we go... ready to deploy the VF Module.
- long instantiateVduStartTime = System.currentTimeMillis();
if (backout == null)
backout = true;
@@ -1088,11 +1076,9 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
logger.debug("Deleting VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
// Capture the output parameters on a delete, so need to query first
- VduInstance vduInstance = null;
+ VduInstance vduInstance;
CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null);
// Use the VduPlugin.
@@ -1123,7 +1109,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
// - a vnfInstance object with status of NOTFOUND (VDU did not exist, treat as success)
// - a vnfInstance object with status of FAILED (error)
// Also, VduException could be thrown.
- long subStartTime = System.currentTimeMillis();
try {
// TODO: Get an appropriate timeout value - require access to the model
vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5);
@@ -1166,11 +1151,11 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
CloudSite cloudSite = cloudSiteOp.get();
String orchestrator = cloudSite.getOrchestrator();
- if (orchestrator.equalsIgnoreCase("CLOUDIFY")) {
+ if ("CLOUDIFY".equalsIgnoreCase(orchestrator)) {
return cloudifyUtils;
- } else if (orchestrator.equalsIgnoreCase("HEAT")) {
+ } else if ("HEAT".equalsIgnoreCase(orchestrator)) {
return heatUtils;
- } else if (orchestrator.equalsIgnoreCase("MULTICLOUD")) {
+ } else if ("MULTICLOUD".equalsIgnoreCase(orchestrator)) {
return multicloudUtils;
} else {
// Default if cloudSite record exists - return HEAT plugin - will fail later
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
index 1c4de2daa1..ba31daaeaf 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
@@ -33,6 +33,8 @@ spring:
ddl-auto: none
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
enable-lazy-load-no-trans: true
+ main:
+ allow-bean-definition-overriding: true
org:
onap:
so: