diff options
Diffstat (limited to 'adapters')
12 files changed, 91 insertions, 49 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java new file mode 100644 index 0000000000..86be9ec3d8 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java @@ -0,0 +1,36 @@ +package org.onap.so.openstack.beans; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class CreateStackRequest { + + @JsonProperty("parameters") + private Map<String, Object> parameters; + + @JsonProperty("environment") + private String environment; + + public Map<String, Object> getParameters() { + return parameters; + } + + public void setParameters(Map<String, Object> parameters) { + this.parameters = parameters; + } + + public String getEnvironment() { + return environment; + } + + public void setEnvironment(String environment) { + this.environment = environment; + } + + @Override + public String toString() { + return "CreateStackRequest [parameters=" + parameters + ", environment=" + environment + "]"; + } + + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index 28d4f3f9b4..1d75892138 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -55,6 +55,7 @@ import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; +import org.onap.so.openstack.beans.CreateStackRequest; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; @@ -354,7 +355,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { try { ObjectMapper mapper = new ObjectMapper(); InfraActiveRequests foundRequest = requestDBClient.getInfraActiveRequestbyRequestId(requestId); - String stackRequest = mapper.writeValueAsString(request.getParameters()); + CreateStackRequest createStackRequest = new CreateStackRequest(); + createStackRequest.setEnvironment(request.getEnvironment()); + createStackRequest.setParameters(request.getParameters()); + String stackRequest = mapper.writeValueAsString(createStackRequest); CloudApiRequests cloudReq = new CloudApiRequests(); cloudReq.setCloudIdentifier(stackName); cloudReq.setRequestBody(stackRequest); diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java index 687b7d8d2f..e840d5affd 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java @@ -48,10 +48,12 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.db.request.beans.CloudApiRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.openstack.beans.CreateStackRequest; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.exceptions.MsoOpenstackException; import org.onap.so.openstack.exceptions.MsoStackAlreadyExists; import org.springframework.core.env.Environment; +import com.fasterxml.jackson.databind.ObjectMapper; import com.woorea.openstack.base.client.OpenStackResponseException; import com.woorea.openstack.heat.Heat; import com.woorea.openstack.heat.StackResource; @@ -415,11 +417,22 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { @Test public final void saveStack_Test() throws MsoException, IOException, NovaClientException { + CreateStackParam createStackParam = new CreateStackParam(); createStackParam.setStackName("stackName"); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("test", "value"); + String environment = + "parameters:\n mmn_volume_name_1: \"data-mn-v-vdb\"\n mmn_volume_name_2: \"arch-mn-v-vdc\"\n"; createStackParam.setParameters(parameters); + createStackParam.setEnvironment(environment); + + CreateStackRequest createStackRequest = new CreateStackRequest(); + createStackRequest.setEnvironment(environment); + createStackRequest.setParameters(parameters); + ObjectMapper mapper = new ObjectMapper(); + String stackRequest = mapper.writeValueAsString(createStackRequest); + InfraActiveRequests request = new InfraActiveRequests(); request.setRequestId("requestId"); doReturn(request).when(requestDbClient).getInfraActiveRequestbyRequestId("requestId"); @@ -427,7 +440,8 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { heatUtils.saveStackRequest(createStackParam, "requestId", "stackName"); Mockito.verify(requestDbClient, times(1)).updateInfraActiveRequests(request); assertNotNull(request.getCloudApiRequests().get(0)); - assertEquals(request.getCloudApiRequests().get(0).getRequestId(), "requestId"); + assertEquals("requestId", request.getCloudApiRequests().get(0).getRequestId()); + assertEquals(stackRequest, request.getCloudApiRequests().get(0).getRequestBody()); } @Test diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java index a0d822d394..0b8de60a81 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java @@ -3,6 +3,8 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Modifications Copyright (C) 2019 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,10 +27,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import javax.xml.bind.annotation.XmlRootElement; -import org.onap.so.db.catalog.beans.InstanceGroup; -import org.onap.so.db.catalog.beans.VFCInstanceGroup; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.slf4j.Logger; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml b/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml index bcf5429789..1487cb21b2 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml +++ b/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml @@ -41,6 +41,8 @@ spring: jackson: serialization: fail-on-empty-beans: false + main: + allow-bean-definition-overriding: true #Actuator management: 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: diff --git a/adapters/mso-requests-db-adapter/src/main/resources/application.yaml b/adapters/mso-requests-db-adapter/src/main/resources/application.yaml index 7234733b95..17b014b993 100644 --- a/adapters/mso-requests-db-adapter/src/main/resources/application.yaml +++ b/adapters/mso-requests-db-adapter/src/main/resources/application.yaml @@ -47,6 +47,8 @@ spring: username: mso_admin password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' role: ACTUATOR + main: + allow-bean-definition-overriding: true #Actuator management: diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java index a68bd3e0be..5697ed56a5 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java @@ -88,11 +88,9 @@ public class SDNCServiceRequestTask { String xml = genSdncReq(request, mappedTunables); - long sdncStartTime = System.currentTimeMillis(); SDNCResponseCommon response = connector.send(xml, mappedTunables); - long bpStartTime = System.currentTimeMillis(); - boolean callbackSuccess = bpRestCallback.send(request.getBPNotificationUrl(), response.toJson()); + bpRestCallback.send(request.getBPNotificationUrl(), response.toJson()); } private Element addChild(Element parent, String tag) { diff --git a/adapters/mso-sdnc-adapter/src/main/resources/application.yaml b/adapters/mso-sdnc-adapter/src/main/resources/application.yaml index 9be0a257c9..2ef721fca5 100644 --- a/adapters/mso-sdnc-adapter/src/main/resources/application.yaml +++ b/adapters/mso-sdnc-adapter/src/main/resources/application.yaml @@ -11,6 +11,10 @@ mso: max-pool-size: 50 queue-capacity: 500 +spring: + main: + allow-bean-definition-overriding: true + #Actuator management: endpoints: diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java index cff36061b1..2dcdf11316 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java @@ -28,8 +28,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; /** @@ -44,8 +42,6 @@ import org.springframework.stereotype.Component; @Component public class HealthCheckHandler { - private static Logger logger = LoggerFactory.getLogger(HealthCheckHandler.class); - private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>"; |