From: Mamtha Date: Fri, 17 Apr 2020 13:25:35 +0000 (+0530) Subject: Code smell fix for appc-ansible-adapter-bundle module X-Git-Tag: 1.7.2~13 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=appc.git;a=commitdiff_plain;h=b7e91dd7ef25b497f2358a71e059f48fb657b6c1 Code smell fix for appc-ansible-adapter-bundle module Issue-ID: APPC-1858 Change-Id: I20362c71c8c54def706bb2fe94970ab18965d62d Signed-off-by: Mamtha --- diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/pom.xml b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/pom.xml index 3af242d4c..1a71a37cb 100644 --- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/pom.xml +++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/pom.xml @@ -172,13 +172,6 @@ guava - diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java index 4c59b4e18..901fe03ad 100644 --- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java +++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java @@ -95,7 +95,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { private static final String PASSWORD = "Password"; private static final String APPC_PROPS = "/appc.properties"; private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - private static final String propDir = System.getenv(SDNC_CONFIG_DIR); + private static final String PROPDIR = System.getenv(SDNC_CONFIG_DIR); private static final String SERVERIP = "ServerIP"; private Properties props; private int defaultTimeout = 600 * 1000; @@ -109,7 +109,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { /** * Connection object **/ - private ConnectionBuilder httpClient; + //private ConnectionBuilder httpClient; /** * Ansible API Message Handlers @@ -174,7 +174,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { * data */ private void initialize() { - String path = propDir + APPC_PROPS; + String path = PROPDIR + APPC_PROPS; File propFile = new File(path); props = new Properties(); try { @@ -217,7 +217,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { private ConnectionBuilder getHttpConn(int timeout, String serverIP) { - String path = propDir + APPC_PROPS; + String path = PROPDIR + APPC_PROPS; File propFile = new File(path); props = new Properties(); InputStream input; @@ -347,10 +347,9 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { doFailure(ctx, testResult.getStatusCode(), "Error posting request. Reason = " + testResult.getStatusMessage()); } - String output = StringUtils.EMPTY; code = testResult.getStatusCode(); message = testResult.getStatusMessage(); - output = testResult.getOutput(); + String output = testResult.getOutput(); ctx.setAttribute(OUTPUT_ATTRIBUTE_NAME, output); String serverIp = testResult.getServerIp(); if (StringUtils.isBlank(serverIp)) @@ -414,6 +413,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { String vmKey = "tmp.vnfInfo.vm[" + Integer.toString(i) + "]"; logger.info("Looking for attributes of: " + vmKey); if (ctx.getAttribute(vmKey + ".vnfc-name") != null) { + String debugText = "Auto Node List candidate "; String vmVnfcName = ctx.getAttribute(vmKey + ".vnfc-name"); String vmVnfcIpv4Address = ctx.getAttribute(vmKey + ".vnfc-ipaddress-v4-oam-vip"); String vmVnfcType = ctx.getAttribute(vmKey + ".vnfc-type"); @@ -423,31 +423,31 @@ public class AnsibleAdapterImpl implements AnsibleAdapter { if (vServerId != null) { String vmVserverId = ctx.getAttribute(vmKey + ".vserver-id"); if (vmVserverId == null || !vmVserverId.equals(vServerId)) { - logger.debug("Auto Node List candidate " + vmVnfcName + " dropped. vserver-id mismatch"); + logger.debug(debugText + vmVnfcName + " dropped. vserver-id mismatch"); continue; } } if (vfModuleId != null) { String vmVfModuleId = ctx.getAttribute(vmKey + ".vf-module-id"); if (vmVfModuleId == null || !vmVfModuleId.equals(vfModuleId)) { - logger.debug("Auto Node List candidate " + vmVnfcName + " dropped. vf-module-id mismatch"); + logger.debug(debugText + vmVnfcName + " dropped. vf-module-id mismatch"); continue; } } if (vnfcName != null) { if (!vmVnfcName.equals(vnfcName)) { - logger.debug("Auto Node List candidate " + vmVnfcName + " dropped. vnfc-name mismatch"); + logger.debug(debugText + vmVnfcName + " dropped. vnfc-name mismatch"); continue; } } if (vnfcType != null) { if (!vmVnfcType.equals(vnfcType)) { - logger.debug("Auto Node List candidate " + vmVnfcType + " dropped. vnfc-type mismatch"); + logger.debug(debugText + vmVnfcType + " dropped. vnfc-type mismatch"); continue; } } - logger.info("Auto Node List candidate " + vmVnfcName + " [" + vmVnfcIpv4Address + "," + vmVnfcType + "]"); + logger.info(debugText + vmVnfcName + " [" + vmVnfcIpv4Address + "," + vmVnfcType + "]"); JSONObject vnfTypeCandidates = null; JSONArray vmList = null;