aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/netconf-executor/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/functions/netconf-executor/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/functions/netconf-executor/src/main')
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt7
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt1
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt3
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt8
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSessionListener.kt1
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt11
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt7
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt2
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt18
9 files changed, 45 insertions, 13 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
index 307e73e6b..b64790065 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
@@ -35,6 +35,7 @@ open class ComponentNetconfExecutor(private var componentFunctionScriptingServic
AbstractComponentFunction() {
companion object {
+
const val SCRIPT_TYPE = "script-type"
const val SCRIPT_CLASS_REFERENCE = "script-class-reference"
const val INSTANCE_DEPENDENCIES = "instance-dependencies"
@@ -66,8 +67,10 @@ open class ComponentNetconfExecutor(private var componentFunctionScriptingServic
// Handles both script processing and error handling
scriptComponent.executeScript(executionServiceInput)
- componentFunctionScriptingService.cleanupInstance(bluePrintRuntimeService.bluePrintContext(),
- scriptType)
+ componentFunctionScriptingService.cleanupInstance(
+ bluePrintRuntimeService.bluePrintContext(),
+ scriptType
+ )
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
index a69e4d9d6..d1855cb62 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
@@ -21,6 +21,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core.Ne
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionImpl
data class NetconfDevice(val deviceInfo: DeviceInfo) {
+
val netconfRpcService = NetconfRpcServiceImpl(deviceInfo)
val netconfSession: NetconfSession
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt
index f52cb0a62..b964388cb 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt
@@ -44,7 +44,8 @@ fun AbstractComponentFunction.netconfDeviceInfo(requirementName: String): Device
val capabilityProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties(
requirement
- .node!!, requirement.capability!!
+ .node!!,
+ requirement.capability!!
)
return netconfDeviceInfo(capabilityProperties)
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt
index 4456cb0de..25cfb3392 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt
@@ -20,20 +20,28 @@ import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
class DeviceInfo {
+
@get:JsonProperty("login-account")
var username: String? = null
+
@get:JsonProperty("login-key")
var password: String? = null
+
@get:JsonProperty("target-ip-address")
var ipAddress: String? = null
+
@get:JsonProperty("port-number")
var port: Int = 0
+
@get:JsonProperty("connection-time-out")
var connectTimeout: Long = 30
+
@get:JsonIgnore
var source: String? = null
+
@get:JsonProperty("reply-time-out")
var replyTimeout: Int = 30
+
@get:JsonIgnore
var idleTimeout: Int = 99999
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSessionListener.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSessionListener.kt
index 23982dcb5..1cb4b3732 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSessionListener.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSessionListener.kt
@@ -16,5 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api
interface NetconfSessionListener {
+
fun accept(event: NetconfReceivedEvent)
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt
index 8f8fc1463..b2d4d98fe 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt
@@ -120,6 +120,7 @@ class NetconfDeviceCommunicator(
internal enum class NetconfMessageState {
NO_MATCHING_PATTERN {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
']' -> FIRST_BRACKET
@@ -129,6 +130,7 @@ class NetconfDeviceCommunicator(
}
},
FIRST_BRACKET {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
']' -> SECOND_BRACKET
@@ -137,6 +139,7 @@ class NetconfDeviceCommunicator(
}
},
SECOND_BRACKET {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
'>' -> FIRST_BIGGER
@@ -145,6 +148,7 @@ class NetconfDeviceCommunicator(
}
},
FIRST_BIGGER {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
']' -> THIRD_BRACKET
@@ -153,6 +157,7 @@ class NetconfDeviceCommunicator(
}
},
THIRD_BRACKET {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
']' -> ENDING_BIGGER
@@ -161,6 +166,7 @@ class NetconfDeviceCommunicator(
}
},
ENDING_BIGGER {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
'>' -> END_PATTERN
@@ -169,6 +175,7 @@ class NetconfDeviceCommunicator(
}
},
FIRST_LF {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
'#' -> FIRST_HASH
@@ -179,6 +186,7 @@ class NetconfDeviceCommunicator(
}
},
FIRST_HASH {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
'#' -> SECOND_HASH
@@ -187,6 +195,7 @@ class NetconfDeviceCommunicator(
}
},
SECOND_HASH {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
'\n' -> END_CHUNKED_PATTERN
@@ -195,11 +204,13 @@ class NetconfDeviceCommunicator(
}
},
END_CHUNKED_PATTERN {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return NO_MATCHING_PATTERN
}
},
END_PATTERN {
+
override fun evaluateChar(c: Char): NetconfMessageState {
return NO_MATCHING_PATTERN
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
index 3d3eee8f0..7aefbb0d6 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
@@ -65,7 +65,7 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
try {
log.info(
"$deviceInfo: Connecting to Netconf Device with timeouts C:${deviceInfo.connectTimeout}, " +
- "R:${deviceInfo.replyTimeout}, I:${deviceInfo.idleTimeout}"
+ "R:${deviceInfo.replyTimeout}, I:${deviceInfo.idleTimeout}"
)
startConnection()
log.info("$deviceInfo: Connected to Netconf Device")
@@ -78,7 +78,7 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
override fun disconnect() {
var retryNum = 3
while (rpcService.closeSession(false).status
- .equals(RpcStatus.FAILURE, true) && retryNum > 0
+ .equals(RpcStatus.FAILURE, true) && retryNum > 0
) {
log.error("disconnect: graceful disconnect failed, retrying $retryNum times...")
retryNum--
@@ -228,7 +228,8 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
ImmutableSet.of(
ClientSession.ClientSessionEvent.WAIT_AUTH,
ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.AUTHED
- ), 0
+ ),
+ 0
)
if (!event.contains(ClientSession.ClientSessionEvent.AUTHED)) {
throw NetconfException("$deviceInfo: Failed to authenticate session.")
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt
index 03177e8ec..54877d5eb 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt
@@ -27,11 +27,13 @@ enum class ModifyAction(val action: String) {
}
object RpcStatus {
+
const val SUCCESS = "success"
const val FAILURE = "failure"
}
object RpcMessageUtils {
+
const val OPEN = "<"
const val CLOSE = ">"
const val EQUAL = "="
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
index 232dca621..32d7dcadc 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
@@ -31,6 +31,7 @@ import kotlin.text.Charsets.UTF_8
class NetconfMessageUtils {
companion object {
+
val log = LoggerFactory.getLogger(NetconfMessageUtils::class.java)
const val NEW_LINE = "\n"
@@ -141,13 +142,13 @@ class NetconfMessageUtils {
if (!persist.isEmpty() && !persistId.isEmpty()) {
throw NetconfException(
"Can't proceed <commit> with both persist($persist) and " +
- "persistId($persistId) specified. Only one should be specified."
+ "persistId($persistId) specified. Only one should be specified."
)
}
if (confirmed && !persistId.isEmpty()) {
throw NetconfException(
"Can't proceed <commit> with both confirmed flag and " +
- "persistId($persistId) specified. Only one should be specified."
+ "persistId($persistId) specified. Only one should be specified."
)
}
@@ -366,8 +367,10 @@ class NetconfMessageUtils {
if (!message.startsWith(RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH)) {
// chunk encode message
message =
- (RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + message.toByteArray(UTF_8).size + RpcMessageUtils.NEW_LINE + message + RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH +
- RpcMessageUtils.NEW_LINE)
+ (
+ RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + message.toByteArray(UTF_8).size + RpcMessageUtils.NEW_LINE + message + RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH +
+ RpcMessageUtils.NEW_LINE
+ )
}
return message
}
@@ -383,9 +386,10 @@ class NetconfMessageUtils {
if (!request.contains(RpcMessageUtils.XML_HEADER)) {
if (request.startsWith(RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH)) {
request =
- request.split("<".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0] + RpcMessageUtils.XML_HEADER + request.substring(
- request.split("<".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0].length
- )
+ request.split("<".toRegex()).dropLastWhile { it.isEmpty() }
+ .toTypedArray()[0] + RpcMessageUtils.XML_HEADER + request.substring(
+ request.split("<".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0].length
+ )
} else {
request = RpcMessageUtils.XML_HEADER + "\n" + request
}