diff options
author | jmac <james.macnider@amdocs.com> | 2019-01-04 20:50:35 +0000 |
---|---|---|
committer | jmac <james.macnider@amdocs.com> | 2019-01-04 20:50:40 +0000 |
commit | e9d2fb2637ae8fc5fb0fe3474c75bf0c8409b66a (patch) | |
tree | b176c0e3e9a8837a5682885e3f4d7eb98479dff8 /pomba/network-discovery | |
parent | 140cdde3f7b51926f30ca5889b18da8e157fea3f (diff) |
remove username and extra fields from logs
Change-Id: Ie0855fdec713826e1c15148cc4cc5094948cdfa4
Signed-off-by: jmac <james.macnider@amdocs.com>
Issue-ID: LOG-909
Diffstat (limited to 'pomba/network-discovery')
2 files changed, 33 insertions, 9 deletions
diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/OSAuthentication.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/OSAuthentication.java index fed52a0..c00bf24 100644 --- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/OSAuthentication.java +++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/OSAuthentication.java @@ -34,6 +34,8 @@ import org.onap.aai.restclient.client.RestClient; import org.onap.logging.ref.slf4j.ONAPLogAdapter;
import org.onap.sdnc.apps.pomba.networkdiscovery.ApplicationException;
+import org.slf4j.Logger;
+
public class OSAuthentication {
private static final String CONFIG_AUTH_DIR = "config/auth";
@@ -61,8 +63,16 @@ public class OSAuthentication { OperationResult result = openstackClient.post(openstackIdentityUrl, payload, headers,
MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
- adapter.unwrap().info("request at url = {} resulted in http response: {}", openstackIdentityUrl,
- result.getResult());
+ Logger log = adapter.unwrap();
+
+ if (result.wasSuccessful()) {
+ log.info("request at url = {} resulted in http response code: {}",
+ openstackIdentityUrl, result.getResultCode());
+ } else {
+ log.error("request at url = {} resulted in http response code: {}. Failure cause: {}",
+ openstackIdentityUrl, result.getResultCode(), result.getFailureCause());
+ }
+
String token = result.getHeaders().getFirst(X_SUBJECT_TOKEN);
@@ -70,7 +80,7 @@ public class OSAuthentication { throw new ApplicationException(UNAUTHORIZED, Status.UNAUTHORIZED);
}
- adapter.unwrap().debug("Got token: {}", token);
+ log.debug("Got token: {}", token);
return token;
}
diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java index 1be8fbc..f9de2be 100644 --- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java +++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java @@ -37,7 +37,9 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.StatusType; import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.Response.Status.Family; import javax.xml.parsers.ParserConfigurationException; import org.onap.aai.restclient.client.OperationResult; @@ -137,13 +139,21 @@ public class SpringServiceImpl implements SpringService { Logger log = adapter.unwrap(); adapter.invoke(new RequestBuilderWrapper(request), InvocationMode.SYNCHRONOUS); try { - adapter.unwrap().info("Posting notfication to url = {} , payload: {}", url, + log.info("Posting notfication to url = {} , payload: {}", url, JsonUtils.toJsonString(Entity.json(notification).getEntity())); Response result = request.post(Entity.json(notification)); - adapter.unwrap().info("request at url = {} resulted in http status {} and response: {}", url, - result.getStatus(), result.getEntity()); + StatusType status = result.getStatusInfo(); + + if (status.getFamily().equals(Family.SUCCESSFUL)) { + log.info("request at url = {} resulted in http status code {}", + url, status.getStatusCode()); + } else { + log.error("request at url = {} resulted in http status code {}, reason: {}", + url, status.getStatusCode(), status.getReasonPhrase()); + } + } catch (Exception x) { log.error("Error during {} operation to endpoint at url = {} with error = {}", "POST", url, @@ -213,8 +223,6 @@ public class SpringServiceImpl implements SpringService { OperationResult result = SpringServiceImpl.this.openstackClient.get(url, headers, MediaType.APPLICATION_JSON_TYPE); - adapter.unwrap().info("Openstack GET result: {}", result.getResult()); - Resource resource = new Resource(); resource.setType(this.resourceType); resource.setId(resourceId); @@ -224,15 +232,21 @@ public class SpringServiceImpl implements SpringService { } resources.add(resource); + Logger log = adapter.unwrap(); + if (result.wasSuccessful()) { + log.info("Openstack GET result code: {}", result.getResultCode()); + String transformedOutput = TransformationUtil.transform(result.getResult(), this.resourceType); - adapter.unwrap().info("Jolt transformed output: {}", transformedOutput); + log.debug("Jolt transformed output: {}", transformedOutput); resource.setDataQuality(DataQuality.ok()); List<Attribute> attributeList = TransformationUtil.toAttributeList(transformedOutput); resource.setAttributeList(attributeList); } else { + log.error("Openstack GET result code: {}. Failure cause: {}", + result.getResultCode(), result.getFailureCause()); resource.setDataQuality(DataQuality.error(result.getFailureCause())); } } |