diff options
Diffstat (limited to 'adapters')
45 files changed, 860 insertions, 1012 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index 9212fbcc6c..f50a6fd1bd 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -1032,14 +1032,14 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ * Normalize an input value to an Object, based on the target parameter type. * If the type is not recognized, it will just be returned unchanged (as a string). */ - public Object convertInputValue (String inputValue, HeatTemplateParam templateParam) + public Object convertInputValue (Object inputValue, HeatTemplateParam templateParam) { String type = templateParam.getParamType(); logger.debug("Parameter: {} is of type {}", templateParam.getParamName(), type); if (type.equalsIgnoreCase("number")) { try { - return Integer.valueOf(inputValue); + return Integer.valueOf(inputValue.toString()); } catch (Exception e) { logger.debug("Unable to convert {} to an integer!", inputValue); @@ -1047,14 +1047,14 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ } } else if (type.equalsIgnoreCase("json")) { try { - return new ObjectMapper().readTree(inputValue); + return JSON_MAPPER.writeValueAsString(inputValue); } catch (Exception e) { logger.debug("Unable to convert {} to a JsonNode!", inputValue); return null; } } else if (type.equalsIgnoreCase("boolean")) { - return new Boolean(inputValue); + return new Boolean(inputValue.toString()); } // Nothing else matched. Return the original string 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 efc232e79e..ee1c79c09c 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 @@ -86,6 +86,24 @@ import org.springframework.context.annotation.Primary; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.woorea.openstack.base.client.OpenStackConnectException; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.base.client.OpenStackResponseException; +import com.woorea.openstack.heat.Heat; +import com.woorea.openstack.heat.model.CreateStackParam; +import com.woorea.openstack.heat.model.Resources; +import com.woorea.openstack.heat.model.Stack; +import com.woorea.openstack.heat.model.Stack.Output; +import com.woorea.openstack.heat.model.Stacks; +import com.woorea.openstack.keystone.Keystone; +import com.woorea.openstack.keystone.model.Access; +import com.woorea.openstack.keystone.model.Authentication; +import com.woorea.openstack.keystone.utils.KeystoneUtils; + @Primary @Component public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ @@ -1005,7 +1023,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ return heatStack.getOutputs(); } - public void copyStringOutputsToInputs(Map<String, String> inputs, + public void copyStringOutputsToInputs(Map<String, Object> inputs, Map<String, Object> otherStackOutputs, boolean overWrite) { if (inputs == null || otherStackOutputs == null) return; @@ -1245,7 +1263,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ * (heat variable type) -> java Object type * string -> String * number -> Integer - * json -> JsonNode XXX Removed with MSO-1475 / 1802 + * json -> marshal object to json * comma_delimited_list -> ArrayList * boolean -> Boolean * if any of the conversions should fail, we will default to adding it to the inputs @@ -1256,7 +1274,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ * @param template the HeatTemplate object - this is so we can also verify if the param is valid for this template * @return HashMap<String, Object> of the inputs, cleaned and converted */ - public Map<String, Object> convertInputMap(Map<String, String> inputs, HeatTemplate template) { + public Map<String, Object> convertInputMap(Map<String, Object> inputs, HeatTemplate template) { HashMap<String, Object> newInputs = new HashMap<>(); HashMap<String, HeatTemplateParam> params = new HashMap<>(); HashMap<String, HeatTemplateParam> paramAliases = new HashMap<>(); @@ -1309,13 +1327,13 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ logger.debug("Parameter: {} is of type {}", key, type); if ("string".equalsIgnoreCase(type)) { // Easiest! - String str = inputs.get(key); + String str = inputs.get(key).toString(); if (alias) newInputs.put(realName, str); else newInputs.put(key, str); } else if ("number".equalsIgnoreCase(type)) { - String integerString = inputs.get(key); + String integerString = inputs.get(key).toString(); Integer anInteger = null; try { anInteger = Integer.parseInt(integerString); @@ -1336,16 +1354,21 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ newInputs.put(key, integerString); } } else if ("json".equalsIgnoreCase(type)) { - // MSO-1475 - Leave this as a string now - String jsonString = inputs.get(key); - logger.debug("Skipping conversion to jsonNode..."); - if (alias) + Object jsonObj = inputs.get(key); + String jsonString; + try { + jsonString = JSON_MAPPER.writeValueAsString(jsonObj); + } catch (JsonProcessingException e) { + logger.error("failed to map to json, directly converting to string instead", e); + jsonString = jsonObj.toString(); + } + if (alias) newInputs.put(realName, jsonString); else newInputs.put(key, jsonString); //} } else if ("comma_delimited_list".equalsIgnoreCase(type)) { - String commaSeparated = inputs.get(key); + String commaSeparated = inputs.get(key).toString(); try { List<String> anArrayList = this.convertCdlToArrayList(commaSeparated); if (alias) @@ -1360,7 +1383,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ newInputs.put(key, commaSeparated); } } else if ("boolean".equalsIgnoreCase(type)) { - String booleanString = inputs.get(key); + String booleanString = inputs.get(key).toString(); Boolean aBool = Boolean.valueOf(booleanString); if (alias) newInputs.put(realName, aBool); @@ -1368,7 +1391,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ newInputs.put(key, aBool); } else { // it's null or something undefined - just add it back as a String - String str = inputs.get(key); + String str = inputs.get(key).toString(); if (alias) newInputs.put(realName, str); else diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java new file mode 100644 index 0000000000..af24975771 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java @@ -0,0 +1,59 @@ +/* + * ============LICENSE_START========================================== + * org.onap.music + * =================================================================== + * 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. + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================= + * ==================================================================== + */ +package org.onap.so.cloud.authentication; + +import static org.junit.Assert.assertEquals; + +import java.util.Calendar; + +import org.junit.Before; +import org.junit.Test; + +public class KeystoneAuthHolderTest { + + private KeystoneAuthHolder keystoneAuthHolder; + private Calendar calendar = Calendar.getInstance(); + + @Before + public void setUp() { + keystoneAuthHolder = new KeystoneAuthHolder(); + } + + @Test + public void testGetId() { + keystoneAuthHolder.setId("001"); + assertEquals("001", keystoneAuthHolder.getId()); + } + + @Test + public void testGetexpiration() { + keystoneAuthHolder.setexpiration(calendar); + assertEquals(calendar, keystoneAuthHolder.getexpiration()); + } + + @Test + public void testGetServiceUrl() { + keystoneAuthHolder.setHeatUrl("testURL"); + assertEquals("testURL", keystoneAuthHolder.getServiceUrl()); + } + +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java index 7c5111bd18..f63aab7ce1 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java @@ -23,7 +23,7 @@ package org.onap.so.cloudify.utils; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -33,7 +33,9 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.fasterxml.jackson.databind.JsonNode; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -52,17 +54,23 @@ import org.onap.so.adapters.vdu.VduModelInfo; import org.onap.so.adapters.vdu.VduStateType; import org.onap.so.adapters.vdu.VduStatus; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloudify.beans.DeploymentInfoBuilder; -import org.onap.so.db.catalog.beans.CloudIdentity; -import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.cloudify.beans.DeploymentInfo; +import org.onap.so.cloudify.beans.DeploymentInfoBuilder; import org.onap.so.cloudify.beans.DeploymentStatus; import org.onap.so.cloudify.v3.client.Cloudify; import org.onap.so.cloudify.v3.model.AzureConfig; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.db.catalog.beans.HeatTemplateParam; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoException; +import org.skyscreamer.jsonassert.JSONAssert; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; public class MsoCloudifyUtilsTest { @@ -282,21 +290,31 @@ public class MsoCloudifyUtilsTest { } @Test - public void convertInputValue_successful() { - MsoCloudifyUtils testedObject = new MsoCloudifyUtils(); - - HeatTemplateParam heatTemplateParam = new HeatTemplateParam(); - heatTemplateParam.setParamType("number"); - Object result = testedObject.convertInputValue("5", heatTemplateParam); - assertTrue(result instanceof Integer); - - heatTemplateParam.setParamType("json"); - Object result2 = testedObject.convertInputValue("{\"key\": \"value\"}", heatTemplateParam); - assertTrue(result2 instanceof JsonNode); + public void convertInputValueTest() throws JsonParseException, JsonMappingException, IOException { + MsoCloudifyUtils utils = new MsoCloudifyUtils(); + ObjectMapper mapper = new ObjectMapper(); + HeatTemplateParam paramNum = new HeatTemplateParam(); + paramNum.setParamType("number"); + paramNum.setParamName("my-number"); + + HeatTemplateParam paramString = new HeatTemplateParam(); + paramString.setParamType("string"); + paramString.setParamName("my-string"); + + HeatTemplateParam paramJson = new HeatTemplateParam(); + paramJson.setParamType("json"); + paramJson.setParamName("my-json"); + + Map<String, Object> jsonMap = mapper.readValue(getJson("free-form.json"), new TypeReference<Map<String, Object>>(){}); + + assertEquals(3, utils.convertInputValue("3", paramNum)); + assertEquals("hello", utils.convertInputValue("hello", paramString)); + JSONAssert.assertEquals(getJson("free-form.json"), utils.convertInputValue(jsonMap, paramJson).toString(), false); + + } - heatTemplateParam.setParamType("boolean"); - Object result3 = testedObject.convertInputValue("true", heatTemplateParam); - assertTrue(result3 instanceof Boolean); + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/MsoHeatUtils/" + filename))); } private void mockCloudConfig(MsoCloudifyUtils testedObjectSpy) { diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsUnitTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsUnitTest.java new file mode 100644 index 0000000000..40bbe90218 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsUnitTest.java @@ -0,0 +1,67 @@ +package org.onap.so.openstack.utils; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.junit.Test; +import org.onap.so.db.catalog.beans.HeatTemplate; +import org.onap.so.db.catalog.beans.HeatTemplateParam; +import org.skyscreamer.jsonassert.JSONAssert; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class MsoHeatUtilsUnitTest { + + + private ObjectMapper mapper = new ObjectMapper(); + @Test + public void convertInputMapTest() throws JsonParseException, JsonMappingException, IOException { + MsoHeatUtils utils = new MsoHeatUtils(); + + Map<String, Object> input = new HashMap<>(); + HeatTemplate template = new HeatTemplate(); + template.setArtifactUuid("my-uuid"); + Set<HeatTemplateParam> parameters = template.getParameters(); + HeatTemplateParam paramNum = new HeatTemplateParam(); + paramNum.setParamType("number"); + paramNum.setParamName("my-number"); + input.put("my-number", "3"); + + HeatTemplateParam paramString = new HeatTemplateParam(); + paramString.setParamType("string"); + paramString.setParamName("my-string"); + input.put("my-string", "hello"); + + HeatTemplateParam paramJson = new HeatTemplateParam(); + paramJson.setParamType("json"); + paramJson.setParamName("my-json"); + + Map<String, Object> jsonMap = mapper.readValue(getJson("free-form.json"), new TypeReference<Map<String, Object>>(){}); + input.put("my-json", jsonMap); + + parameters.add(paramNum); + parameters.add(paramString); + parameters.add(paramJson); + + Map<String, Object> output = utils.convertInputMap(input, template); + + assertEquals(3, output.get("my-number")); + assertEquals("hello", output.get("my-string")); + JSONAssert.assertEquals(getJson("free-form.json"), (String)output.get("my-json"), false); + } + + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/MsoHeatUtils/" + filename))); + } + +} diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/MsoHeatUtils/free-form.json b/adapters/mso-adapter-utils/src/test/resources/__files/MsoHeatUtils/free-form.json new file mode 100644 index 0000000000..3efe43682d --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/resources/__files/MsoHeatUtils/free-form.json @@ -0,0 +1,7 @@ +{ + "a" : "value", + "b" : { + "my-key" : "my-value", + "array" : [1, 3, 4] + } +}
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java index a383aac77f..c62dc0dfbf 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java @@ -58,7 +58,7 @@ public class CreateVfModuleRequest extends VfRequestCommon { private Boolean backout = true; private Boolean enableBridge; - private Map<String, String> vfModuleParams = new HashMap<>(); + private Map<String, Object> vfModuleParams = new HashMap<>(); private MsoRequest msoRequest = new MsoRequest(); public String getCloudSiteId() { @@ -189,11 +189,11 @@ public class CreateVfModuleRequest extends VfRequestCommon { this.backout = backout; } - public Map<String, String> getVfModuleParams() { + public Map<String, Object> getVfModuleParams() { return vfModuleParams; } - public void setVfModuleParams(Map<String, String> vfModuleParams) { + public void setVfModuleParams(Map<String, Object> vfModuleParams) { this.vfModuleParams = vfModuleParams; } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVolumeGroupRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVolumeGroupRequest.java index 698b2ccebe..214abd4e9d 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVolumeGroupRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVolumeGroupRequest.java @@ -41,7 +41,7 @@ public class CreateVolumeGroupRequest extends VfRequestCommon { private String vnfVersion; private String vfModuleType; private String modelCustomizationUuid; - private Map<String,String> volumeGroupParams = new HashMap<>(); + private Map<String,Object> volumeGroupParams = new HashMap<>(); private Boolean failIfExists; private Boolean enableBridge; private Boolean suppressBackout; @@ -91,11 +91,11 @@ public class CreateVolumeGroupRequest extends VfRequestCommon { this.vfModuleType = vfModuleType; } - public Map<String, String> getVolumeGroupParams() { + public Map<String, Object> getVolumeGroupParams() { return volumeGroupParams; } - public void setVolumeGroupParams(Map<String, String> volumeGroupParams) { + public void setVolumeGroupParams(Map<String, Object> volumeGroupParams) { this.volumeGroupParams = volumeGroupParams; } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/UpdateVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/UpdateVfModuleRequest.java index 0fb5c05e2a..1c7696a79b 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/UpdateVfModuleRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/UpdateVfModuleRequest.java @@ -58,7 +58,7 @@ public class UpdateVfModuleRequest extends VfRequestCommon { private Boolean failIfExists; private Boolean backout; - private Map<String,String> vfModuleParams = new HashMap<>(); + private Map<String,Object> vfModuleParams = new HashMap<>(); private MsoRequest msoRequest = new MsoRequest(); public String getCloudSiteId() { @@ -197,11 +197,11 @@ public class UpdateVfModuleRequest extends VfRequestCommon { this.backout = backout; } - public Map<String, String> getVfModuleParams() { + public Map<String, Object> getVfModuleParams() { return vfModuleParams; } - public void setVfModuleParams(Map<String, String> vfModuleParams) { + public void setVfModuleParams(Map<String, Object> vfModuleParams) { this.vfModuleParams = vfModuleParams; } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/UpdateVolumeGroupRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/UpdateVolumeGroupRequest.java index d9f83aad2f..8ddef1eeaf 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/UpdateVolumeGroupRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/UpdateVolumeGroupRequest.java @@ -41,7 +41,7 @@ public class UpdateVolumeGroupRequest extends VfRequestCommon { private String vnfVersion; private String vfModuleType; private String modelCustomizationUuid; - private Map<String,String> volumeGroupParams = new HashMap<>(); + private Map<String,Object> volumeGroupParams = new HashMap<>(); private MsoRequest msoRequest = new MsoRequest(); public UpdateVolumeGroupRequest() { @@ -112,11 +112,11 @@ public class UpdateVolumeGroupRequest extends VfRequestCommon { this.modelCustomizationUuid = modelCustomizationUuid; } - public Map<String, String> getVolumeGroupParams() { + public Map<String, Object> getVolumeGroupParams() { return volumeGroupParams; } - public void setVolumeGroupParams(Map<String, String> volumeGroupParams) { + public void setVolumeGroupParams(Map<String, Object> volumeGroupParams) { this.volumeGroupParams = volumeGroupParams; } diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index dbfc5b7f6b..390c775cb2 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -153,10 +153,6 @@ </dependency> <dependency> <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-jdbc</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/application-local.yaml b/adapters/mso-catalog-db-adapter/src/main/resources/application-local.yaml index 078e22b8ee..d7c13eaa14 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/application-local.yaml +++ b/adapters/mso-catalog-db-adapter/src/main/resources/application-local.yaml @@ -13,15 +13,7 @@ mso: endpoint: http://localhost:8090 db: auth: Basic YnBlbDptc28tZGItMTUwNyE= - spring: - datasource: - jdbc-url: jdbc:mariadb://localhost:3306/catalogdb - username: catalog - password: catalog123 - driver-class-name: org.mariadb.jdbc.Driver - initialization-mode: never - security: usercredentials: - @@ -40,8 +32,4 @@ spring: server: port: 8090 -flyway: - baseline-on-migrate: false - jdbc-url: jdbc:mariadb://localhost:3306/catalogdb - user: catalog - password: catalog123 + 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 0977bf95fb..aa9317c920 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml +++ b/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml @@ -16,7 +16,7 @@ mso: spring: datasource: - jdbcUrl: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb + url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb username: ${DB_USERNAME} password: ${DB_PASSWORD} driver-class-name: org.mariadb.jdbc.Driver diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 12aee67a74..f2f411d5b6 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -13,8 +13,8 @@ <build> <finalName>${project.artifactId}-${project.version}</finalName> - - <plugins> + + <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> @@ -36,75 +36,25 @@ </executions> </plugin> -<!-- run the following plugin only when there's a wsdl change and you need to recompile the java classes + <!-- run the following plugin only when there's a wsdl change and you + need to recompile the java classes <plugin> <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxws-maven-plugin</artifactId> <version>2.4.1</version> <executions> + <execution> <id>generate-network-async-stubs</id> <phase>process-classes</phase> + <goals> <goal>wsimport</goal> </goals> <configuration> <vmArgs> <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> + </vmArgs> <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> <wsdlFiles> + <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile> </wsdlFiles> <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation> + <packageName>org.onap.so.adapters.network.async.client</packageName> <xnocompile>false</xnocompile> + <keep>true</keep> </configuration> </execution> <execution> <id>generate-vnf-async-stubs</id> + <phase>process-classes</phase> <goals> <goal>wsimport</goal> </goals> <configuration> + <vmArgs> <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> </vmArgs> <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> + <wsdlFiles> <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile> </wsdlFiles> <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation> + <packageName>org.onap.so.adapters.vnf.async.client</packageName> <xnocompile>false</xnocompile> + <keep>true</keep> </configuration> </execution> </executions> </plugin> <plugin> + <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> + <version>3.0.0</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> + <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>${project.build.directory}/generated-sources/wsimport/</source> + </sources> </configuration> </execution> </executions> </plugin> --> <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>jaxws-maven-plugin</artifactId> - <version>2.4.1</version> - <executions> - <execution> - <id>generate-network-async-stubs</id> - <phase>process-classes</phase> - <goals> - <goal>wsimport</goal> - </goals> - <configuration> - <vmArgs> - <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> - </vmArgs> - <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> - <wsdlFiles> - <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile> - </wsdlFiles> - <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation> - <packageName>org.onap.so.adapters.network.async.client</packageName> - <xnocompile>false</xnocompile> - <keep>true</keep> - </configuration> - </execution> - - <execution> - <id>generate-vnf-async-stubs</id> - <phase>process-classes</phase> - <goals> - <goal>wsimport</goal> - </goals> - <configuration> - <vmArgs> - <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> - </vmArgs> - <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> - <wsdlFiles> - <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile> - </wsdlFiles> - <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation> - <packageName>org.onap.so.adapters.vnf.async.client</packageName> - <xnocompile>false</xnocompile> - <keep>true</keep> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <id>add-source</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${project.build.directory}/generated-sources/wsimport/</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> </plugin> @@ -126,12 +76,12 @@ </execution> </executions> </plugin> - </plugins> - - + </plugins> + + <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings + <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> @@ -168,10 +118,10 @@ </build> <dependencies> - <!-- added for spring boot support --> + <!-- added for spring boot support --> <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -180,21 +130,11 @@ <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> - <exclusions> - <exclusion> - <groupId>org.apache.tomcat</groupId> - <artifactId>tomcat-jdbc</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> @@ -202,32 +142,31 @@ <version>${cxf.version}</version> </dependency> <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-service-description-swagger</artifactId> + <version>${cxf.version}</version> </dependency> <dependency> - <groupId>org.webjars</groupId> - <artifactId>swagger-ui</artifactId> - <version>3.5.0</version> - </dependency> - + <groupId>org.webjars</groupId> + <artifactId>swagger-ui</artifactId> + <version>3.5.0</version> + </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>janino</groupId> - <artifactId>janino</artifactId> - <version>2.5.15</version> + <groupId>janino</groupId> + <artifactId>janino</artifactId> + <version>2.5.15</version> </dependency> - - <!-- end added for spring boot support --> - - - - <!-- added for unit testing --> + + <!-- end added for spring boot support --> + + + + <!-- added for unit testing --> <dependency> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> @@ -242,23 +181,23 @@ <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>test</scope> - </dependency> + </dependency> <dependency> <groupId>org.mariadb.jdbc</groupId> <artifactId>mariadb-java-client</artifactId> - </dependency> + </dependency> <dependency> <groupId>org.onap.so</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>ch.vorburger.mariaDB4j</groupId> - <artifactId>mariaDB4j</artifactId> - <version>2.2.3</version> - <scope>test</scope> - </dependency> - <dependency> + <groupId>ch.vorburger.mariaDB4j</groupId> + <artifactId>mariaDB4j</artifactId> + <version>2.2.3</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-contract-wiremock</artifactId> <version>1.2.4.RELEASE</version> @@ -271,13 +210,13 @@ </dependency> <dependency> <groupId>org.onap.so.libs.openstack-java-sdk</groupId> - <artifactId>nova-model</artifactId> + <artifactId>nova-model</artifactId> <version>${openstack.version}</version> </dependency> <dependency> - <groupId>org.camunda.bpm</groupId> - <artifactId>camunda-external-task-client</artifactId> - <version>1.2.0-SNAPSHOT</version> - </dependency> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-external-task-client</artifactId> + <version>1.0.0</version> + </dependency> </dependencies> </project> 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 aace75ff99..499c1137c7 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 @@ -59,9 +59,9 @@ public class AuditStackService { ClientRequestInterceptor interceptor = new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), auth); ExternalTaskClient client = ExternalTaskClient.create() - .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(5).addInterceptor(interceptor) - .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(5000, 2, 30000)).build(); - client.subscribe("InventoryAudit").lockDuration(5000) + .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor) + .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(10000, 2, 120000)).build(); + client.subscribe("InventoryAudit").lockDuration(60000) .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 d1f952c829..773705d566 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 @@ -72,7 +72,7 @@ public class AuditStackServiceData { }else if(externalTask.getRetries() != null && externalTask.getRetries()-1 == 0){ logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId()); - externalTaskService.handleBpmnError(externalTask, "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory"); + externalTaskService.handleBpmnError(externalTask, "AuditAAIInventoryFailure"); }else{ logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(),externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java index 46fb651afe..613ab0d2f9 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -21,15 +23,17 @@ package org.onap.so.adapters.network; -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; - import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ContrailPolicyRef { - private static final MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, ContrailPolicyRef.class); + + private static final Logger logger = LoggerFactory.getLogger(ContrailPolicyRef.class); @JsonProperty("network_policy_refs_data_sequence") private ContrailPolicyRefSeq seq; @@ -44,7 +48,8 @@ public class ContrailPolicyRef { } catch (Exception e) { - logger.error (MessageEnum.RA_MARSHING_ERROR, "Error creating JsonString for Contrail Policy Ref", "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Policy Ref", e); + logger.error("{} {} Error creating JsonString for Contrail Policy Ref: ", MessageEnum.RA_MARSHING_ERROR, + MsoLogger.ErrorCode.SchemaError.getValue(), e); } return node; @@ -60,7 +65,8 @@ public class ContrailPolicyRef { } catch (Exception e) { - logger.error (MessageEnum.RA_MARSHING_ERROR, "Error creating JsonString for Contrail Policy Ref", "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Policy Ref", e); + logger.error("{} {} Error creating JsonString for Contrail Policy Ref: ", MessageEnum.RA_MARSHING_ERROR, + MsoLogger.ErrorCode.SchemaError.getValue(), e); } return jsonString; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java index 019963b242..6f80e0ee15 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -20,23 +22,24 @@ package org.onap.so.adapters.network; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.List; - import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.HostRoute; import org.onap.so.openstack.beans.Pool; import org.onap.so.openstack.beans.Subnet; import org.onap.so.openstack.utils.MsoCommonUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - public class ContrailSubnet { - private static final MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, ContrailSubnet.class); + + private static final Logger logger = LoggerFactory.getLogger(ContrailSubnet.class); @Autowired private MsoCommonUtils msoCommonUtils; @@ -129,8 +132,8 @@ public class ContrailSubnet { } catch (Exception e) { - String error = "Error creating JsonNode for Contrail Subnet:" + subnetName; - logger.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonNode for Contrail Subnet", e); + logger.error("{} {} Error creating JsonNode for Contrail Subnet: {} ", MessageEnum.RA_MARSHING_ERROR, + MsoLogger.ErrorCode.SchemaError.getValue(), subnetName, e); } return node; @@ -146,8 +149,8 @@ public class ContrailSubnet { } catch (Exception e) { - String error = "Error creating JsonString for Contrail Subnet:" + subnetName; - logger.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Subnet", e); + logger.error("{} {} Error creating JsonString for Contrail Subnet: {} ", MessageEnum.RA_MARSHING_ERROR, + MsoLogger.ErrorCode.SchemaError.getValue(), subnetName, e); } return jsonString; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java index 8181714c0a..80333d6c7e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java @@ -6,6 +6,7 @@ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ */ package org.onap.so.adapters.network; - + import java.net.MalformedURLException; import java.net.URL; @@ -31,14 +32,12 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.jws.WebService; import javax.xml.bind.DatatypeConverter; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import javax.xml.ws.Holder; import javax.xml.ws.handler.MessageContext; - import org.onap.so.adapters.network.async.client.CreateNetworkNotification; import org.onap.so.adapters.network.async.client.MsoExceptionCategory; import org.onap.so.adapters.network.async.client.NetworkAdapterNotify; @@ -48,12 +47,13 @@ import org.onap.so.adapters.network.async.client.UpdateNetworkNotification; import org.onap.so.adapters.network.exceptions.NetworkException; import org.onap.so.entity.MsoRequest; import org.onap.so.logger.MessageEnum; - import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.NetworkRollback; import org.onap.so.openstack.beans.NetworkStatus; import org.onap.so.openstack.beans.Subnet; import org.onap.so.utils.CryptoUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -62,14 +62,14 @@ import org.springframework.stereotype.Component; @WebService(serviceName = "NetworkAdapterAsync", endpointInterface = "org.onap.so.adapters.network.MsoNetworkAdapterAsync", targetNamespace = "http://org.onap.so/networkA") public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,MsoNetworkAdapterAsyncImpl.class); + private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterAsyncImpl.class); private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.network.bpelauth"; private static final String ENCRYPTION_KEY_PROP = "org.onap.so.adapters.network.encryptionKey"; private static final String NETWORK_EXCEPTION_MSG="Got a NetworkException on createNetwork: "; - private static final String CREATE_NETWORK_ERROR_MSG="Error sending createNetwork notification "; - private static final String CREATE_NETWORK_EXCEPTON_MSG="Exception sending createNetwork notification"; - private static final String MSO_INTERNAL_ERROR_MSG="MsoInternalError"; + private static final String CREATE_NETWORK_ERROR_LOGMSG ="{} {} Error sending createNetwork notification {} "; + private static final String FAULT_INFO_ERROR_LOGMSG = "{} {} Exception - fault info "; + @Autowired private Environment environment; @@ -80,7 +80,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { */ @Override public void healthCheckA () { - LOGGER.debug ("Health check call in Network Adapter"); + logger.debug ("Health check call in Network Adapter"); } /** @@ -130,13 +130,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("CreateNetworkA"); - LOGGER.debug ("Async Create Network: " + networkName - + " of type " - + networkType - + " in " - + cloudSiteId - + "/" - + tenantId); + logger.debug("Async Create Network: {} of type {} in {}/{}", networkName, networkType, cloudSiteId, tenantId); // Use the synchronous method to perform the actual Create @@ -177,27 +171,28 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { subnetIdMap, networkRollback); } catch (NetworkException e) { - LOGGER.debug (NETWORK_EXCEPTION_MSG, e); + logger.debug (NETWORK_EXCEPTION_MSG, e); MsoExceptionCategory exCat = null; String eMsg = null; try { eMsg = e.getFaultInfo ().getMessage (); exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1); + logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e1); } // Build and send Asynchronous error response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.createNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null); } catch (Exception e1) { - error = CREATE_NETWORK_ERROR_MSG + e1.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError,CREATE_NETWORK_EXCEPTON_MSG, e1); + logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e1.getMessage(), e1); } return; } - LOGGER.debug ("Async Create Network:Name " + networkName + " physicalNetworkName:" + physicalNetworkName); + logger.debug("Async Create Network:Name {} physicalNetworkName:{}", networkName, physicalNetworkName); // Build and send Asynchronous response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); @@ -210,8 +205,8 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { copyCreateSubnetIdMap (subnetIdMap), copyNrb (networkRollback)); } catch (Exception e) { - error = CREATE_NETWORK_ERROR_MSG + e.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, CREATE_NETWORK_EXCEPTON_MSG, e); + logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e.getMessage(), e); } return; @@ -262,13 +257,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { String serviceName = "UpdateNetworkA"; MsoLogger.setServiceName (serviceName); MsoLogger.setLogContext (msoRequest); - LOGGER.debug ("Async Update Network: " + networkId - + " of type " - + networkType - + "in " - + cloudSiteId - + "/" - + tenantId); + logger.debug("Async Update Network: {} of type {} in {}/{}", networkId, networkType, cloudSiteId, tenantId); // Use the synchronous method to perform the actual Create @@ -306,27 +295,29 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoLogger.setServiceName (serviceName); } catch (NetworkException e) { MsoLogger.setServiceName (serviceName); - LOGGER.debug ("Got a NetworkException on updateNetwork: ", e); + logger.debug ("Got a NetworkException on updateNetwork: ", e); MsoExceptionCategory exCat = null; String eMsg = null; try { eMsg = e.getFaultInfo ().getMessage (); exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1); + logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e1); } // Build and send Asynchronous error response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.updateNetworkNotification (messageId, false, exCat, eMsg, null, copyNrb (networkRollback)); } catch (Exception e1) { - error = "Error sending updateNetwork notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNetwork notification", e1); + logger.error("{} {} Error sending updateNetwork notification {} ", + MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, MsoLogger.ErrorCode.DataError.getValue(), e1.getMessage(), + e1); } return; } - LOGGER.debug ("Async Update Network:Name " + networkName + " NetworkId:" + networkId); + logger.debug("Async Update Network:Name {} NetworkId:{}", networkName, networkId); // Build and send Asynchronous response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); @@ -337,9 +328,8 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { copyUpdateSubnetIdMap (subnetIdMap), copyNrb (networkRollback)); } catch (Exception e) { - error = "Error sending updateNotification request" + e.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNotification request", e); - + logger.error("{} {} Error sending updateNotification request {} ", MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e.getMessage(), e); } return; } @@ -363,7 +353,8 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoLogger.setLogContext (msoRequest); String serviceName = "QueryNetworkA"; MsoLogger.setServiceName (serviceName); - LOGGER.debug ("Async Query Network " + networkNameOrId + " in " + cloudSiteId + "/" + tenantId); + logger.debug("Async Query Network {} in {}/{}", networkNameOrId, cloudSiteId, tenantId); + String errorCreateNetworkMessage = "{} {} Error sending createNetwork notification {} "; // Use the synchronous method to perform the actual Create @@ -390,27 +381,27 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoLogger.setServiceName (serviceName); } catch (NetworkException e) { MsoLogger.setServiceName (serviceName); - LOGGER.debug (NETWORK_EXCEPTION_MSG, e); + logger.debug (NETWORK_EXCEPTION_MSG, e); MsoExceptionCategory exCat = null; String eMsg = null; try { eMsg = e.getFaultInfo ().getMessage (); exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1); + logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e1); } // Build and send Asynchronous error response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.queryNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null, null, null); } catch (Exception e1) { - error = "Error sending createNetwork notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1); - + logger.error(errorCreateNetworkMessage, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e1.getMessage(), e1); } return; } - LOGGER.debug ("Async Query Network:NameOrId " + networkNameOrId + " tenantId:" + tenantId); + logger.debug("Async Query Network:NameOrId {} tenantId:{}", networkNameOrId, tenantId); // Build and send Asynchronous response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); @@ -426,9 +417,8 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { vlans.value, copyQuerySubnetIdMap (subnetIdMap)); } catch (Exception e) { - error = "Error sending createNetwork notification " + e.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e); - + logger.error(errorCreateNetworkMessage, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e.getMessage(), e); } return; } @@ -464,7 +454,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoLogger.setLogContext (msoRequest); String serviceName = "DeleteNetworkA"; MsoLogger.setServiceName (serviceName); - LOGGER.debug ("Async Delete Network " + networkId + " in " + cloudSiteId + "/" + tenantId); + logger.debug("Async Delete Network {} in {}/{}", networkId, cloudSiteId, tenantId); // Use the synchronous method to perform the actual Create @@ -477,34 +467,36 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoLogger.setServiceName (serviceName); } catch (NetworkException e) { MsoLogger.setServiceName (serviceName); - LOGGER.debug (NETWORK_EXCEPTION_MSG, e); + logger.debug (NETWORK_EXCEPTION_MSG, e); MsoExceptionCategory exCat = null; String eMsg = null; try { eMsg = e.getFaultInfo ().getMessage (); exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1); + logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e1); } // Build and send Asynchronous error response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.deleteNetworkNotification (messageId, false, exCat, eMsg, null); } catch (Exception e1) { - error = "Error sending createNetwork notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1); + logger.error("{} {} Error sending createNetwork notification {} ", + MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, MsoLogger.ErrorCode.DataError.getValue(), e1.getMessage(), + e1); } return; } - LOGGER.debug ("Async Delete NetworkId: " + networkId + " tenantId:" + tenantId); + logger.debug("Async Delete NetworkId: {} tenantId:{}", networkId, tenantId); // Build and send Asynchronous response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.deleteNetworkNotification (messageId, true, null, null, networkDeleted.value); } catch (Exception e) { - error = "Error sending deleteNetwork notification " + e.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending deleteNetwork notification", e); + logger.error("{} {} Error sending deleteNetwork notification {} ", MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e.getMessage(), e); } return; @@ -526,12 +518,13 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoLogger.setServiceName (serviceName); // rollback may be null (e.g. if network already existed when Create was called) if (rollback == null) { - LOGGER.warn (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.SchemaError, "Rollback is null"); + logger.warn("{} {} Rollback is null", MessageEnum.RA_ROLLBACK_NULL, + MsoLogger.ErrorCode.SchemaError.getValue()); return; } MsoLogger.setLogContext (rollback.getMsoRequest ()); - LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId (), "", ""); + logger.info("{} {}", MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId()); // Use the synchronous method to perform the actual Create @@ -540,7 +533,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoLogger.setServiceName (serviceName); } catch (NetworkException e) { MsoLogger.setServiceName (serviceName); - LOGGER.debug ("Got a NetworkException on rollbackNetwork: ", e); + logger.debug ("Got a NetworkException on rollbackNetwork: ", e); // Build and send Asynchronous error response MsoExceptionCategory exCat = null; String eMsg = null; @@ -548,27 +541,29 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { eMsg = e.getFaultInfo ().getMessage (); exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in get fault info", e1); + logger.error("{} {} Exception in get fault info ", MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e1); } // Build and send Asynchronous error response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), false, exCat, eMsg); } catch (Exception e1) { - error = CREATE_NETWORK_ERROR_MSG + e1.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending createNetwork notification ", e1); + logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e1.getMessage(), e1); } return; } - LOGGER.debug ("Async Rollback NetworkId: " + rollback.getNetworkStackId () + " tenantId:" + rollback.getTenantId ()); + logger.debug("Async Rollback NetworkId: {} tenantId:{}", rollback.getNetworkStackId(), rollback.getTenantId()); // Build and send Asynchronous response try { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), true, null, null); } catch (Exception e) { - error = "Error sending rollbackNetwork notification " + e.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending rollbackNetwork notification", e); + logger + .error("{} {} Error sending rollbackNetwork notification {} ", MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e.getMessage(), e); } return; @@ -607,15 +602,18 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { try { warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("NetworkAdapterNotify.wsdl"); } catch (Exception e) { - LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); + logger.error("{} {} Exception - WSDL not found ", MessageEnum.RA_WSDL_NOT_FOUND, + MsoLogger.ErrorCode.DataError.getValue(), e); } if (warWsdlLoc == null) { - LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "WSDL not found"); + logger + .error("{} {} WSDL not found", MessageEnum.RA_WSDL_NOT_FOUND, MsoLogger.ErrorCode.DataError.getValue()); } else { try { - LOGGER.debug ("NetworkAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ()); + logger.debug("NetworkAdpaterNotify.wsdl location: {}", warWsdlLoc.toURI().toString()); } catch (Exception e) { - LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.SchemaError, "Exception - WSDL URL convention", e); + logger.error("{} {} Exception - WSDL URL convention ", MessageEnum.RA_WSDL_URL_CONVENTION_EXC, + MsoLogger.ErrorCode.SchemaError.getValue(), e); } } @@ -631,15 +629,16 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { try { epUrl = new URL (notificationUrl); } catch (MalformedURLException e1) { - LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - init notification", e1); + logger.error("{} {} Exception - init notification ", MessageEnum.RA_INIT_NOTIF_EXC, + MsoLogger.ErrorCode.DataError.getValue(), e1); } if(null != epUrl) { - LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ()); + logger.debug("Notification Endpoint URL: {}", epUrl.toExternalForm()); bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); } else { - LOGGER.debug ("Notification Endpoint URL is NULL: "); + logger.debug("Notification Endpoint URL is NULL: "); } // authentication @@ -653,9 +652,8 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, headers); headers.put ("Authorization", Collections.singletonList (basicAuth)); } catch (Exception e) { - String error1 = "Unable to set authorization in callback request" + e.getMessage (); - LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to set authorization in callback request", e); - + logger.error("{} {} Unable to set authorization in callback request {} ", + MessageEnum.RA_SET_CALLBACK_AUTH_EXC, MsoLogger.ErrorCode.DataError.getValue(), e.getMessage(), e); } return notifyPort; @@ -665,7 +663,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { try { return CryptoUtils.decrypt(this.environment.getProperty(key), this.environment.getProperty(encryptionKey)); } catch (GeneralSecurityException e) { - LOGGER.debug("Exception while decrypting property: " + this.environment.getProperty(key), e); + logger.debug("Exception while decrypting property: {} ", this.environment.getProperty(key), e); } return defaultValue; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index d250561f16..79966577f8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -6,6 +6,7 @@ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,17 +22,17 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.network; +package org.onap.so.adapters.network; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; - import javax.jws.WebService; import javax.xml.ws.Holder; - import org.onap.so.adapters.network.beans.ContrailPolicyRef; import org.onap.so.adapters.network.beans.ContrailPolicyRefSeq; import org.onap.so.adapters.network.beans.ContrailSubnet; @@ -39,17 +40,16 @@ import org.onap.so.adapters.network.exceptions.NetworkException; import org.onap.so.adapters.network.mappers.ContrailSubnetMapper; import org.onap.so.cloud.CloudConfig; import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.HeatTemplate; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; -import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.data.repository.CollectionNetworkResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; import org.onap.so.db.catalog.utils.MavenLikeVersioning; import org.onap.so.entity.MsoRequest; import org.onap.so.logger.MessageEnum; - import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.NetworkInfo; @@ -67,14 +67,13 @@ import org.onap.so.openstack.utils.MsoHeatUtils; import org.onap.so.openstack.utils.MsoHeatUtilsWithUpdate; import org.onap.so.openstack.utils.MsoNeutronUtils; import org.onap.so.openstack.utils.MsoNeutronUtils.NetworkType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - @Component @Transactional @WebService(serviceName = "NetworkAdapter", endpointInterface = "org.onap.so.adapters.network.MsoNetworkAdapter", targetNamespace = "http://org.onap.so/network") @@ -91,7 +90,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError"; private static final String NEUTRON_MODE = "NEUTRON"; - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,MsoNetworkAdapterImpl.class); + private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterImpl.class); @Autowired private CloudConfig cloudConfig; @@ -119,7 +118,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { */ @Override public void healthCheck () { - LOGGER.debug ("Health check call in Network Adapter"); + logger.debug ("Health check call in Network Adapter"); } /** @@ -270,13 +269,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName (CREATE_NETWORK_CONTEXT); - LOGGER.debug ("*** CREATE Network: " + networkName - + " of type " - + networkType - + " in " - + cloudSiteId - + "/" - + tenantId); + logger.debug("*** CREATE Network: {} of type {} in {}/{}", networkName, networkType, cloudSiteId, tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -295,16 +288,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId); if (!cloudSiteOpt.isPresent()) { - String error = "Configuration Error. Stack " + networkName + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + " CloudSite does not exist in MSO Configuration"; - LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, "Configuration Error"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); - // Set the detailed error as the Exception 'message' - throw new NetworkException (error, MsoExceptionCategory.USERDATA); + String error = String + .format("Configuration Error. Stack %s in %s/%s: CloudSite does not exist in MSO Configuration", + networkName, cloudSiteId, tenantId); + logger.error("{} {} {}", MessageEnum.RA_CONFIG_EXC, MsoLogger.ErrorCode.DataError.getValue(), error); + // Set the detailed error as the Exception 'message' + throw new NetworkException(error, MsoExceptionCategory.USERDATA); } @@ -329,12 +318,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long queryNetworkStarttime = System.currentTimeMillis (); try { netInfo = neutron.queryNetwork (networkName, tenantId, cloudSiteId); - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null); } catch (MsoException me) { - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack", "OpenStack", "QueryNetwork", null); - LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack", me); + logger.error( + "{} {} Exception while querying network {} for CloudSite {} from Tenant {} from OpenStack ", + MessageEnum.RA_QUERY_NETWORK_EXC, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + networkName, cloudSiteId, tenantId, me); me.addContext (CREATE_NETWORK_CONTEXT); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack"); throw new NetworkException (me); } @@ -342,23 +331,20 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Exists. If that's OK, return success with the network ID. // Otherwise, return an exception. if (failIfExists != null && failIfExists) { - String error = "Create Nework: Network " + networkName - + " already exists in " - + cloudSiteId - + "/" - + tenantId - + " with ID " + netInfo.getId(); - LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + String error = String + .format("Create Nework: Network %s already exists in %s/%s with ID %s", networkName, + cloudSiteId, tenantId, netInfo.getId()); + logger.error("{} {} {}", MessageEnum.RA_NETWORK_ALREADY_EXIST, + MsoLogger.ErrorCode.DataError.getValue(), error); throw new NetworkException(error, MsoExceptionCategory.USERDATA); } else { // Populate the outputs from the existing network. networkId.value = netInfo.getId (); neutronNetworkId.value = netInfo.getId (); rollback.value = networkRollback; // Default rollback - no updates performed - String msg = "Found Existing network, status=" + netInfo.getStatus () + " for Neutron mode"; - LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", MsoLogger.ErrorCode.DataError, "Found Existing network, status=" + netInfo.getStatus ()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg); + logger.warn("{} {} Found Existing network, status={} for Neutron mode ", + MessageEnum.RA_NETWORK_ALREADY_EXIST, MsoLogger.ErrorCode.DataError.getValue(), + netInfo.getStatus()); } return; } @@ -371,19 +357,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkName, physicalNetworkName, vlans); - LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "CreateNetwork", null); } catch (MsoException me) { - me.addContext (CREATE_NETWORK_CONTEXT); - LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with OpenStack", "OpenStack", "CreateNetwork", null); - String error = "Create Network: type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while communicate with OpenStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + me.addContext(CREATE_NETWORK_CONTEXT); + logger.error("{} {} Create Network: type {} in {}/{}: ", MessageEnum.RA_CREATE_NETWORK_EXC, + MsoLogger.ErrorCode.DataError.getValue(), neutronNetworkType, cloudSiteId, tenantId, me); throw new NetworkException (me); } @@ -401,18 +378,19 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkRollback.setNeutronNetworkId (netInfo.getId ()); networkRollback.setNetworkType (networkType); - LOGGER.debug ("Network " + networkName + " created, id = " + netInfo.getId ()); + logger.debug("Network {} created, id = {}", networkName, netInfo.getId()); } else if ("HEAT".equals (mode)) { HeatTemplate heatTemplate = networkResource.getHeatTemplate(); if (heatTemplate == null) { - String error = "Network error - undefined Heat Template. Network Type = " + networkType; - LOGGER.error (MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "Openstack", "", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type = " + networkType); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + String error = String + .format("Network error - undefined Heat Template. Network Type = %s", networkType); + logger.error("{} {} {}", MessageEnum.RA_PARAM_NOT_FOUND, MsoLogger.ErrorCode.DataError.getValue(), + error); throw new NetworkException (error, MsoExceptionCategory.INTERNAL); } - - LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString()); + + logger.debug("Got HEAT Template from DB: {}", heatTemplate.toString()); // "Fix" the template if it has CR/LF (getting this from Oracle) String template = heatTemplate.getHeatTemplate (); @@ -432,33 +410,22 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long queryNetworkStarttime = System.currentTimeMillis (); try { heatStack = heat.queryStack (cloudSiteId, tenantId, networkName); - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null); } catch (MsoException me) { me.addContext (CREATE_NETWORK_CONTEXT); - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying stack from OpenStack", "OpenStack", "QueryNetwork", null); - String error = "Create Network (heat): query network " + networkName - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while querying stack from OpenStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Create Network (heat): query network {} in {}/{}: ", + MessageEnum.RA_QUERY_NETWORK_EXC, MsoLogger.ErrorCode.DataError.getValue(), networkName, + cloudSiteId, tenantId, me); throw new NetworkException (me); } if (heatStack != null && (heatStack.getStatus () != HeatStatus.NOTFOUND)) { // Stack exists. Return success or error depending on input directive if (failIfExists != null && failIfExists) { - String error = "CreateNetwork: Stack " + networkName - + " already exists in " - + cloudSiteId - + "/" - + tenantId - + " as " + heatStack.getCanonicalName(); - LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Network already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + String error = String + .format("CreateNetwork: Stack %s already exists in %s/%s as %s", networkName, cloudSiteId, + tenantId, heatStack.getCanonicalName()); + logger.error("{} {} {}", MessageEnum.RA_NETWORK_ALREADY_EXIST, + MsoLogger.ErrorCode.DataError.getValue(), error); throw new NetworkException(error, MsoExceptionCategory.USERDATA); } else { // Populate the outputs from the existing stack. @@ -489,8 +456,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } subnetIdMap.value = sMap; - LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", MsoLogger.ErrorCode.DataError, "Found Existing network stack, status=" + heatStack.getStatus ()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Found Existing network stack"); + logger.warn("{} {} Found Existing network stack, status={} networkName={} for {}/{}", + MessageEnum.RA_NETWORK_ALREADY_EXIST, MsoLogger.ErrorCode.DataError.getValue(), + heatStack.getStatus(), networkName, cloudSiteId, tenantId); } return; } @@ -513,8 +481,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { stackParams = heat.validateStackParams (stackParams, heatTemplate); } catch (IllegalArgumentException e) { String error = "Create Network: Configuration Error: " + e.getMessage (); - LOGGER.error (MessageEnum.RA_CONFIG_EXC, e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Create Network, Configuration Error", e); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + logger.error("{} {} {} ", MessageEnum.RA_CONFIG_EXC, + MsoLogger.ErrorCode.DataError.getValue(), error,e); // Input parameters were not valid throw new NetworkException (error, MsoExceptionCategory.INTERNAL); } @@ -531,15 +499,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } catch (MsoException me) { me.addContext (CREATE_NETWORK_CONTEXT); - String error = "Create Network (heat): type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging subnets", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + logger + .error("{} {} Exception Create Network, merging subnets for network (heat) type {} in {}/{} ", + MessageEnum.RA_CREATE_NETWORK_EXC, MsoLogger.ErrorCode.DataError.getValue(), + neutronNetworkType.toString(), cloudSiteId, tenantId, me); throw new NetworkException (me); } } @@ -549,15 +512,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { mergePolicyRefs (policyFqdns, stackParams); } catch (MsoException me) { me.addContext (CREATE_NETWORK_CONTEXT); - String error = "Create Network (heat) mergePolicyRefs type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging policyRefs", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + logger.error("{} {} Exception Create Network, merging policyRefs type {} in {}/{} ", + MessageEnum.RA_CREATE_NETWORK_EXC, MsoLogger.ErrorCode.DataError.getValue(), + neutronNetworkType.toString(), cloudSiteId, tenantId, me); throw new NetworkException (me); } } @@ -567,15 +524,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { mergeRouteTableRefs (routeTableFqdns, stackParams); } catch (MsoException me) { me.addContext (CREATE_NETWORK_CONTEXT); - String error = "Create Network (heat) mergeRouteTableRefs type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging routeTableRefs", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + logger.error("{} {} Exception Create Network, merging routeTableRefs type {} in {}/{} ", + MessageEnum.RA_CREATE_NETWORK_EXC, MsoLogger.ErrorCode.DataError.getValue(), + neutronNetworkType.toString(), cloudSiteId, tenantId, me); throw new NetworkException (me); } } @@ -598,15 +549,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { backout.booleanValue()); } catch (MsoException me) { me.addContext (CREATE_NETWORK_CONTEXT); - String error = "Create Network (heat): type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception creating network", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger + .error("{} {} Exception creating network type {} in {}/{} ", MessageEnum.RA_CREATE_NETWORK_EXC, + MsoLogger.ErrorCode.DataError.getValue(), networkName, cloudSiteId, tenantId, me); throw new NetworkException (me); } @@ -648,10 +593,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkRollback.setNetworkCreated (true); networkRollback.setNetworkType (networkType); - LOGGER.debug ("Network " + networkName + " successfully created via HEAT"); + logger.debug("Network {} successfully created via HEAT", networkName); } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Successfully created network"); return; } @@ -772,14 +716,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Holder <NetworkRollback> rollback) throws NetworkException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName (UPDATE_NETWORK_CONTEXT); - LOGGER.debug ("***UPDATE Network adapter with Network: " + networkName - + " of type " - + networkType - + " in " - + cloudSiteId - + "/" - + tenantId); - + logger.debug("***UPDATE Network adapter with Network: {} of type {} in {}/{}", networkName, networkType, + cloudSiteId, tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -792,16 +730,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite (cloudSiteId); if (!cloudSiteOpt.isPresent()) { - String error = "UpdateNetwork: Configuration Error. Stack " + networkName + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + " CloudSite does not exist in MSO Configuration"; - LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "CloudSite does not exist in MSO Configuration"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); - // Set the detailed error as the Exception 'message' - throw new NetworkException (error, MsoExceptionCategory.USERDATA); + String error = String.format( + "UpdateNetwork: Configuration Error. Stack %s in %s/%s: CloudSite does not exist in MSO Configuration", + networkName, cloudSiteId, tenantId); + logger.error("{} {} {}", MessageEnum.RA_CONFIG_EXC, MsoLogger.ErrorCode.DataError.getValue(), error); + // Set the detailed error as the Exception 'message' + throw new NetworkException(error, MsoExceptionCategory.USERDATA); } @@ -830,30 +764,18 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long queryNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.queryNetwork(networkId, tenantId, cloudSiteId); - LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryNetwork", null); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); - String error = "Update Network (neutron): query " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null); - LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "QueryNetwork", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryNetwork", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - queryNetwork query {} in {}/{} ", MessageEnum.RA_QUERY_NETWORK_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), networkId, cloudSiteId, tenantId, me); throw new NetworkException(me); } if (netInfo == null) { - String error = "Update Nework: Network " + networkId - + " does not exist in " - + cloudSiteId - + "/" - + tenantId; - LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Network not found"); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + String error = String + .format("Update Nework: Network %s does not exist in %s/%s", networkId, cloudSiteId, tenantId); + logger.error("{} {} {}", MessageEnum.RA_NETWORK_NOT_FOUND, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), error); // Does not exist. Throw an exception (can't update a non-existent network) throw new NetworkException(error, MsoExceptionCategory.USERDATA); } @@ -865,19 +787,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { neutronNetworkType, physicalNetworkName, vlans); - LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateNetwork", null); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); - String error = "Update Network (neutron): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "Openstack", "updateNetwork", MsoLogger.ErrorCode.DataError, "Exception - updateNetwork", me); - LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateNetwork", null); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - updateNetwork {} in {}/{} ", MessageEnum.RA_UPDATE_NETWORK_ERR, + MsoLogger.ErrorCode.DataError.getValue(), networkId, cloudSiteId, tenantId, me); throw new NetworkException(me); } @@ -890,7 +803,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkRollback.setPhysicalNetwork(netInfo.getProvider()); networkRollback.setVlans(netInfo.getVlans()); - LOGGER.debug("Network " + networkId + " updated, id = " + netInfo.getId()); + logger.debug("Network {} updated, id = {}", networkId, netInfo.getId()); } else if ("HEAT".equals(mode)) { // First, look up to see that the Network already exists. @@ -899,30 +812,18 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long queryStackStarttime = System.currentTimeMillis(); try { heatStack = heat.queryStack(cloudSiteId, tenantId, networkName); - LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", null); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); - String error = "UpdateNetwork (heat): query " + networkName - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); - LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - QueryStack query {} in {}/{} ", MessageEnum.RA_QUERY_NETWORK_EXC, + MsoLogger.ErrorCode.DataError.getValue(), networkId, cloudSiteId, tenantId, me); throw new NetworkException(me); } if (heatStack == null || (heatStack.getStatus() == HeatStatus.NOTFOUND)) { - String error = "UpdateNetwork: Stack " + networkName - + " does not exist in " - + cloudSiteId - + "/" - + tenantId; - LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Network not found"); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + String error = String + .format("UpdateNetwork: Stack %s does not exist in %s/%s", networkName, cloudSiteId, tenantId); + logger.error("{} {} {}", MessageEnum.RA_NETWORK_NOT_FOUND, MsoLogger.ErrorCode.DataError.getValue(), + error); // Network stack does not exist. Return an error throw new NetworkException(error, MsoExceptionCategory.USERDATA); } @@ -940,11 +841,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { try { previousVlans.add(Integer.parseInt(vlan)); } catch (NumberFormatException e) { - LOGGER.warn(MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e); + logger.warn("{} {} Exception - VLAN parse for params {} ", MessageEnum.RA_VLAN_PARSE, + MsoLogger.ErrorCode.DataError.getValue(), vlansParam, e); } } } - LOGGER.debug("Update Stack: Previous VLANS: " + previousVlans); + logger.debug("Update Stack: Previous VLANS: {}", previousVlans); // Ready to deploy the updated Network via Heat @@ -952,13 +854,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { HeatTemplate heatTemplate = networkResource.getHeatTemplate(); if (heatTemplate == null) { String error = "Network error - undefined Heat Template. Network Type=" + networkType; - LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "OpenStack", "getHeatTemplate", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type=" + networkType); - - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + logger.error("{} {} {}", MessageEnum.RA_PARAM_NOT_FOUND, MsoLogger.ErrorCode.DataError.getValue(), + error); throw new NetworkException(error, MsoExceptionCategory.INTERNAL); } - LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString()); + logger.debug("Got HEAT Template from DB: {}", heatTemplate.toString()); // "Fix" the template if it has CR/LF (getting this from Oracle) String template = heatTemplate.getHeatTemplate(); @@ -988,9 +889,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { stackParams = heat.validateStackParams(stackParams, heatTemplate); } catch (IllegalArgumentException e) { String error = "UpdateNetwork: Configuration Error: Network Type=" + networkType; - LOGGER.error(MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork: Configuration Error"); - - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, error); + logger.error("{} {} {} ", MessageEnum.RA_CONFIG_EXC, MsoLogger.ErrorCode.DataError.getValue(), error); throw new NetworkException(error, MsoExceptionCategory.INTERNAL, e); } @@ -1003,15 +902,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); - String error = "Update Network (heat): type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeSubnets ", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + logger.error("{} {} Exception - UpdateNetwork mergeSubnets for network type {} in {}/{} ", + MessageEnum.RA_UPDATE_NETWORK_ERR, MsoLogger.ErrorCode.DataError.getValue(), + neutronNetworkType.toString(), cloudSiteId, tenantId, me); throw new NetworkException(me); } } @@ -1021,15 +914,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { mergePolicyRefs(policyFqdns, stackParams); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); - String error = "UpdateNetwork (heat) mergePolicyRefs type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergePolicyRefs", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + logger.error("{} {} Exception - UpdateNetwork mergePolicyRefs type {} in {}/{} ", + MessageEnum.RA_UPDATE_NETWORK_ERR, MsoLogger.ErrorCode.DataError.getValue(), + neutronNetworkType.toString(), cloudSiteId, tenantId, me); throw new NetworkException(me); } } @@ -1039,15 +926,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { mergeRouteTableRefs(routeTableFqdns, stackParams); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); - String error = "UpdateNetwork (heat) mergeRouteTableRefs type " + neutronNetworkType - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeRouteTableRefs", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); + logger.error("{} {} Exception - UpdateNetwork mergeRouteTableRefs type {} in {}/{} ", + MessageEnum.RA_UPDATE_NETWORK_ERR, MsoLogger.ErrorCode.DataError.getValue(), + neutronNetworkType.toString(), cloudSiteId, tenantId, me); throw new NetworkException(me); } } @@ -1063,13 +944,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { stackParams, true, heatTemplate.getTimeoutMinutes()); - LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateStack", null); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); - String error = "Update Network: " + networkId + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null); - LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - update network", me); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - update network {} in {}/{} ", MessageEnum.RA_UPDATE_NETWORK_ERR, + MsoLogger.ErrorCode.DataError.getValue(), networkId, cloudSiteId, tenantId, me); throw new NetworkException(me); } @@ -1100,7 +978,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID)); } else { - LOGGER.debug("outputs is NULL"); + logger.debug("outputs is NULL"); } networkRollback.setNetworkType(networkType); // Save previous parameters @@ -1110,10 +988,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { rollback.value = networkRollback; - LOGGER.debug("Network " + networkId + " successfully updated via HEAT"); + logger.debug("Network {} successfully updated via HEAT", networkId); } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully updated network"); return; } @@ -1141,30 +1018,23 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } if(networkCust != null){ - LOGGER.debug("Got Network Customization definition from Catalog: " - + networkCust.toString()); + logger.debug("Got Network Customization definition from Catalog: {}", networkCust.toString()); networkResource = networkCust.getNetworkResource(); } else if (collectionNetworkCust != null) { - LOGGER.debug("Retrieved Collection Network Resource Customization from Catalog: " - + collectionNetworkCust.toString()); + logger.debug("Retrieved Collection Network Resource Customization from Catalog: {}", + collectionNetworkCust.toString()); networkResource = collectionNetworkCust.getNetworkResource(); } if (networkResource == null) { - String error = "Create/UpdateNetwork: Unable to get network resource with NetworkType:" - + networkType - + " or ModelCustomizationUUID:" - + modelCustomizationUuid; - LOGGER.error(MessageEnum.RA_UNKOWN_PARAM, - "NetworkType/ModelCustomizationUUID", networkType + "/" - + modelCustomizationUuid, "OpenStack", "", - MsoLogger.ErrorCode.DataError, - "Create/UpdateNetwork: Unknown NetworkType/ModelCustomizationUUID"); + String error = String.format( + "Create/UpdateNetwork: Unable to get network resource with NetworkType: %s or ModelCustomizationUUID:%s", + networkType, modelCustomizationUuid); + logger.error("{} {} {} ", MessageEnum.RA_UNKOWN_PARAM, MsoLogger.ErrorCode.DataError.getValue(), error); throw new NetworkException(error, MsoExceptionCategory.USERDATA); - } - LOGGER.debug("Got Network definition from Catalog: " - + networkResource.toString()); + } + logger.debug("Got Network definition from Catalog: {}", networkResource.toString()); String mode = networkResource.getOrchestrationMode(); NetworkType neutronNetworkType = NetworkType @@ -1172,12 +1042,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // All Networks are orchestrated via HEAT or Neutron if (!("HEAT".equals(mode) || NEUTRON_MODE.equals(mode))) { - String error = "CreateNetwork: Configuration Error: Network Type = " - + networkType; - LOGGER.error(MessageEnum.RA_NETWORK_ORCHE_MODE_NOT_SUPPORT, - mode, "OpenStack", "", MsoLogger.ErrorCode.DataError, - "CreateNetwork: Configuration Error"); - throw new NetworkException(error, MsoExceptionCategory.INTERNAL); + String error = "CreateNetwork: Configuration Error: Network Type = " + networkType; + logger.error("{} {} {}", MessageEnum.RA_NETWORK_ORCHE_MODE_NOT_SUPPORT, + MsoLogger.ErrorCode.DataError.getValue(), error); + throw new NetworkException(error, MsoExceptionCategory.INTERNAL); } MavenLikeVersioning aicV = new MavenLikeVersioning(); @@ -1191,22 +1059,15 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { .isMoreRecentThan(networkResource .getAicVersionMax())))) // aic <= max { - LOGGER.debug("Network Type:" + networkType + " VersionMin:" - + networkResource.getAicVersionMin() + " VersionMax:" - + networkResource.getAicVersionMax() - + " supported on Cloud:" + cloudSiteId - + " with AIC_Version:" + cloudSite.getCloudVersion()); + logger.debug("Network Type:{} VersionMin:{} VersionMax:{} supported on Cloud:{} with AIC_Version:{}", + networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(), cloudSiteId, + cloudSite.getCloudVersion()); } else { - String error = "Network Type:" + networkType + " Version_Min:" - + networkResource.getAicVersionMin() + " Version_Max:" - + networkResource.getAicVersionMax() - + " not supported on Cloud:" + cloudSiteId - + " with AIC_Version:" + cloudSite.getCloudVersion(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", - MsoLogger.ErrorCode.DataError, - "Network Type not supported on Cloud"); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, - MsoLogger.ResponseCode.DataError, error); + String error = String + .format("Network Type:%s Version_Min:%s Version_Max:%s not supported on Cloud:%s with AIC_Version:%s", + networkType, networkType, networkResource.getAicVersionMin(), + networkResource.getAicVersionMax(), cloudSiteId, cloudSite.getCloudVersion()); + logger.error("{} {} {} ", MessageEnum.RA_CONFIG_EXC, MsoLogger.ErrorCode.DataError.getValue(), error); throw new NetworkException(error, MsoExceptionCategory.USERDATA); } @@ -1215,9 +1076,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkName, physicalNetworkName, vlans, routeTargets); if (!missing.isEmpty()) { String error = "Create Network: Missing parameters: " + missing; - LOGGER.error(MessageEnum.RA_MISSING_PARAM, missing, - "OpenStack", "", MsoLogger.ErrorCode.DataError, - "Create Network: Missing parameters"); + logger.error("{} {} {}", MessageEnum.RA_MISSING_PARAM, MsoLogger.ErrorCode.DataError.getValue(), error); throw new NetworkException(error, MsoExceptionCategory.USERDATA); } @@ -1293,11 +1152,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Holder <Map <String, String>> subnetIdMap) throws NetworkException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("QueryNetwork"); - LOGGER.debug ("*** QUERY Network with Network: " + networkNameOrId - + " in " - + cloudSiteId - + "/" - + tenantId); + logger.debug("*** QUERY Network with Network: {} in {}/{}", networkNameOrId, cloudSiteId, tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -1307,22 +1162,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { || commonUtils.isNullOrEmpty(networkNameOrId)) { String error = "Missing mandatory parameter cloudSiteId, tenantId or networkId"; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkNameOrId", "OpenStack", "", MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + logger.error("{} {} {}", MessageEnum.RA_MISSING_PARAM, MsoLogger.ErrorCode.DataError.getValue(), error); throw new NetworkException (error, MsoExceptionCategory.USERDATA); } Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId); if (!cloudSiteOpt.isPresent()) { - String error = "Configuration Error. Stack " + networkNameOrId + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + " CloudSite does not exist in MSO Configuration"; - LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Configuration Error"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + String error = String + .format("Configuration Error. Stack %s in %s/%s: CloudSite does not exist in MSO Configuration", + networkNameOrId, cloudSiteId, tenantId); + logger.error("{} {} {}", MessageEnum.RA_CONFIG_EXC, MsoLogger.ErrorCode.DataError.getValue(), error); // Set the detailed error as the Exception 'message' throw new NetworkException (error, MsoExceptionCategory.USERDATA); } @@ -1336,19 +1186,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long queryStackStarttime = System.currentTimeMillis (); try { heatStack = heat.queryStack (cloudSiteId, tenantId, networkNameOrId); - LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", null); } catch (MsoException me) { me.addContext ("QueryNetwork"); - String error = "Query Network (heat): " + networkNameOrId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "BPMN", "QueryStack", null); - LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkNameOrId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - Query Network (heat)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - Query Network (heat): {} in {}/{} ", MessageEnum.RA_QUERY_NETWORK_EXC, + MsoLogger.ErrorCode.DataError.getValue(), networkNameOrId, cloudSiteId, tenantId, me); throw new NetworkException (me); } @@ -1388,7 +1229,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long queryNetworkStarttime = System.currentTimeMillis (); try { NetworkInfo netInfo = neutron.queryNetwork (neutronId, tenantId, cloudSiteId); - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryNetwork", null); if (netInfo != null) { // Found. Populate the output elements networkExists.value = Boolean.TRUE; @@ -1402,12 +1242,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (vlans != null) vlans.value = netInfo.getVlans (); - LOGGER.debug ("Network " + networkNameOrId - + " found (" - + mode - + "), ID = " - + networkId.value - + ("HEAT".equals (mode) ? ",NeutronId = " + neutronNetworkId.value : "")); + logger.debug("Network {} found({}), ID = {}{}", networkNameOrId, mode, networkId.value, + ("HEAT".equals(mode) ? ",NeutronId = " + neutronNetworkId.value : "")); } else { // Not found. Populate the status fields, leave the rest null networkExists.value = Boolean.FALSE; @@ -1416,23 +1252,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (vlans != null) vlans.value = new ArrayList<>(); - LOGGER.debug ("Network " + networkNameOrId + " not found"); + logger.debug("Network {} not found", networkNameOrId); } } catch (MsoException me) { me.addContext ("QueryNetwork"); - String error = "Query Network (neutron): " + networkNameOrId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null); - LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkNameOrId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - Query Network (neutron)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - Query Network (neutron): {} in {}/{} ", MessageEnum.RA_QUERY_NETWORK_EXC, + MsoLogger.ErrorCode.DataError.getValue(), networkNameOrId, cloudSiteId, tenantId, me); throw new NetworkException (me); } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully queried network"); return; } @@ -1464,11 +1291,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Holder <Boolean> networkDeleted) throws NetworkException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("DeleteNetwork"); - LOGGER.debug ("*** DELETE Network adapter with Network: " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId); + logger.debug("*** DELETE Network adapter with Network: {} in {}/{}", networkId, cloudSiteId, tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -1478,8 +1301,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { || commonUtils.isNullOrEmpty(tenantId) || commonUtils.isNullOrEmpty(networkId)) { String error = "Missing mandatory parameter cloudSiteId, tenantId or networkId"; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkId", "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + logger.error("{} {} {} ", MessageEnum.RA_MISSING_PARAM, MsoLogger.ErrorCode.DataError.getValue(), error); throw new NetworkException (error, MsoExceptionCategory.USERDATA); } @@ -1499,7 +1321,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String mode = ""; if (networkResource != null) { - LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + logger.debug("Got Network definition from Catalog: {}", networkResource.toString()); mode = networkResource.getOrchestrationMode (); } @@ -1512,20 +1334,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // The deleteNetwork function in MsoNeutronUtils returns success if the network // was not found. So don't bother to query first. boolean deleted = neutron.deleteNetwork (networkId, tenantId, cloudSiteId); - LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null); networkDeleted.value = deleted; } catch (MsoException me) { me.addContext ("DeleteNetwork"); - String error = "Delete Network (neutron): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null); - LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (neutron)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Delete Network (neutron): {} in {}/{} ", MessageEnum.RA_DELETE_NETWORK_EXC, + MsoLogger.ErrorCode.DataError.getValue(), networkId, cloudSiteId, tenantId, me); throw new NetworkException (me); } } else { // DEFAULT to ("HEAT".equals (mode)) @@ -1539,7 +1352,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) { heat.deleteStack (tenantId, cloudSiteId, networkId, true); - LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null); networkDeleted.value = true; } else @@ -1548,23 +1360,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } catch (MsoException me) { me.addContext ("DeleteNetwork"); - String error = "Delete Network (heat): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); - LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (heat)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Delete Network (heat): {} in {}/{} ", MessageEnum.RA_DELETE_NETWORK_EXC, + MsoLogger.ErrorCode.DataError.getValue(), networkId, cloudSiteId, tenantId, me); throw new NetworkException (me); } } // On success, nothing is returned. - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully deleted network"); return; } @@ -1584,8 +1387,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { long startTime = System.currentTimeMillis (); if (rollback == null) { - LOGGER.error (MessageEnum.RA_ROLLBACK_NULL, "Openstack", "", MsoLogger.ErrorCode.DataError, "rollback is null"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "No action to perform"); + logger + .error("{} {} rollback is null", MessageEnum.RA_ROLLBACK_NULL, MsoLogger.ErrorCode.DataError.getValue()); return; } @@ -1598,9 +1401,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String networkType = rollback.getNetworkType (); String modelCustomizationUuid = rollback.getModelCustomizationUuid(); - LOGGER.debug ("*** ROLLBACK Network " + networkId + " in " + cloudSiteId + "/" + tenantId); + logger.debug("*** ROLLBACK Network {} in {}/{}", networkId, cloudSiteId, tenantId); - // Retrieve the Network Resource definition NetworkResource networkResource = null; @@ -1612,7 +1414,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String mode = ""; if (networkResource != null) { - LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ()); + logger.debug("Got Network definition from Catalog: {}", networkResource.toString()); mode = networkResource.getOrchestrationMode (); } @@ -1626,19 +1428,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // The deleteNetwork function in MsoNeutronUtils returns success if the network // was not found. So don't bother to query first. neutron.deleteNetwork (networkId, tenantId, cloudSiteId); - LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null); } catch (MsoException me) { me.addContext ("RollbackNetwork"); - String error = "Rollback Network (neutron): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null); - LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (neutron)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - Rollback Network (neutron): {} in {}/{} ", + MessageEnum.RA_DELETE_NETWORK_EXC, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + networkId, cloudSiteId, tenantId, me); throw new NetworkException (me); } } else { // DEFAULT to if ("HEAT".equals (mode)) @@ -1647,25 +1441,16 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // The deleteStack function in MsoHeatUtils returns success if the stack // was not found. So don't bother to query first. heat.deleteStack (tenantId, cloudSiteId, networkId, true); - LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null); } catch (MsoException me) { me.addContext ("RollbackNetwork"); - String error = "Rollback Network (heat): " + networkId - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; - LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); - LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (heat)", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - Rollback Network (heat): {} in {}/{} ", + MessageEnum.RA_DELETE_NETWORK_EXC, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + networkId, cloudSiteId, tenantId, me); throw new NetworkException (me); } } } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully rolled back network"); return; } @@ -1740,7 +1525,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { { String routeTarget = rt.getRouteTarget(); String routeTargetRole = rt.getRouteTargetRole(); - LOGGER.debug("Checking for an actually null route target: " + rt.toString()); + logger.debug("Checking for an actually null route target: {}", rt); if (routeTarget == null || routeTarget.equals("") || routeTarget.equalsIgnoreCase("null")) rtIsNull = true; if (routeTargetRole == null || routeTargetRole.equals("") || routeTargetRole.equalsIgnoreCase("null")) @@ -1749,7 +1534,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { rtIsNull = true; } if (!rtIsNull) { - LOGGER.debug("Input RT:" + rt.toString()); + logger.debug("Input RT:{}", rt); String role = rt.getRouteTargetRole(); String rtValue = rt.getRouteTarget(); @@ -1827,7 +1612,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { ContrailPolicyRefSeq refSeq = new ContrailPolicyRefSeq(String.valueOf(index), "0"); pr.setSeq(refSeq); index++; - LOGGER.debug("Contrail PolicyRefs Data:" + pr.toString()); + logger.debug("Contrail PolicyRefs Data:{}", pr); prlist.add(pr); } } @@ -1838,12 +1623,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { ObjectMapper mapper = new ObjectMapper(); node = mapper.convertValue(prlist, JsonNode.class); String jsonString = mapper.writeValueAsString(prlist); - LOGGER.debug("Json PolicyRefs Data:" + jsonString); + logger.debug("Json PolicyRefs Data:{}", jsonString); } catch (Exception e) { String error = "Error creating JsonNode for policyRefs Data"; - LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "Openstack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception creating JsonNode for policyRefs Data", e); + logger.error("{} {} {} ", MessageEnum.RA_MARSHING_ERROR, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + error, e); throw new MsoAdapterException (error); } //update parameters @@ -1863,7 +1649,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { stackParams.put ("policy_refsdata", node); } - LOGGER.debug ("StackParams updated with policy refs"); + logger.debug("StackParams updated with policy refs"); return; } @@ -1885,7 +1671,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { stackParams.put ("route_table_refs", csl); } - LOGGER.debug ("StackParams updated with route_table refs"); + logger.debug("StackParams updated with route_table refs"); return; } @@ -1948,9 +1734,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { //Resource Property List<ContrailSubnet> cslist = new ArrayList <> (); for (Subnet subnet : subnets) { - LOGGER.debug("Input Subnet:" + subnet.toString()); + logger.debug("Input Subnet:{}", subnet.toString()); ContrailSubnet cs = new ContrailSubnetMapper(subnet).map(); - LOGGER.debug("Contrail Subnet:" + cs.toString()); + logger.debug("Contrail Subnet:{}", cs.toString()); cslist.add(cs); } @@ -1960,12 +1746,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { ObjectMapper mapper = new ObjectMapper(); node = mapper.convertValue(cslist, JsonNode.class); String jsonString = mapper.writeValueAsString(cslist); - LOGGER.debug("Json Subnet List:" + jsonString); + logger.debug("Json Subnet List:{}", jsonString); } catch (Exception e) { String error = "Error creating JsonNode from input subnets"; - LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.DataError, "Exception creating JsonNode from input subnets", e); + logger.error("{} {} {} ", MessageEnum.RA_MARSHING_ERROR, MsoLogger.ErrorCode.DataError.getValue(), error, e); throw new MsoAdapterException (error); } //update parameters @@ -1980,7 +1766,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // append outputs in heatTemplate int outputsIdx = heatTemplate.indexOf ("outputs:"); heatTemplate = insertStr (heatTemplate, outputTempl, outputsIdx + 8); - LOGGER.debug ("Template updated with all AIC3.0 subnets:" + heatTemplate); + logger.debug("Template updated with all AIC3.0 subnets:{}", heatTemplate); return heatTemplate; } @@ -2018,7 +1804,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { curR = curR.replace ("%subnetId%", subnet.getSubnetId ()); } else { String error = "Missing Required AAI SubnetId for subnet in HEAT Template"; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required AAI ID for subnet in HEAT Template"); + logger.error("{} {} {} ", MessageEnum.RA_MISSING_PARAM, MsoLogger.ErrorCode.DataError.getValue(), error); throw new MsoAdapterException (error); } @@ -2032,7 +1818,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { curR = curR.replace ("%cidr%", subnet.getCidr ()); } else { String error = "Missing Required cidr for subnet in HEAT Template"; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required cidr for subnet in HEAT Template"); + logger.error("{} {} {} ", MessageEnum.RA_MISSING_PARAM, MsoLogger.ErrorCode.DataError.getValue(), error); throw new MsoAdapterException (error); } @@ -2067,13 +1853,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } // append resources and outputs in heatTemplate - LOGGER.debug ("Tempate initial:" + heatTemplate); + logger.debug("Tempate initial:{}", heatTemplate); int outputsIdx = heatTemplate.indexOf ("outputs:"); heatTemplate = insertStr (heatTemplate, outputsBuf.toString (), outputsIdx + 8); int resourcesIdx = heatTemplate.indexOf ("resources:"); heatTemplate = insertStr (heatTemplate, resourcesBuf.toString (), resourcesIdx + 10); - LOGGER.debug ("Template updated with all subnets:" + heatTemplate); + logger.debug("Template updated with all subnets:{}", heatTemplate); return heatTemplate; } @@ -2085,12 +1871,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Object obj = outputs.get(key); ObjectMapper mapper = new ObjectMapper(); String jStr = mapper.writeValueAsString(obj); - LOGGER.debug ("Subnet_Ipam Output JSON String:" + obj.getClass() + " " + jStr); + logger.debug("Subnet_Ipam Output JSON String:{} {}", obj.getClass(), jStr); JsonNode rootNode = mapper.readTree(jStr); for (JsonNode sNode : rootNode.path("ipam_subnets")) { - LOGGER.debug("Output Subnet Node" + sNode.toString()); + logger.debug("Output Subnet Node {}", sNode.toString()); String name = sNode.path("subnet_name").textValue(); String uuid = sNode.path("subnet_uuid").textValue(); String aaiId = name; // default @@ -2114,10 +1900,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } catch (Exception e) { - LOGGER.error (MessageEnum.RA_MARSHING_ERROR, "error getting subnet-uuids", "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception getting subnet-uuids", e); + logger.error("{} {} Exception getting subnet-uuids ", MessageEnum.RA_MARSHING_ERROR, + MsoLogger.ErrorCode.DataError.getValue(), e); } - LOGGER.debug ("Return sMap" + sMap.toString()); + logger.debug("Return sMap {}", sMap.toString()); return sMap; } @@ -2125,14 +1912,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String updatedTemplate; - LOGGER.debug ("Index:" + index + " Snippet:" + snippet); + logger.debug("Index:{} Snippet:{}", index, snippet); String templateBeg = template.substring (0, index); String templateEnd = template.substring (index); updatedTemplate = templateBeg + "\n" + snippet + templateEnd; - LOGGER.debug ("Template updated with a subnet:" + updatedTemplate); + logger.debug("Template updated with a subnet:{}", updatedTemplate); return updatedTemplate; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java index fd658244ee..8f9152a86d 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -22,10 +24,14 @@ package org.onap.so.adapters.network; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.inject.Provider; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -40,7 +46,6 @@ import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.xml.ws.Holder; - import org.apache.http.HttpStatus; import org.onap.so.adapters.network.exceptions.NetworkException; import org.onap.so.adapters.nwrest.ContrailNetwork; @@ -67,31 +72,25 @@ import org.onap.so.openstack.beans.NetworkRollback; import org.onap.so.openstack.beans.NetworkStatus; import org.onap.so.openstack.beans.RouteTarget; import org.onap.so.openstack.exceptions.MsoExceptionCategory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - @Path("/v1/networks") @Api(value = "/v1/networks", description = "root of network adapters restful web service") @Component @Transactional public class NetworkAdapterRest { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,NetworkAdapterRest.class); + + private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterRest.class); private static final String TESTING_KEYWORD = "___TESTING___"; - private String APPEND_RESPONSE = ", resp="; private String EXCEPTION = "Exception:"; @Autowired private MsoNetworkAdapterImpl adapter; @Autowired - @Qualifier("NetworkBpel") private Provider<BpelRestClient> bpelRestClientProvider; @@ -109,7 +108,7 @@ public class NetworkAdapterRest { public Response createNetwork( @ApiParam(value = "details of network being created", required = true) CreateNetworkRequest req) { - LOGGER.debug("createNetwork enter: " + req.toJsonString()); + logger.debug("createNetwork enter: {}", req.toJsonString()); CreateNetworkTask task = new CreateNetworkTask(req); if (req.isSynchronous()) { // This is a synchronous request @@ -125,11 +124,12 @@ public class NetworkAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while create network", e); + logger.error("{} {} Exception while create network ", MessageEnum.RA_CREATE_NETWORK_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("createNetwork exit"); + logger.debug("createNetwork exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -161,7 +161,7 @@ public class NetworkAdapterRest { } @Override public void run() { - LOGGER.debug ("CreateNetworkTask start"); + logger.debug("CreateNetworkTask start"); try { // Synchronous Web Service Outputs Holder<String> networkId = new Holder<>(); @@ -269,7 +269,7 @@ public class NetworkAdapterRest { rollback.value, req.getMessageId()); } catch (NetworkException e) { - LOGGER.debug (EXCEPTION, e); + logger.debug(EXCEPTION, e); eresp = new CreateNetworkError( e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } @@ -278,7 +278,7 @@ public class NetworkAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("CreateNetworkTask exit: code=" + getStatusCode() + APPEND_RESPONSE+ getResponse()); + logger.debug("CreateNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse()); } } @@ -299,7 +299,7 @@ public class NetworkAdapterRest { @ApiParam(value = "details of network being deleted", required = true) DeleteNetworkRequest req) { - LOGGER.debug("deleteNetwork enter: " + req.toJsonString()); + logger.debug("deleteNetwork enter: {}", req.toJsonString()); if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) { return Response .status(HttpStatus.SC_BAD_REQUEST) @@ -322,11 +322,12 @@ public class NetworkAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while delete network", e); + logger.error("{} {} Exception while delete network ", MessageEnum.RA_DELETE_NETWORK_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("deleteNetwork exit"); + logger.debug("deleteNetwork exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -358,7 +359,7 @@ public class NetworkAdapterRest { } @Override public void run() { - LOGGER.debug("DeleteNetworkTask start"); + logger.debug("DeleteNetworkTask start"); try { Holder<Boolean> networkDeleted = new Holder<>(); if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { @@ -375,7 +376,7 @@ public class NetworkAdapterRest { } response = new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId()); } catch (NetworkException e) { - LOGGER.debug (EXCEPTION, e); + logger.debug(EXCEPTION, e); eresp = new DeleteNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -383,7 +384,7 @@ public class NetworkAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("DeleteNetworkTask exit: code=" + getStatusCode() + APPEND_RESPONSE+ getResponse()); + logger.debug("DeleteNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse()); } } @@ -413,7 +414,7 @@ public class NetworkAdapterRest { @PathParam("aaiNetworkId") String aaiNetworkId) { //This request responds synchronously only - LOGGER.debug ("Query network enter:" + aaiNetworkId); + logger.debug("Query network enter:{}" + aaiNetworkId); MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); try { @@ -430,10 +431,10 @@ public class NetworkAdapterRest { networkExists, networkId, neutronNetworkId, status, routeTargets, subnetIdMap); if (!networkExists.value) { - LOGGER.debug ("network not found"); + logger.debug("network not found"); respStatus = HttpStatus.SC_NOT_FOUND; } else { - LOGGER.debug ("network found" + networkId.value + ", status=" + status.value); + logger.debug("network found {}, status={}", networkId.value, status.value); resp.setNetworkExists(networkExists.value); resp.setNetworkId(networkId.value); resp.setNeutronNetworkId(neutronNetworkId.value); @@ -441,13 +442,14 @@ public class NetworkAdapterRest { resp.setRouteTargets(routeTargets.value); resp.setSubnetIdMap(subnetIdMap.value); } - LOGGER.debug ("Query network exit"); + logger.debug("Query network exit"); return Response .status(respStatus) .entity(new GenericEntity<QueryNetworkResponse>(resp) {}) .build(); } catch (NetworkException e) { - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, aaiNetworkId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception when query VNF", e); + logger.error("{} {} Exception when query VNF ", MessageEnum.RA_QUERY_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); QueryNetworkError err = new QueryNetworkError(); err.setMessage(e.getMessage()); err.setCategory(MsoExceptionCategory.INTERNAL); @@ -473,7 +475,7 @@ public class NetworkAdapterRest { @ApiParam(value = "RollbackNetworkRequest in JSON format", required = true) RollbackNetworkRequest req) { - LOGGER.debug("rollbackNetwork enter: " + req.toJsonString()); + logger.debug("rollbackNetwork enter: {}", req.toJsonString()); RollbackNetworkTask task = new RollbackNetworkTask(req); if (req.isSynchronous()) { // This is a synchronous request @@ -489,11 +491,12 @@ public class NetworkAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in rollbackNetwork", e); + logger.error("{} {} Exception in rollbackNetwork ", MessageEnum.RA_ROLLBACK_NULL, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug("rollbackNetwork exit"); + logger.debug("rollbackNetwork exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -525,13 +528,13 @@ public class NetworkAdapterRest { } @Override public void run() { - LOGGER.debug("RollbackNetworkTask start"); + logger.debug("RollbackNetworkTask start"); try { NetworkRollback nwr = req.getNetworkRollback(); adapter.rollbackNetwork(nwr); response = new RollbackNetworkResponse(true, req.getMessageId()); } catch (NetworkException e) { - LOGGER.debug (EXCEPTION, e); + logger.debug(EXCEPTION, e); eresp = new RollbackNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -539,7 +542,7 @@ public class NetworkAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("RollbackNetworkTask exit: code=" + getStatusCode() + APPEND_RESPONSE+ getResponse()); + logger.debug("RollbackNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse()); } } @@ -560,7 +563,7 @@ public class NetworkAdapterRest { @ApiParam(value = "UpdateNetworkRequest in JSON format", required = true) UpdateNetworkRequest req) { - LOGGER.debug("updateNetwork enter: " + req.toJsonString()); + logger.debug("updateNetwork enter: {}", req.toJsonString()); if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) { return Response .status(HttpStatus.SC_BAD_REQUEST) @@ -583,11 +586,12 @@ public class NetworkAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_UPDATE_NETWORK_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in updateNetwork", e); + logger.error("{} {} Exception in updateNetwork ", MessageEnum.RA_UPDATE_NETWORK_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("updateNetwork exit"); + logger.debug("updateNetwork exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -619,7 +623,7 @@ public class NetworkAdapterRest { } @Override public void run() { - LOGGER.debug("UpdateNetworkTask start"); + logger.debug("UpdateNetworkTask start"); try { Holder<Map<String, String>> subnetIdMap = new Holder<>(); Holder<NetworkRollback> rollback = new Holder<> (); @@ -709,7 +713,7 @@ public class NetworkAdapterRest { subnetIdMap.value, req.getMessageId()); } catch (NetworkException e) { - LOGGER.debug (EXCEPTION, e); + logger.debug(EXCEPTION, e); eresp = new UpdateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -717,7 +721,7 @@ public class NetworkAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("UpdateNetworkTask exit: code=" + getStatusCode() + APPEND_RESPONSE+ getResponse()); + logger.debug("UpdateNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse()); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java index b86681ebfc..db9226bb19 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +25,10 @@ package org.onap.so.adapters.tenant; import java.util.Map; - import javax.annotation.Resource; import javax.jws.WebService; import javax.xml.ws.Holder; import javax.xml.ws.WebServiceContext; - import org.onap.so.adapters.tenant.exceptions.TenantAlreadyExists; import org.onap.so.adapters.tenant.exceptions.TenantException; import org.onap.so.adapters.tenantrest.TenantRollback; @@ -41,6 +40,8 @@ import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.utils.MsoTenantUtils; import org.onap.so.openstack.utils.MsoTenantUtilsFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -52,14 +53,13 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { public static final String QUERY_TENANT = "QueryTenant"; public static final String DELETE_TENANT = "DeleteTenant"; public static final String ROLLBACK_TENANT = "RollbackTenant"; - private static final String SUCCESS_RESPONSE_OPENSTACK="Successfully received response from Open Stack"; - private static final String OPENSTACK_COMMUNICATE_EXCEPTION_MSG="Exception while communicate with Open Stack"; + private static final String OPENSTACK_COMMUNICATE_EXCEPTION_MSG = "{} {} Exception while communicate with Open Stack "; @Resource private WebServiceContext wsContext; @Autowired private MsoTenantUtilsFactory tFactory; - private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,MsoTenantAdapterImpl.class); + private static Logger logger = LoggerFactory.getLogger(MsoTenantAdapterImpl.class); /** * Health Check web method. Does nothing but return to show the adapter is deployed. */ @@ -91,12 +91,7 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName (CREATE_TENANT); - logger.debug ("Call to MSO createTenant adapter. Creating Tenant: " + tenantName - + "in " - + cloudSiteId); - - // Will capture total time for metrics - long startTime = System.currentTimeMillis (); + logger.debug("Call to MSO createTenant adapter. Creating Tenant: {} in {}", tenantName, cloudSiteId); // Start building up rollback object TenantRollback tenantRollback = new TenantRollback (); @@ -107,57 +102,47 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { try { tUtils = tFactory.getTenantUtils (cloudSiteId); } catch (MsoCloudSiteNotFound me) { - logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, CREATE_TENANT, MsoLogger.ErrorCode.DataError, "no implementation found for " + cloudSiteId, me); + logger.error("{} {} no implementation found for {}: ", MessageEnum.RA_CREATE_TENANT_ERR, + MsoLogger.ErrorCode.DataError.getValue(), cloudSiteId, me); throw new TenantException (me); } MsoTenant newTenant = null; String newTenantId; - long queryTenantStartTime = System.currentTimeMillis (); try { newTenant = tUtils.queryTenantByName (tenantName, cloudSiteId); - logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_RESPONSE_OPENSTACK, OPENSTACK, QUERY_TENANT, null); } catch (MsoException me) { - logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, OPENSTACK_COMMUNICATE_EXCEPTION_MSG, OPENSTACK, QUERY_TENANT, null); - String error = "Create Tenant " + tenantName + ": " + me; - logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, CREATE_TENANT, MsoLogger.ErrorCode.DataError, OPENSTACK_COMMUNICATE_EXCEPTION_MSG, me); - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error(OPENSTACK_COMMUNICATE_EXCEPTION_MSG, MessageEnum.RA_CREATE_TENANT_ERR, + MsoLogger.ErrorCode.DataError.getValue(), me); throw new TenantException (me); } if (newTenant == null) { if (backout == null) backout = true; - long createTenantStartTime = System.currentTimeMillis (); try { newTenantId = tUtils.createTenant (tenantName, cloudSiteId, metadata, backout.booleanValue ()); - logger.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_RESPONSE_OPENSTACK, OPENSTACK, CREATE_TENANT, null); } catch (MsoException me) { - logger.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, OPENSTACK_COMMUNICATE_EXCEPTION_MSG, OPENSTACK, CREATE_TENANT, null); - String error = "Create Tenant " + tenantName + ": " + me; - logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, CREATE_TENANT, MsoLogger.ErrorCode.DataError, OPENSTACK_COMMUNICATE_EXCEPTION_MSG, me); - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error (OPENSTACK_COMMUNICATE_EXCEPTION_MSG, MessageEnum.RA_CREATE_TENANT_ERR, MsoLogger.ErrorCode.DataError.getValue(), me); throw new TenantException (me); } tenantRollback.setTenantId (newTenantId); tenantRollback.setTenantCreated (true); - logger.debug ("Tenant " + tenantName + " successfully created with ID " + newTenantId); + logger.debug ("Tenant {} successfully created with ID {}", tenantName, newTenantId); } else { if (failIfExists != null && failIfExists) { - String error = CREATE_TENANT + ": Tenant " + tenantName + " already exists in " + cloudSiteId; - logger.error (MessageEnum.RA_TENANT_ALREADY_EXIST, tenantName, cloudSiteId, OPENSTACK, "", MsoLogger.ErrorCode.DataError, CREATE_TENANT + ", Tenant already exists"); - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + logger.error("{} {} CreateTenant: Tenant {} already exists in {} ", MessageEnum.RA_TENANT_ALREADY_EXIST, + MsoLogger.ErrorCode.DataError.getValue(), tenantName, cloudSiteId); throw new TenantAlreadyExists (tenantName, cloudSiteId, newTenant.getTenantId ()); } newTenantId = newTenant.getTenantId (); tenantRollback.setTenantCreated (false); - logger.debug ("Tenant " + tenantName + " already exists with ID " + newTenantId); + logger.debug("Tenant {} already exists with ID {}", tenantName, newTenantId); } tenantId.value = newTenantId; rollback.value = tenantRollback; - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create tenant"); return; } @@ -170,48 +155,41 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { Holder <Map <String, String>> metadata) throws TenantException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName (QUERY_TENANT); - logger.debug ("Querying Tenant " + tenantNameOrId + " in " + cloudSiteId); - - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); + logger.debug ("Querying Tenant {} in {}", tenantNameOrId, cloudSiteId); MsoTenantUtils tUtils; try { tUtils = tFactory.getTenantUtils (cloudSiteId); } catch (MsoCloudSiteNotFound me) { - logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, CREATE_TENANT, MsoLogger.ErrorCode.DataError, "no implementation found for " + cloudSiteId, me); + logger.error("{} {} no implementation found for {}: ", MessageEnum.RA_CREATE_TENANT_ERR, + MsoLogger.ErrorCode.DataError.getValue(), cloudSiteId, me); throw new TenantException (me); } MsoTenant qTenant = null; - long subStartTime = System.currentTimeMillis (); try { qTenant = tUtils.queryTenant (tenantNameOrId, cloudSiteId); - logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_RESPONSE_OPENSTACK, OPENSTACK, QUERY_TENANT, null); if (qTenant == null) { // Not found by ID, Try by name. qTenant = tUtils.queryTenantByName (tenantNameOrId, cloudSiteId); } if (qTenant == null) { - logger.debug ("QueryTenant: Tenant " + tenantNameOrId + " not found"); + logger.debug ("QueryTenant: Tenant {} not found", tenantNameOrId); tenantId.value = null; tenantName.value = null; metadata.value = null; } else { - logger.debug ("QueryTenant: Tenant " + tenantNameOrId + " found with ID " + qTenant.getTenantId ()); + logger.debug("QueryTenant: Tenant {} found with ID {}", tenantNameOrId, qTenant.getTenantId()); tenantId.value = qTenant.getTenantId (); tenantName.value = qTenant.getTenantName (); metadata.value = qTenant.getMetadata (); } } catch (MsoException me) { - String error = "Query Tenant " + tenantNameOrId + ": " + me; - logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, OPENSTACK, QUERY_TENANT, null); - logger.error (MessageEnum.RA_GENERAL_EXCEPTION, me.getMessage(), OPENSTACK, "", MsoLogger.ErrorCode.DataError, "Exception in queryTenant", me); - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("Exception in queryTenant for {}: ", MessageEnum.RA_GENERAL_EXCEPTION, + MsoLogger.ErrorCode.DataError.getValue(), tenantNameOrId, me); throw new TenantException (me); } - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query tenant"); return; } @@ -223,29 +201,21 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName (DELETE_TENANT); - logger.debug ("Deleting Tenant " + tenantId + " in " + cloudSiteId); - - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); + logger.debug ("Deleting Tenant {} in {}", tenantId, cloudSiteId); // Delete the Tenant. - long subStartTime = System.currentTimeMillis (); try { MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId); boolean deleted = tUtils.deleteTenant (tenantId, cloudSiteId); tenantDeleted.value = deleted; - logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully communicate with Open Stack", OPENSTACK, DELETE_TENANT, null); } catch (MsoException me) { - String error = "Delete Tenant " + tenantId + ": " + me; - logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, OPENSTACK, DELETE_TENANT, null); - logger.error (MessageEnum.RA_DELETE_TEMAMT_ERR, me.getMessage(), OPENSTACK, "", MsoLogger.ErrorCode.DataError, "Exception - DeleteTenant", me); - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - DeleteTenant {}: ", MessageEnum.RA_DELETE_TEMAMT_ERR, + MsoLogger.ErrorCode.DataError.getValue(), tenantId, me); throw new TenantException (me); } // On success, nothing is returned. - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete tenant"); return; } @@ -260,11 +230,11 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { */ @Override public void rollbackTenant (TenantRollback rollback) throws TenantException { - long startTime = System.currentTimeMillis (); MsoLogger.setServiceName (ROLLBACK_TENANT); // rollback may be null (e.g. if stack already existed when Create was called) if (rollback == null) { - logger.warn (MessageEnum.RA_ROLLBACK_NULL, OPENSTACK, "rollbackTenant", MsoLogger.ErrorCode.DataError, "rollbackTenant, rollback is null"); + logger.warn("{} {} rollbackTenant, rollback is null", MessageEnum.RA_ROLLBACK_NULL, + MsoLogger.ErrorCode.DataError.getValue()); return; } @@ -273,26 +243,21 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { String tenantId = rollback.getTenantId (); MsoLogger.setLogContext (rollback.getMsoRequest ()); - logger.debug ("Rolling Back Tenant " + rollback.getTenantId () + " in " + cloudSiteId); + logger.debug("Rolling Back Tenant {} in {}", rollback.getTenantId(), cloudSiteId); - long subStartTime = System.currentTimeMillis (); if (rollback.getTenantCreated ()) { try { MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId); tUtils.deleteTenant (tenantId, cloudSiteId); - logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully communicate with Open Stack", OPENSTACK, ROLLBACK_TENANT, null); } catch (MsoException me) { me.addContext (ROLLBACK_TENANT); // Failed to delete the tenant. - String error = "Rollback Tenant " + tenantId + ": " + me; - logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, OPENSTACK, ROLLBACK_TENANT, null); - logger.error (MessageEnum.RA_ROLLBACK_TENANT_ERR, me.getMessage(), OPENSTACK, "rollbackTenant", MsoLogger.ErrorCode.DataError, "Exception - rollbackTenant", me); - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} Exception - rollbackTenant {}: ", MessageEnum.RA_ROLLBACK_TENANT_ERR, + MsoLogger.ErrorCode.DataError.getValue(), tenantId, me); throw new TenantException (me); } } - logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back tenant"); return; } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/TenantAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/TenantAdapterRest.java index 41544c8104..11051df34e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/TenantAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/TenantAdapterRest.java @@ -6,6 +6,7 @@ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +25,12 @@ package org.onap.so.adapters.tenant; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import java.util.Map; - import javax.servlet.http.HttpServletResponse; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -38,7 +43,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.xml.ws.Holder; - import org.onap.so.adapters.tenant.exceptions.TenantAlreadyExists; import org.onap.so.adapters.tenant.exceptions.TenantException; import org.onap.so.adapters.tenantrest.CreateTenantError; @@ -53,18 +57,13 @@ import org.onap.so.adapters.tenantrest.RollbackTenantError; import org.onap.so.adapters.tenantrest.RollbackTenantRequest; import org.onap.so.adapters.tenantrest.RollbackTenantResponse; import org.onap.so.adapters.tenantrest.TenantRollback; -import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.exceptions.MsoExceptionCategory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - /** * This class services calls to the REST interface for Tenants (http://host:port/vnfs/rest/v1/tenants) * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. @@ -73,7 +72,8 @@ import io.swagger.annotations.ApiResponses; @Api(value = "/v1/tenants", description = "root of tenant adapters restful web service") @Component public class TenantAdapterRest { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, TenantAdapterRest.class); + + private static Logger logger = LoggerFactory.getLogger(TenantAdapterRest.class); private static final String EXCEPTION= "Exception :"; //RAA? No logging in wrappers @Autowired @@ -122,7 +122,7 @@ public class TenantAdapterRest { public Response createTenant( @ApiParam(value = "details of tenant being created", required = true) CreateTenantRequest req) { - LOGGER.debug("createTenant enter: " + req.toJsonString()); + logger.debug("createTenant enter: {}", req.toJsonString()); String newTenantId = null; TenantRollback tenantRollback = new TenantRollback (); @@ -145,17 +145,17 @@ public class TenantAdapterRest { } catch (TenantAlreadyExists tae) { - LOGGER.debug(EXCEPTION,tae); + logger.debug(EXCEPTION, tae); CreateTenantError exc = new CreateTenantError(tae.getMessage(), tae.getFaultInfo().getCategory(), Boolean.TRUE); return Response.status(HttpServletResponse.SC_NOT_IMPLEMENTED).entity(exc).build(); } catch (TenantException te) { - LOGGER.debug(EXCEPTION,te); + logger.debug(EXCEPTION, te); CreateTenantError exc = new CreateTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } catch (Exception e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); CreateTenantError exc = new CreateTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } @@ -208,12 +208,12 @@ public class TenantAdapterRest { tenantDeleted = deleted.value; } catch (TenantException te) { - LOGGER.debug(EXCEPTION,te); + logger.debug(EXCEPTION, te); DeleteTenantError exc = new DeleteTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } catch (Exception e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); DeleteTenantError exc = new DeleteTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } @@ -272,12 +272,12 @@ public class TenantAdapterRest { } catch (TenantException te) { - LOGGER.debug(EXCEPTION,te); + logger.debug(EXCEPTION, te); QueryTenantError exc = new QueryTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory()); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } catch (Exception e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); QueryTenantError exc = new QueryTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } @@ -321,12 +321,12 @@ public class TenantAdapterRest { impl.rollbackTenant(req.getTenantRollback()); } catch (TenantException te) { - LOGGER.debug(EXCEPTION,te); + logger.debug(EXCEPTION, te); RollbackTenantError exc = new RollbackTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } catch (Exception e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); RollbackTenantError exc = new RollbackTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java index 4b02b73786..7265a59397 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -24,10 +26,8 @@ package org.onap.so.adapters.vnf; import java.security.GeneralSecurityException; import java.util.Set; import java.util.TreeSet; - import javax.annotation.PostConstruct; import javax.xml.bind.DatatypeConverter; - import org.apache.http.HttpEntity; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; @@ -40,6 +40,8 @@ import org.apache.http.util.EntityUtils; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.utils.CryptoUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.core.env.Environment; @@ -69,7 +71,7 @@ public class BpelRestClient { private static final String RETRY_INTERVAL_PROPERTY = PROPERTY_DOMAIN+".retryinterval"; private static final String RETRY_LIST_PROPERTY = PROPERTY_DOMAIN+".retrylist"; private static final String ENCRYPTION_KEY_PROP = "org.onap.so.adapters.network.encryptionKey"; - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, BpelRestClient.class); + private static final Logger logger = LoggerFactory.getLogger(BpelRestClient.class); /** Default socket timeout (in seconds) */ public static final int DEFAULT_SOCKET_TIMEOUT = 5; @@ -218,7 +220,8 @@ public class BpelRestClient { } if (totalretries >= retryCount) { debug("Retried " + totalretries + " times, giving up."); - LOGGER.error(MessageEnum.RA_SEND_VNF_NOTIF_ERR, "Could not deliver response to BPEL after "+totalretries+" tries: "+toBpelStr, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Could not deliver response to BPEL"); + logger.error("{} {} Could not deliver response to BPEL after {} tries: {}", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), totalretries, toBpelStr); return false; } totalretries++; @@ -232,26 +235,26 @@ public class BpelRestClient { try { Thread.sleep(sleepinterval * 1000L); } catch (InterruptedException e) { - LOGGER.debug("Exception while Thread sleep", e); + logger.debug("Exception while Thread sleep", e); Thread.currentThread().interrupt(); } } } private void debug(String m) { - LOGGER.debug(m); + logger.debug(m); } private void sendOne(final String toBpelStr, final String bpelUrl, final boolean isxml) { - LOGGER.debug("Sending to BPEL server: "+bpelUrl); - LOGGER.debug("Content is: "+toBpelStr); + logger.debug("Sending to BPEL server: {}", bpelUrl); + logger.debug("Content is: {}", toBpelStr); //POST HttpPost post = new HttpPost(bpelUrl); if (credentials != null && !credentials.isEmpty()) post.addHeader("Authorization", "Basic " + DatatypeConverter.printBase64Binary(credentials.getBytes())); - LOGGER.debug("HTTPPost Headers: " + post.getAllHeaders()); - - //ContentType + logger.debug("HTTPPost Headers: {}", post.getAllHeaders()); + + //ContentType ContentType ctype = isxml ? ContentType.APPLICATION_XML : ContentType.APPLICATION_JSON; post.setEntity(new StringEntity(toBpelStr, ctype)); @@ -274,14 +277,14 @@ public class BpelRestClient { lastResponse = ""; } } catch (Exception e) { - String error = "Error sending Bpel notification:" + toBpelStr; - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Error sending Bpel notification", e); + logger.error("{} {} Exception - Error sending Bpel notification: {} ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), toBpelStr, e); lastResponseCode = 900; lastResponse = ""; } - LOGGER.debug("Response code from BPEL server: "+lastResponseCode); - LOGGER.debug("Response body is: "+lastResponse); + logger.debug("Response code from BPEL server: {}", lastResponseCode); + logger.debug("Response body is: {}", lastResponse); } private String getEncryptedProperty(String key, String defaultValue, String encryptionKey) { @@ -289,7 +292,7 @@ public class BpelRestClient { try { return CryptoUtils.decrypt(env.getProperty(key), env.getProperty(encryptionKey)); } catch (GeneralSecurityException e) { - LOGGER.debug("Exception while decrypting property: " + env.getProperty(key), e); + logger.debug("Exception while decrypting property: {} ", env.getProperty(key), e); } } return defaultValue; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java index 7c49c9f948..c54b067a78 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java @@ -50,7 +50,7 @@ public interface MsoVnfAdapter @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, @WebParam(name="requestType") @XmlElement(required=false) String requestType, @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, - @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="inputs") Map<String,Object> inputs, @WebParam(name="failIfExists") Boolean failIfExists, @WebParam(name="backout") Boolean backout, @WebParam(name="enableBridge") Boolean enableBridge, @@ -68,7 +68,7 @@ public interface MsoVnfAdapter @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, @WebParam(name="requestType") @XmlElement(required=false) String requestType, @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, - @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="inputs") Map<String,Object> inputs, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) @@ -109,7 +109,7 @@ public interface MsoVnfAdapter @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, @WebParam(name="baseVfHeatStackId") @XmlElement(required=false) String baseVfHeatStackId, @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, - @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="inputs") Map<String,Object> inputs, @WebParam(name="failIfExists") Boolean failIfExists, @WebParam(name="backout") Boolean backout, @WebParam(name="enableBridge") Boolean enableBridge, @@ -138,7 +138,7 @@ public interface MsoVnfAdapter @WebParam(name="baseVfHeatStackId") @XmlElement(required=false) String baseVfHeatStackId, @WebParam(name="vfModuleStackId") @XmlElement(required=false) String vfModuleStackId, @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, - @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="inputs") Map<String,Object> inputs, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java index b67a412c3e..6f61f0292c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java @@ -53,7 +53,7 @@ public interface MsoVnfAdapterAsync @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, @WebParam(name="requestType") @XmlElement(required=false) String requestType, @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, - @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="inputs") Map<String,Object> inputs, @WebParam(name="failIfExists") Boolean failIfExists, @WebParam(name="backout") Boolean backout, @WebParam(name="enableBridge") Boolean enableBridge, @@ -70,7 +70,7 @@ public interface MsoVnfAdapterAsync @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, @WebParam(name="requestType") @XmlElement(required=false) String requestType, @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, - @WebParam(name="inputs") Map<String,String> inputs, + @WebParam(name="inputs") Map<String,Object> inputs, @WebParam(name="messageId") @XmlElement(required=true) String messageId, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java index 21b7ea4142..2c9d3776a7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -29,14 +31,12 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.jws.WebService; import javax.xml.bind.DatatypeConverter; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import javax.xml.ws.Holder; import javax.xml.ws.handler.MessageContext; - import org.onap.so.adapters.vnf.async.client.CreateVnfNotification; import org.onap.so.adapters.vnf.async.client.QueryVnfNotification; import org.onap.so.adapters.vnf.async.client.UpdateVnfNotification; @@ -45,11 +45,12 @@ import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify_Service; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.entity.MsoRequest; import org.onap.so.logger.MessageEnum; - import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; import org.onap.so.utils.CryptoUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -58,8 +59,7 @@ import org.springframework.stereotype.Component; @Component public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { - public static final String MSO_PROP_VNF_ADAPTER="MSO_PROP_VNF_ADAPTER"; - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoVnfAdapterAsyncImpl.class); + private static final Logger logger = LoggerFactory.getLogger(MsoVnfAdapterAsyncImpl.class); private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.vnf.bpelauth"; private static final String ENCRYPTION_KEY_PROP = "org.onap.so.adapters.network.encryptionKey"; @@ -75,7 +75,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { */ @Override public void healthCheckA () { - LOGGER.debug ("Health check call in VNF Adapter"); + logger.debug ("Health check call in VNF Adapter"); } /** @@ -125,7 +125,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String vnfName, String requestType, String volumeGroupHeatStackId, - Map <String, String> inputs, + Map <String, Object> inputs, Boolean failIfExists, Boolean backout, Boolean enableBridge, @@ -136,7 +136,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String serviceName = "CreateVnfA"; MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName (serviceName); - LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "createVnfA"); + logger.info("{} createVnfA", MessageEnum.RA_ASYNC_CREATE_VNF); // Use the synchronous method to perform the actual Create MsoVnfAdapter vnfAdapter = vnfImpl; // Synchronous Web Service Outputs @@ -163,7 +163,8 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { MsoLogger.setServiceName (serviceName); } catch (VnfException e) { MsoLogger.setServiceName (serviceName); - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException in createVnfA", e); + logger.error("{} {} VnfException in createVnfA ", MessageEnum.RA_CREATE_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -172,21 +173,21 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .getCategory () .name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Fault info", e1); + logger.error("{} {} Exception - Fault info ", MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } // Build and send Asynchronous error response try { VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.createVnfNotification (messageId, false, exCat, eMsg, null, null, null); } catch (Exception e1) { - error = "Error sending createVnf notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending createVnf notification", e1); - + logger.error("{} {} Exception sending createVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } - LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE, "", "createVnfA", ""); + logger.info("{}", MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE); return; } - LOGGER.debug ("Async Create VNF: " + vnfName + " VnfId:" + vnfId.value); + logger.debug("Async Create VNF: {} VnfId:{}", vnfName, vnfId.value); // Build and send Asynchronous response try { VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); @@ -198,11 +199,10 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { copyCreateOutputs (outputs), copyVrb (vnfRollback)); } catch (Exception e) { - error = "Error sending createVnf notification " + e.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending createVnf notification", e); - + logger.error("{} {} Exception sending createVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); } - LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE, "", "","createVnfA"); + logger.info("{} createVnfA", MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE); return; } @@ -214,7 +214,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String vnfName, String requestType, String volumeGroupHeatStackId, - Map <String, String> inputs, + Map <String, Object> inputs, String messageId, MsoRequest msoRequest, String notificationUrl) { @@ -222,7 +222,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String serviceName = "UpdateVnfA"; MsoLogger.setServiceName (serviceName); MsoLogger.setLogContext (msoRequest); - LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "UpdateVnfA"); + logger.info("{} UpdateVnfA", MessageEnum.RA_ASYNC_UPDATE_VNF); // Use the synchronous method to perform the actual Create MsoVnfAdapter vnfAdapter = vnfImpl; @@ -237,7 +237,8 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { MsoLogger.setServiceName (serviceName); } catch (VnfException e) { MsoLogger.setServiceName (serviceName); - LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e); + logger.error("{} {} Exception sending updateVnf notification ", MessageEnum.RA_UPDATE_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -246,21 +247,21 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .getCategory () .name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1); + logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } // Build and send Asynchronous error response try { VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.updateVnfNotification (messageId, false, exCat, eMsg, null, null); } catch (Exception e1) { - error = "Error sending updateVnf notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e1); - + logger.error("{} {} Exception sending updateVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } - LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE,"","","UpdateVnfA"); + logger.info("{} UpdateVnfA", MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE); return; } - LOGGER.debug ("Async Update VNF: " + vnfName + " VnfId:" + vnfId.value); + logger.debug("Async Update VNF: {} VnfId:{}", vnfName, vnfId.value); // Build and send Asynchronous response try { VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); @@ -271,11 +272,10 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { copyUpdateOutputs (outputs), copyVrb (vnfRollback)); } catch (Exception e) { - error = "Error sending updateVnf notification " + e.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e); - + logger.error("{} {} Exception sending updateVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); } - LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE, "", "","UpdateVnfA"); + logger.info("{} UpdateVnfA", MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE); return; } @@ -303,7 +303,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String serviceName = "QueryVnfA"; MsoLogger.setServiceName (serviceName); MsoLogger.setLogContext (msoRequest); - LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF, vnfName, cloudSiteId, tenantId); + logger.info("{}", MessageEnum.RA_ASYNC_QUERY_VNF); // Use the synchronous method to perform the actual query MsoVnfAdapter vnfAdapter = vnfImpl; @@ -319,7 +319,8 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { MsoLogger.setServiceName (serviceName); } catch (VnfException e) { MsoLogger.setServiceName (serviceName); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnfA notification", e); + logger.error("{} {} Exception sending queryVnfA notification ", MessageEnum.RA_QUERY_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -328,25 +329,25 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .getCategory () .name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1); + logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } // Build and send Asynchronous error response try { VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.queryVnfNotification (messageId, false, exCat, eMsg, null, null, null, null); } catch (Exception e1) { - error = "Error sending queryVnf notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnf notification", e1); - + logger.error("{} {} Exception sending queryVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } - LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE, "","", "queryVnfA"); + logger.info("{} queryVnfA", MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE); return; } if (!vnfExists.value) { - LOGGER.debug ("Async Query, VNF not found"); + logger.debug ("Async Query, VNF not found"); } else { - LOGGER.debug ("Async Query, VNF=" + vnfId.value + ", status=" + status.value); + logger.debug("Async Query, VNF={}, status={}", vnfId.value, status.value); } // Build and send Asynchronous response try { @@ -361,12 +362,11 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { vnfS, copyQueryOutputs (outputs)); } catch (Exception e) { - error = "Error sending queryVnf notification " + e.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnf notification", e); - + logger.error("{} {} Exception sending queryVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); } - LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE, "","", "queryVnfA"); + logger.info("{} queryVnfA", MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE); return; } @@ -393,7 +393,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String serviceName = "DeleteVnfA"; MsoLogger.setServiceName (serviceName); MsoLogger.setLogContext (msoRequest); - LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF, vnfName, cloudSiteId, tenantId); + logger.info("{}", MessageEnum.RA_ASYNC_DELETE_VNF); // Use the synchronous method to perform the actual delete MsoVnfAdapter vnfAdapter = vnfImpl; @@ -403,7 +403,8 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { MsoLogger.setServiceName (serviceName); } catch (VnfException e) { MsoLogger.setServiceName (serviceName); - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e); + logger.error("{} {} Exception sending deleteVnfA notification ", MessageEnum.RA_DELETE_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -412,34 +413,33 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .getCategory () .name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1); + logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } // Build and send Asynchronous error response try { VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.deleteVnfNotification (messageId, false, exCat, eMsg); } catch (Exception e1) { - error = "Error sending deleteVnf notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e1); - + logger.error("{} {} Exception sending deleteVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } - LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE, "","", "deleteVnfA"); + logger.info("{} deleteVnfA", MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE); return; } - LOGGER.debug ("Async Delete VNF: " + vnfName); + logger.debug("Async Delete VNF: {}", vnfName); // Build and send Asynchronous response try { VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.deleteVnfNotification (messageId, true, null, null); } catch (Exception e) { - error = "Error sending deleteVnf notification " + e.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e); - + logger.error("{} {} Exception sending deleteVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); } - LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE, "", "","deleteVnfA"); + logger.info("{} deleteVnfA", MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE); return; } @@ -456,14 +456,12 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String error; // rollback may be null (e.g. if stack already existed when Create was called) if (rollback == null) { - error = "Empty Rollback: No action to perform"; - LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "","", "rollbackVnfA"); - + logger.info("{} rollbackVnfA: Empty Rollback: No action to perform", MessageEnum.RA_ROLLBACK_NULL); return; } MsoLogger.setLogContext (rollback.getMsoRequest ()); - LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF, "", "","rollbackVnfA"); + logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF); // Use the synchronous method to perform the actual rollback MsoVnfAdapter vnfAdapter = vnfImpl; @@ -473,7 +471,8 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { MsoLogger.setServiceName (serviceName); } catch (VnfException e) { MsoLogger.setServiceName (serviceName); - LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e); + logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_ROLLBACK_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -482,33 +481,32 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .getCategory () .name ()); } catch (Exception e1) { - LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1); + logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } // Build and send Asynchronous error response try { VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.rollbackVnfNotification (messageId, false, exCat, eMsg); } catch (Exception e1) { - error = "Error sending rollbackVnf notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e1); - + logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } - LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE, "","", "rollbackVnfA"); + logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE); return; } - LOGGER.debug ("Async Rollback VNF:" + rollback.getVnfId ()); + logger.debug ("Async Rollback VNF:" + rollback.getVnfId ()); // Build and send Asynchronous response try { VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.rollbackVnfNotification (messageId, true, null, null); } catch (Exception e) { - error = "Error sending rollbackVnf notification " + e.getMessage (); - LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e); - + logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); } - LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE, "", "","rollbackVnfA"); + logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE); return; } @@ -600,15 +598,18 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { try { warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("VnfAdapterNotify.wsdl"); } catch (Exception e) { - LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - WSDL not found", e); + logger.error("{} {} Exception - WSDL not found ", MessageEnum.RA_WSDL_NOT_FOUND, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); } if (warWsdlLoc == null) { - LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "WSDL not found"); + logger.error("{} {} WSDL not found", MessageEnum.RA_WSDL_NOT_FOUND, + MsoLogger.ErrorCode.BusinessProcesssError.getValue()); } else { try { - LOGGER.debug ("VnfAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ()); + logger.debug("VnfAdpaterNotify.wsdl location:{}", warWsdlLoc.toURI().toString()); } catch (Exception e) { - LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - WSDL URL convention", e); + logger.error("{} {} Exception - WSDL URL convention ", MessageEnum.RA_WSDL_URL_CONVENTION_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); } } @@ -624,15 +625,16 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { try { epUrl = new URL (notificationUrl); } catch (MalformedURLException e1) { - LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "MalformedURLException", e1); + logger.error("{} {} MalformedURLException ", MessageEnum.RA_INIT_NOTIF_EXC, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e1); } if(null != epUrl) { - LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ()); + logger.debug("Notification Endpoint URL: {}", epUrl.toExternalForm()); bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); } else { - LOGGER.debug ("epUrl is NULL:"); + logger.debug ("epUrl is NULL:"); } // authentication @@ -646,8 +648,8 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, headers); headers.put ("Authorization", Collections.singletonList (basicAuth)); } catch (Exception e) { - LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Unable to set authorization in callback request", e); - + logger.error("{} {} Exception - Unable to set authorization in callback request ", + MessageEnum.RA_SET_CALLBACK_AUTH_EXC, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); } return notifyPort; @@ -657,7 +659,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { try { return CryptoUtils.decrypt(this.environment.getProperty(key), this.environment.getProperty(encryptionKey)); } catch (GeneralSecurityException e) { - LOGGER.debug("Exception while decrypting property: " + this.environment.getProperty(key), e); + logger.debug("Exception while decrypting property: {} ", this.environment.getProperty(key), e); } return defaultValue; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 94434cd781..96160760fd 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -180,7 +180,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String vnfName, String requestType, String volumeGroupHeatStackId, - Map <String, String> inputs, + Map <String, Object> inputs, Boolean failIfExists, Boolean backout, Boolean enableBridge, @@ -265,7 +265,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String vnfName, String requestType, String volumeGroupHeatStackId, - Map <String, String> inputs, + Map <String, Object> inputs, MsoRequest msoRequest, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) throws VnfException { @@ -474,7 +474,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return stringOutputs; } - private Map <String, Object> copyStringInputs (Map <String, String> stringInputs) { + private Map <String, Object> copyStringInputs (Map <String, Object> stringInputs) { return new HashMap <> (stringInputs); } @@ -579,7 +579,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String volumeGroupHeatStackId, String baseVfHeatStackId, String modelCustomizationUuid, - Map <String, String> inputs, + Map <String, Object> inputs, Boolean failIfExists, Boolean backout, Boolean enableBridge, @@ -1343,7 +1343,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String baseVfHeatStackId, String vfModuleStackId, String modelCustomizationUuid, - Map <String, String> inputs, + Map <String, Object> inputs, MsoRequest msoRequest, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) throws VnfException { @@ -1794,8 +1794,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { hasJson = true; String jsonString = null; try { - jsonString = inputs.get(parm.getParamName()); - jsonNode = new ObjectMapper().readTree(jsonString); + jsonString = JSON_MAPPER.writeValueAsString(inputs.get(parm.getParamName())); + jsonNode = JSON_MAPPER.readTree(jsonString); } catch (JsonParseException jpe) { //TODO - what to do here? //for now - send the error to debug, but just leave it as a String @@ -1816,8 +1816,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { hasJson = true; String jsonString = null; try { - jsonString = inputs.get(parm.getParamAlias()); - jsonNode = new ObjectMapper().readTree(jsonString); + jsonString = (String)inputs.get(parm.getParamAlias()); + jsonNode = JSON_MAPPER.readTree(jsonString); } catch (JsonParseException jpe) { //TODO - what to do here? //for now - send the error to debug, but just leave it as a String @@ -1847,7 +1847,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // They've submitted using an alias name. Remove that from inputs, and add back using real name. String realParamName = parm.getParamName (); String alias = parm.getParamAlias (); - String value = inputs.get (alias); + Object value = inputs.get (alias); LOGGER.debug ("*Found an Alias: paramName=" + realParamName + ",alias=" + alias @@ -1911,9 +1911,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Map<String, Object> inputsTwo = null; if (hasJson && jsonParams.size() > 0) { inputsTwo = new HashMap<>(); - for (Map.Entry<String, String> entry : inputs.entrySet()) { + for (Map.Entry<String, Object> entry : inputs.entrySet()) { String keyParamName = entry.getKey(); - String value = entry.getValue(); + Object value = entry.getValue(); if (jsonParams.containsKey(keyParamName)) { inputsTwo.put(keyParamName, jsonParams.get(keyParamName)); } else { @@ -2085,7 +2085,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { */ private boolean valetCreateRequest(String cloudSiteId, String tenantId, Map<String, Object> heatFilesObjects, Map<String, Object> nestedTemplatesChecked, String vfModuleName, boolean backout, HeatTemplate heatTemplate, String newEnvironmentString, Map<String, Object> goldenInputs, - MsoRequest msoRequest, Map<String, String> inputs, boolean failRequestOnValetFailure, Holder<Map<String, Object>> valetModifiedParamsHolder) throws VnfException { + MsoRequest msoRequest, Map<String, Object> inputs, boolean failRequestOnValetFailure, Holder<Map<String, Object>> valetModifiedParamsHolder) throws VnfException { boolean valetSucceeded = false; String valetErrorMessage = "more detail not available"; try { @@ -2095,8 +2095,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { HeatRequest heatRequest = new HeatRequest(vfModuleName, backout, heatTemplate.getTimeoutMinutes(), heatTemplate.getTemplateBody(), newEnvironmentString, files, goldenInputs); GenericValetResponse<ValetCreateResponse> createReq = this.vci.callValetCreateRequest(msoRequest.getRequestId(), - cloudSiteId, tenantId, msoRequest.getServiceInstanceId(), inputs.get("vnf_id"), - inputs.get("vnf_name"), inputs.get("vf_module_id"), inputs.get("vf_module_name"), keystoneUrl, + cloudSiteId, tenantId, msoRequest.getServiceInstanceId(), (String)inputs.get("vnf_id"), + (String)inputs.get("vnf_name"), (String)inputs.get("vf_module_id"), (String)inputs.get("vf_module_name"), keystoneUrl, heatRequest); ValetCreateResponse vcr = createReq.getReturnObject(); if (vcr != null && createReq.getStatusCode() == 200) { @@ -2145,7 +2145,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private boolean valetUpdateRequest(String cloudSiteId, String tenantId, Map<String, Object> heatFilesObjects, Map<String, Object> nestedTemplatesChecked, String vfModuleName, boolean backout, HeatTemplate heatTemplate, String newEnvironmentString, - Map<String, Object> goldenInputs, MsoRequest msoRequest, Map<String, String> inputs, + Map<String, Object> goldenInputs, MsoRequest msoRequest, Map<String, Object> inputs, boolean failRequestOnValetFailure, Holder<Map<String, Object>> valetModifiedParamsHolder) throws VnfException { boolean valetSucceeded = false; @@ -2158,8 +2158,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heatTemplate.getTemplateBody(), newEnvironmentString, files, goldenInputs); // vnf name is not sent to MSO on update requests - so we will set it to the vf module name for now GenericValetResponse<ValetUpdateResponse> updateReq = this.vci.callValetUpdateRequest(msoRequest.getRequestId(), - cloudSiteId, tenantId, msoRequest.getServiceInstanceId(), inputs.get("vnf_id"), - vfModuleName, inputs.get("vf_module_id"), vfModuleName, keystoneUrl, + cloudSiteId, tenantId, msoRequest.getServiceInstanceId(), (String)inputs.get("vnf_id"), + vfModuleName, (String)inputs.get("vf_module_id"), vfModuleName, keystoneUrl, heatRequest); ValetUpdateResponse vur = updateReq.getReturnObject(); if (vur != null && updateReq.getStatusCode() == 200) { diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java index 00e72373dd..f34a79491e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java @@ -132,7 +132,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { String vnfName, String requestType, String volumeGroupHeatStackId, - Map <String, String> inputs, + Map <String, Object> inputs, Boolean failIfExists, Boolean backout, Boolean enableBridge, @@ -160,7 +160,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { String vnfName, String requestType, String volumeGroupHeatStackId, - Map <String, String> inputs, + Map <String, Object> inputs, MsoRequest msoRequest, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) @@ -428,7 +428,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { return; } - private void sendMapToDebug(Map<String, String> inputs) { + private void sendMapToDebug(Map<String, Object> inputs) { int i = 0; StringBuilder sb = new StringBuilder("inputs:"); if (inputs == null) { @@ -567,7 +567,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { String volumeGroupId, String baseVfModuleId, String modelCustomizationUuid, - Map <String, String> inputs, + Map <String, Object> inputs, Boolean failIfExists, Boolean backout, Boolean enableBridge, @@ -605,7 +605,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { if (inputs == null) { // Create an empty set of inputs - inputs = new HashMap<String,String>(); + inputs = new HashMap<>(); LOGGER.debug("inputs == null - setting to empty"); } else { this.sendMapToDebug(inputs); @@ -1212,7 +1212,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { String baseVfHeatStackId, String vfModuleStackId, String modelCustomizationUuid, - Map <String, String> inputs, + Map <String, Object> inputs, MsoRequest msoRequest, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) throws VnfException 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 09ee0cde04..13212be74a 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 @@ -155,7 +155,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { String vnfName, String requestType, String volumeGroupHeatStackId, - Map <String, String> inputs, + Map <String, Object> inputs, Boolean failIfExists, Boolean backout, Boolean enableBridge, @@ -183,7 +183,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { String vnfName, String requestType, String volumeGroupHeatStackId, - Map <String, String> inputs, + Map <String, Object> inputs, MsoRequest msoRequest, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) @@ -379,14 +379,14 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { * Normalize an input value to an Object, based on the target parameter type. * If the type is not recognized, it will just be returned unchanged (as a string). */ - private Object convertInputValue (String inputValue, HeatTemplateParam templateParam) + private Object convertInputValue (Object inputValue, HeatTemplateParam templateParam) { String type = templateParam.getParamType(); LOGGER.debug("Parameter: " + templateParam.getParamName() + " is of type " + type); if (type.equalsIgnoreCase("number")) { try { - return Integer.valueOf(inputValue); + return Integer.valueOf(inputValue.toString()); } catch (Exception e) { LOGGER.debug("Unable to convert " + inputValue + " to an integer!" , e); @@ -394,7 +394,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } } else if (type.equalsIgnoreCase("json")) { try { - JsonNode jsonNode = new ObjectMapper().readTree(inputValue); + JsonNode jsonNode = JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(inputValue)); return jsonNode; } catch (Exception e) { @@ -402,7 +402,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { return null; } } else if (type.equalsIgnoreCase("boolean")) { - return new Boolean(inputValue); + return new Boolean(inputValue.toString()); } // Nothing else matched. Return the original string @@ -471,7 +471,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { return; } - private void sendMapToDebug(Map<String, String> inputs) { + private void sendMapToDebug(Map<String, Object> inputs) { int i = 0; StringBuilder sb = new StringBuilder("inputs:"); if (inputs == null) { @@ -608,7 +608,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { String volumeGroupId, String baseVfModuleId, String modelCustomizationUuid, - Map <String, String> inputs, + Map <String, Object> inputs, Boolean failIfExists, Boolean backout, Boolean enableBridge, @@ -1212,7 +1212,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { String baseVfHeatStackId, String vfModuleStackId, String modelCustomizationUuid, - Map <String, String> inputs, + Map <String, Object> inputs, MsoRequest msoRequest, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) throws VnfException diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java index b4adc1ade9..ef2073839a 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java @@ -61,7 +61,6 @@ import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; import org.onap.so.openstack.exceptions.MsoExceptionCategory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -91,7 +90,6 @@ public class VnfAdapterRest { //TODO Logging, SkipAAI, CREATED flags, Integrate with BPEL, Auth, @Autowired - @Qualifier("VnfBpel") private Provider<BpelRestClient> bpelRestClientProvider; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java index 2c189fa8e8..a3d7c597de 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java @@ -60,7 +60,6 @@ import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; import org.onap.so.openstack.exceptions.MsoExceptionCategory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import io.swagger.annotations.Api; @@ -90,7 +89,6 @@ public class VnfAdapterRestV2 { private VnfAdapterRestUtils vnfAdapterRestUtils; @Autowired - @Qualifier("VnfBpel") private Provider<BpelRestClient> bpelRestClientProvider; /* diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java index 7913a6d827..dc1ff12570 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java @@ -68,7 +68,6 @@ import org.onap.so.openstack.exceptions.MsoExceptionCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; /** @@ -91,7 +90,6 @@ public class VolumeAdapterRest { private MsoVnfAdapterImpl vnfAdapter; @Autowired - @Qualifier("VnfBpel") private Provider<BpelRestClient> bpelRestClientProvider; @POST diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java index 3dc223f5c7..1dcf586346 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java @@ -67,7 +67,6 @@ import org.onap.so.openstack.exceptions.MsoExceptionCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; /** @@ -94,7 +93,6 @@ public class VolumeAdapterRestV2 { private VnfAdapterRestUtils vnfAdapterRestUtils; @Autowired - @Qualifier("VnfBpel") private Provider<BpelRestClient> bpelRestClientProvider; @POST diff --git a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml index 771aa80081..936bde125a 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml @@ -49,7 +49,16 @@ ssl-enable: false tomcat: max-threads: 50 mso: + msoKey: 07a7159d3bf51a0e53be7a8f89699be7 + auth: 6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436 logPath: logs + workflow: + endpoint: http://bpmn-infra:8081/sobpmnengine + topics: + retryMultiplier: 1000 + config: + cadi: + aafId: test catalog: db: spring: @@ -61,26 +70,8 @@ mso: core-pool-size: 50 max-pool-size: 50 queue-capacity: 500 -# H2 -spring: - datasource: - url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1; - username: sa - password: sa - driver-class-name: org.h2.Driver - intialize: true - h2: - console: - enabled: true - path: /h2 - jpa: - show-sql: true - hibernate: - dialect: org.hibernate.dialect.MySQL5Dialect - ddl-auto: validate - naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy - enable_lazy_load_no_trans: true +spring: security: usercredentials: - diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml index a68372f833..4e8d389998 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml @@ -18,7 +18,7 @@ mso: retryMultiplier: 60000 spring: datasource: - jdbcUrl: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb + url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb username: ${DB_USERNAME} password: ${DB_PASSWORD} driver-class-name: org.mariadb.jdbc.Driver diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java index 52b67b8eb9..d7739e56f6 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java @@ -105,7 +105,7 @@ public class AuditStackServiceDataTest extends AuditStackServiceData { doReturn(1).when(mockExternalTask).getRetries(); auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, - "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory"); + "AuditAAIInventoryFailure"); } @Test diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java index 4f1c2c8707..3ebaea9c2c 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java @@ -76,7 +76,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils { String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"; String notificationUrl = "http://localhost:"+wireMockPort+"/notify/adapterNotify/updateVnfNotificationRequest"; instance.createVnfA("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", - "volumeGroupHeatStackId|1", new HashMap<String, String>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, "messageId", + "volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, "messageId", msoRequest, notificationUrl); verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest"))); @@ -86,7 +86,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils { public void createVNFTest_Exception() throws Exception { String notificationUrl = "http://localhost:"+wireMockPort+"/notify/adapterNotify/updateVnfNotificationRequest"; instance.createVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", - "volumeGroupHeatStackId|1", new HashMap<String, String>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, "messageId", + "volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, "messageId", null, notificationUrl); verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest"))); @@ -99,7 +99,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils { msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody (containing("messageId")) @@ -116,7 +116,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils { msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody (containing("messageId")) diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java index 849c0811b0..be3b54e23f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java @@ -104,7 +104,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("MTN13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -124,7 +124,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -144,7 +144,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -164,7 +164,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -181,7 +181,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -195,7 +195,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { expectedException.expect(VnfException.class); MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -211,7 +211,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -230,7 +230,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -250,7 +250,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -268,7 +268,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -300,7 +300,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -337,7 +337,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "XVFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", null, map, @@ -355,7 +355,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -375,7 +375,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { expectedException.expect(VnfException.class); MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.updateVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId", @@ -388,7 +388,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { expectedException.expect(VnfNotFound.class); MsoRequest msoRequest = getMsoRequest(); mockOpenStackResponseAccess(wireMockPort); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.updateVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId", @@ -405,7 +405,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.updateVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId", @@ -422,7 +422,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withStatus(HttpStatus.SC_NOT_FOUND))); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.updateVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId", @@ -438,7 +438,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(); mockOpenstackGetWithResponse("/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json"); mockOpenstackGetWithResponse("/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_INTERNAL_SERVER_ERROR,"OpenstackResponse_Stack_Created_VfModule.json"); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.updateVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId", @@ -454,7 +454,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(); mockOpenstackGetWithResponse("/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json"); mockOpenstackGetWithResponse("/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_NOT_FOUND,"OpenstackResponse_Stack_Created_VfModule.json"); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.updateVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId", @@ -470,7 +470,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(); mockOpenstackGetWithResponse("/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json"); mockOpenstackGetWithResponse("/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json"); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.updateVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId", @@ -489,7 +489,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { VfModuleCustomization vfModuleCustomization = getVfModuleCustomization(); vfModuleCustomization.getVfModule().getModuleHeatTemplate().setParameters(new HashSet<>()); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.updateVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId", @@ -509,7 +509,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { VfModuleCustomization vfModuleCustomization = getVfModuleCustomization(); vfModuleCustomization.getVfModule().getModuleHeatTemplate().setParameters(new HashSet<>()); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); instance.updateVfModule("MTN13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId", diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java index addc12a5d3..44843900fc 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java @@ -265,7 +265,7 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); try { instance.createVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", @@ -282,7 +282,7 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); try { diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index 1fd3ffc90a..75cea9eafc 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -66,7 +66,7 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{ @Test public void createVfModule() throws Exception { //expectedException.expect(VnfException.class); - Map<String, String> stackInputs = new HashMap<>(); + Map<String, Object> stackInputs = new HashMap<>(); stackInputs.put("oof_directives", "{}"); stackInputs.put("sdnc_directives", "{}"); stackInputs.put("generic_vnf_id", "genVNFID"); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java index a422680d00..0cd3d1a61d 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java @@ -56,7 +56,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { public void createVfModule_ModelCustUuidIsNull() throws Exception { expectedException.expect(VnfException.class); MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); msoVnfPluginAdapter.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", null, map, @@ -68,7 +68,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { public void createVfModule_ModelCustUuidIsNotFound() throws Exception { expectedException.expect(VnfException.class); MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); msoVnfPluginAdapter.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, @@ -80,7 +80,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { public void createVfModule_VduException() throws Exception { expectedException.expect(VnfException.class); MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); msoVnfPluginAdapter.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, @@ -94,7 +94,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(); MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); msoVnfPluginAdapter.createVfModule("MTN13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", null, "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, @@ -107,7 +107,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { expectedException.expect(VnfException.class); mockOpenStackResponseAccess(wireMockPort); MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); msoVnfPluginAdapter.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, @@ -125,7 +125,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { .withBodyFile("OpenstackResponse_Stack_Created_VfModule.json") .withStatus(HttpStatus.SC_OK))); MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); + Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); msoVnfPluginAdapter.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java index c502620920..343b6245e6 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java @@ -169,7 +169,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { MsoRequest msoReq = new MsoRequest(); boolean failIfExists = true; Boolean enableBridge = null; - Map<String, String> vfModuleParams = new HashMap<String, String>(); + Map<String, Object> vfModuleParams = new HashMap<>(); vfModuleParams.put("vf_module_id", VF_MODULE_ID); @@ -236,7 +236,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { MsoRequest msoReq = new MsoRequest(); boolean failIfExists = true; boolean enableBridge = false; - Map<String, String> vfModuleParams = new HashMap<String, String>(); + Map<String, Object> vfModuleParams = new HashMap<>(); vfModuleParams.put("vf_module_id", VF_MODULE_ID); vfModuleParams.put("vnf_id", AAI_VNF_ID); @@ -385,7 +385,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { msoRequest.setRequestId(MSO_REQUEST_ID); msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - Map<String, String> vfModuleParams = new HashMap<String, String>(); + Map<String, Object> vfModuleParams = new HashMap<>(); vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN); vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN); @@ -511,7 +511,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { MsoRequest msoReq = new MsoRequest(); boolean failIfExists = true; boolean enableBridge = false; - Map<String, String> vfModuleParams = new HashMap<String, String>(); + Map<String, Object> vfModuleParams = new HashMap<>(); vfModuleParams.put("vf_module_id", VF_MODULE_ID); vfModuleParams.put("vnf_id", AAI_VNF_ID); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java index 68982799f1..d0d06aed6c 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java @@ -56,7 +56,7 @@ public class VolumeGroupAdapterCommon extends BaseRestTestUtils { request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); request.setSkipAAI(true); request.setVolumeGroupStackId(VOUME_GROUP_NAME); - Map<String, String> volumeGroupParams = getVolumeGroupParamsMap(); + Map<String, Object> volumeGroupParams = getVolumeGroupParamsMap(); request.setVolumeGroupParams(volumeGroupParams); MsoRequest msoReq = getMsoRequest(); request.setMsoRequest(msoReq); @@ -104,7 +104,7 @@ public class VolumeGroupAdapterCommon extends BaseRestTestUtils { request.setFailIfExists(true); request.setEnableBridge(false); request.setSuppressBackout(true); - Map<String, String> volumeGroupParams = getVolumeGroupParamsMap(); + Map<String, Object> volumeGroupParams = getVolumeGroupParamsMap(); request.setVolumeGroupParams(volumeGroupParams); MsoRequest msoReq = getMsoRequest(); request.setMsoRequest(msoReq); @@ -112,8 +112,8 @@ public class VolumeGroupAdapterCommon extends BaseRestTestUtils { return request; } - private Map<String, String> getVolumeGroupParamsMap() { - Map<String, String> volumeGroupParams = new HashMap<>(); + private Map<String, Object> getVolumeGroupParamsMap() { + Map<String, Object> volumeGroupParams = new HashMap<>(); volumeGroupParams.put("fsb_volume_type_0","volume_type"); volumeGroupParams.put("fsb_volume_image_name_1","vol_img_1"); volumeGroupParams.put("fsb_volume_image_name_0","vol_img_0"); diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 051884d60d..398885cd08 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -77,7 +77,7 @@ mso: queue-capacity: 500 spring: datasource: - jdbcUrl: jdbc:mariadb://localhost:3307/catalogdb + url: jdbc:mariadb://localhost:3307/catalogdb username: root password: password driver-class-name: org.mariadb.jdbc.Driver |