CommandResult info appears in CDS logs by default 10/111710/1
authorJulien Fontaine <julien.fontaine@bell.ca>
Tue, 25 Aug 2020 20:12:24 +0000 (16:12 -0400)
committerJulien Fontaine <julien.fontaine@bell.ca>
Tue, 25 Aug 2020 20:12:24 +0000 (16:12 -0400)
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 <julien.fontaine@bell.ca>
Change-Id: I5107ed6acc150875264a65bf1c64962ff26cfd78

ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt
ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt
ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt

index c7d5105..cc323ad 100644 (file)
@@ -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() {
index ee7a7de..a7702d4 100644 (file)
@@ -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() {
index 2885d65..a3c7300 100644 (file)
@@ -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
     }