summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2020-09-22 12:16:46 -0400
committerSingal, Kapil (ks220y) <ks220y@att.com>2020-09-22 13:49:05 -0400
commit1072867dfac0df993cbd3e44bcc11a5cac7465fd (patch)
tree4a821659cf3b50cf946cbb535d528be8508e9fff /ms/blueprintsprocessor/modules/commons/ssh-lib/src/main
parentd97021cd756d63402545fdc2e14ac7611c3da118 (diff)
Enabling Code Formatter
Code Formatter was turned off due to java 11 migation Issue-ID: CCSDK-2852 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/ssh-lib/src/main')
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt1
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibData.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/service/BasicAuthSshClientService.kt21
3 files changed, 16 insertions, 8 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt
index 382c9b7d7..dc10722cc 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/BluePrintSshLibConfiguration.kt
@@ -43,6 +43,7 @@ fun BluePrintDependencyService.sshClientService(jsonNode: JsonNode): BlueprintSs
class SshLibConstants {
companion object {
+
const val SERVICE_BLUEPRINT_SSH_LIB_PROPERTY = "blueprint-ssh-lib-property-service"
const val PROPERTY_SSH_CLIENT_PREFIX = "blueprintsprocessor.sshclient."
const val TYPE_BASIC_AUTH = "basic-auth"
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 cc323adb3..295021f21 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
@@ -19,6 +19,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.ssh
open class SshClientProperties {
+
lateinit var type: String
lateinit var host: String
var port: Int = 22
@@ -27,6 +28,7 @@ open class SshClientProperties {
}
open class BasicAuthSshClientProperties : SshClientProperties() {
+
lateinit var password: String
lateinit var username: String
}
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 a3c730039..6ee73c238 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
@@ -31,13 +31,13 @@ import java.io.ByteArrayOutputStream
import java.io.IOException
import java.io.PipedInputStream
import java.io.PipedOutputStream
+import java.util.ArrayList
import java.util.Collections
import java.util.EnumSet
import java.util.Scanner
-import java.util.ArrayList
open class BasicAuthSshClientService(private val basicAuthSshClientProperties: BasicAuthSshClientProperties) :
- BlueprintSshClientService {
+ BlueprintSshClientService {
private val log = LoggerFactory.getLogger(BasicAuthSshClientService::class.java)!!
private val newLine = "\n".toByteArray()
@@ -54,8 +54,9 @@ open class BasicAuthSshClientService(private val basicAuthSshClientProperties: B
log.debug("SSH Client Service started successfully")
clientSession = sshClient.connect(
- basicAuthSshClientProperties.username, basicAuthSshClientProperties.host,
- basicAuthSshClientProperties.port).verify(basicAuthSshClientProperties.connectionTimeOut).session
+ basicAuthSshClientProperties.username, basicAuthSshClientProperties.host,
+ basicAuthSshClientProperties.port
+ ).verify(basicAuthSshClientProperties.connectionTimeOut).session
clientSession.addPasswordIdentity(basicAuthSshClientProperties.password)
clientSession.auth().verify(basicAuthSshClientProperties.connectionTimeOut)
@@ -79,7 +80,7 @@ open class BasicAuthSshClientService(private val basicAuthSshClientProperties: B
}
}
- override suspend fun executeCommandsNB(commands: List <String>, timeOut: Long): List<CommandResult> {
+ override suspend fun executeCommandsNB(commands: List<String>, timeOut: Long): List<CommandResult> {
val response = ArrayList<CommandResult>()
try {
var stopLoop = false
@@ -126,7 +127,8 @@ open class BasicAuthSshClientService(private val basicAuthSshClientProperties: B
private fun waitForPrompt(timeOut: Long): String {
val waitMask = channel!!.waitFor(
- Collections.unmodifiableSet(EnumSet.of(ClientChannelEvent.CLOSED)), timeOut)
+ Collections.unmodifiableSet(EnumSet.of(ClientChannelEvent.CLOSED)), timeOut
+ )
if (channel!!.out.toString().indexOfAny(arrayListOf("$", ">", "#")) <= 0 && waitMask.contains(ClientChannelEvent.TIMEOUT)) {
throw BluePrintProcessorException("Timeout: Failed to retrieve commands result in $timeOut ms")
}
@@ -157,8 +159,11 @@ open class BasicAuthSshClientService(private val basicAuthSshClientProperties: B
Scanner(output).use { scanner ->
while (scanner.hasNextLine()) {
val temp = scanner.nextLine()
- if (temp.isNotBlank() && (temp.trim { it <= ' ' }.startsWith("%") ||
- temp.trim { it <= ' ' }.startsWith("syntax error"))) {
+ if (temp.isNotBlank() && (
+ temp.trim { it <= ' ' }.startsWith("%") ||
+ temp.trim { it <= ' ' }.startsWith("syntax error")
+ )
+ ) {
return true
}
}