From e0da7c94aedc038c76d17c1d4a904c7b12ba3c5b Mon Sep 17 00:00:00 2001 From: Julien Fontaine Date: Tue, 25 Aug 2020 16:12:24 -0400 Subject: CommandResult info appears in CDS logs by default Add config property to enable/disable logging of the command result. Now command result logs aren't printed by default. Issue-ID: CCSDK-2693 Signed-off-by: Julien Fontaine Change-Id: I5107ed6acc150875264a65bf1c64962ff26cfd78 --- .../onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt | 3 +++ .../org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt | 6 ++++++ .../blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt | 6 ++++-- 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'ms/blueprintsprocessor/modules') diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt index c7d5105b4..cc323adb3 100644 --- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt +++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt @@ -1,6 +1,8 @@ /* * Copyright © 2019 IBM. * + * Modifications Copyright © 2020 IBM, Bell Canada. + * * 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,6 +23,7 @@ open class SshClientProperties { lateinit var host: String var port: Int = 22 var connectionTimeOut: Long = 3000 + var logging: Boolean = false // print command result in cds logs } open class BasicAuthSshClientProperties : SshClientProperties() { diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt index ee7a7dead..a7702d4fb 100644 --- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt +++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt @@ -1,6 +1,8 @@ /* * Copyright © 2018-2019 AT&T Intellectual Property. * + * Modifications Copyright © 2020 Bell Canada. + * * 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 @@ -94,6 +96,10 @@ open class SshClientPropertiesAssignmentBuilder : PropertiesAssignmentBuilder() fun host(host: String) = host(host.asJsonPrimitive()) fun host(host: JsonNode) = property(SshClientProperties::host.name, host) + + fun logging(logging: Boolean) = logging(logging.asJsonPrimitive()) + + fun logging(logging: JsonNode) = property(SshClientProperties::logging.name, logging) } class BasicAuthSshClientPropertiesAssignmentBuilder : SshClientPropertiesAssignmentBuilder() { diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt index 2885d6528..a3c730039 100644 --- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt +++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt @@ -1,7 +1,7 @@ /* * Copyright © 2019 IBM. * - * Modifications Copyright © 2018-2019 IBM, Bell Canada + * Modifications Copyright © 2018-2020 IBM, Bell Canada. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -118,7 +118,9 @@ open class BasicAuthSshClientService(private val basicAuthSshClientProperties: B } val commandResult = CommandResult(command, deviceOutput, isSuccessful) - log.info("Command Response: ({}) $newLine", commandResult) + if (basicAuthSshClientProperties.logging) { + log.info("Command Response: ({}) $newLine", commandResult) + } return commandResult } -- cgit 1.2.3-korg