summaryrefslogtreecommitdiffstats
path: root/components/model-catalog/blueprint-model/service-blueprint
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 /components/model-catalog/blueprint-model/service-blueprint
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 'components/model-catalog/blueprint-model/service-blueprint')
-rw-r--r--components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/ConfigDeploy.kt38
-rw-r--r--components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/HealthCheck.kt54
-rw-r--r--components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_Kotlin/Scripts/kotlin/kotlin.kt6
-rw-r--r--components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_RESTCONF/Scripts/kotlin/KotlinRestCall.kt36
4 files changed, 74 insertions, 60 deletions
diff --git a/components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/ConfigDeploy.kt b/components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/ConfigDeploy.kt
index fe660f590..61cde0521 100644
--- a/components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/ConfigDeploy.kt
+++ b/components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/ConfigDeploy.kt
@@ -20,7 +20,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB
import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
@@ -30,8 +29,6 @@ import org.springframework.http.HttpMethod
import org.springframework.web.client.RestTemplate
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
-import org.apache.http.client.ClientProtocolException
-import java.io.IOException
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
open class ConfigDeploy : AbstractScriptComponentFunction() {
@@ -53,14 +50,14 @@ open class ConfigDeploy : AbstractScriptComponentFunction() {
val payloadObject = JacksonUtils.jsonNode(payload) as ObjectNode
val vdns_ip: String = payloadObject.get("vdns-instance")[0].get("ip-addr").asText()
-
val blueprintContext = bluePrintRuntimeService.bluePrintContext()
val requirement = blueprintContext.nodeTemplateRequirement(nodeTemplateName, "restconf-connection")
val capabilityProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties(requirement.node!!, requirement.capability!!)
val netconfDeviceInfo = JacksonUtils.getInstanceFromMap(capabilityProperties, NetconfDeviceInfo::class.java)
log.info("Waiting for 2 minutes until vLB intializes ...")
- //Thread.sleep(120000)
- val uri = "http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances/vdns-instance/$vdns_ip"
+ // Thread.sleep(120000)
+ val uri =
+ "http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances/vdns-instance/$vdns_ip"
val restTemplate = RestTemplate()
val mapOfHeaders = hashMapOf<String, String>()
mapOfHeaders.put("Accept", "application/json")
@@ -71,16 +68,18 @@ open class ConfigDeploy : AbstractScriptComponentFunction() {
basicAuthRestClientProperties.username = "admin"
basicAuthRestClientProperties.password = "admin"
basicAuthRestClientProperties.url = uri
- basicAuthRestClientProperties.additionalHeaders =mapOfHeaders
- val basicAuthRestClientService: BasicAuthRestClientService= BasicAuthRestClientService(basicAuthRestClientProperties)
+ basicAuthRestClientProperties.additionalHeaders = mapOfHeaders
+ val basicAuthRestClientService: BasicAuthRestClientService = BasicAuthRestClientService(basicAuthRestClientProperties)
try {
- val result: BlueprintWebClientService.WebClientResponse<String> = basicAuthRestClientService.exchangeResource(HttpMethod.PUT.name, "", payload)
+ val result: BlueprintWebClientService.WebClientResponse<String> =
+ basicAuthRestClientService.exchangeResource(HttpMethod.PUT.name, "", payload)
print(result)
- basicAuthRestClientProperties.url = "http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances"
- val resultOfGet: BlueprintWebClientService.WebClientResponse<String> = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
+ basicAuthRestClientProperties.url =
+ "http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances"
+ val resultOfGet: BlueprintWebClientService.WebClientResponse<String> =
+ basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
print(resultOfGet)
- }
- catch (e: Exception) {
+ } catch (e: Exception) {
log.info("Caught exception trying to connect to vLB!!")
throw BluePrintProcessorException("${e.message}")
}
@@ -93,27 +92,36 @@ open class ConfigDeploy : AbstractScriptComponentFunction() {
}
class NetconfDeviceInfo {
+
@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 = 5
+
@get:JsonIgnore
var source: String? = null
+
@get:JsonIgnore
var replyTimeout: Int = 5
+
@get:JsonIgnore
var idleTimeout: Int = 99999
override fun toString(): String {
return "$ipAddress:$port"
}
- //TODO: should this be a data class instead? Is anything using the JSON serdes?
+
+ // TODO: should this be a data class instead? Is anything using the JSON serdes?
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
@@ -123,4 +131,4 @@ class NetconfDeviceInfo {
override fun hashCode(): Int {
return javaClass.hashCode()
}
-} \ No newline at end of file
+}
diff --git a/components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/HealthCheck.kt b/components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/HealthCheck.kt
index b09a432f7..04993cdae 100644
--- a/components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/HealthCheck.kt
+++ b/components/model-catalog/blueprint-model/service-blueprint/vLB/Scripts/kotlin/HealthCheck.kt
@@ -16,12 +16,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
* limitations under the License.
*/
-
import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB
import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
@@ -31,10 +28,6 @@ import org.springframework.http.HttpMethod
import org.springframework.web.client.RestTemplate
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
-import org.apache.http.client.ClientProtocolException
-import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.PayloadUtils
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentRemoteScriptExecutor
-import java.io.IOException
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
open class HealthCheck : AbstractScriptComponentFunction() {
@@ -50,47 +43,45 @@ open class HealthCheck : AbstractScriptComponentFunction() {
val resolution_key = getDynamicProperties("resolution-key").asText()
log.info("resolution_key: $resolution_key")
- //val payload = storedContentFromResolvedArtifactNB(resolution_key, "baseconfig")
- //log.info("configuration: $payload")
-
- //val payloadObject = JacksonUtils.jsonNode(payload) as ObjectNode
- //val vdns_ip: String = payloadObject.get("vdns-instance")[0].get("ip-addr").asText()
+ // val payload = storedContentFromResolvedArtifactNB(resolution_key, "baseconfig")
+ // log.info("configuration: $payload")
+ // val payloadObject = JacksonUtils.jsonNode(payload) as ObjectNode
+ // val vdns_ip: String = payloadObject.get("vdns-instance")[0].get("ip-addr").asText()
val blueprintContext = bluePrintRuntimeService.bluePrintContext()
val requirement = blueprintContext.nodeTemplateRequirement(nodeTemplateName, "restconf-connection")
val capabilityProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties(requirement.node!!, requirement.capability!!)
val netconfDeviceInfo = JacksonUtils.getInstanceFromMap(capabilityProperties, NetconfDeviceInfo2::class.java)
- //log.info("Waiting for 2 minutes until vLB intializes ...")
- //Thread.sleep(120000)
+ // log.info("Waiting for 2 minutes until vLB intializes ...")
+ // Thread.sleep(120000)
val uri = "http://${netconfDeviceInfo.ipAddress}:8183/restconf/operational/health-vnf-onap-plugin:health-vnf-onap-plugin-state/health-check"
val restTemplate = RestTemplate()
val mapOfHeaders = hashMapOf<String, String>()
mapOfHeaders.put("Accept", "application/json")
mapOfHeaders.put("Content-Type", "application/json")
- //mapOfHeaders.put("cache-control", " no-cache")
- //mapOfHeaders.put("Accept", "application/json")
+ // mapOfHeaders.put("cache-control", " no-cache")
+ // mapOfHeaders.put("Accept", "application/json")
val basicAuthRestClientProperties: BasicAuthRestClientProperties = BasicAuthRestClientProperties()
basicAuthRestClientProperties.username = "admin"
basicAuthRestClientProperties.password = "admin"
basicAuthRestClientProperties.url = uri
- basicAuthRestClientProperties.additionalHeaders =mapOfHeaders
- val basicAuthRestClientService: BasicAuthRestClientService= BasicAuthRestClientService(basicAuthRestClientProperties)
+ basicAuthRestClientProperties.additionalHeaders = mapOfHeaders
+ val basicAuthRestClientService: BasicAuthRestClientService = BasicAuthRestClientService(basicAuthRestClientProperties)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
log.info(result.body)
val resultJson = JacksonUtils.jsonNode(result.body) as ObjectNode
val health: String = resultJson.get("health-check").get("state").asText()
- super.setAttribute("response-data", resultJson)
+ super.setAttribute("response-data", resultJson)
if (health != "healthy") {
throw Exception("VNF is not healty!!")
}
-
- //basicAuthRestClientProperties.url = //"http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances"
- //val resultOfGet: BlueprintWebClientService.WebClientResponse<String> = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
- //print(resultOfGet)
- }
- catch (e: Exception) {
+
+ // basicAuthRestClientProperties.url = //"http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances"
+ // val resultOfGet: BlueprintWebClientService.WebClientResponse<String> = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
+ // print(resultOfGet)
+ } catch (e: Exception) {
log.info("Caught exception trying to connect to vLB!!")
throw BluePrintProcessorException("${e.message}")
}
@@ -103,27 +94,36 @@ open class HealthCheck : AbstractScriptComponentFunction() {
}
class NetconfDeviceInfo2 {
+
@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 = 5
+
@get:JsonIgnore
var source: String? = null
+
@get:JsonIgnore
var replyTimeout: Int = 5
+
@get:JsonIgnore
var idleTimeout: Int = 99999
override fun toString(): String {
return "$ipAddress:$port"
}
- //TODO: should this be a data class instead? Is anything using the JSON serdes?
+
+ // TODO: should this be a data class instead? Is anything using the JSON serdes?
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
@@ -133,4 +133,4 @@ class NetconfDeviceInfo2 {
override fun hashCode(): Int {
return javaClass.hashCode()
}
-} \ No newline at end of file
+}
diff --git a/components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_Kotlin/Scripts/kotlin/kotlin.kt b/components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_Kotlin/Scripts/kotlin/kotlin.kt
index ef0876f96..f8ef7f804 100644
--- a/components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_Kotlin/Scripts/kotlin/kotlin.kt
+++ b/components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_Kotlin/Scripts/kotlin/kotlin.kt
@@ -39,9 +39,9 @@ open class ConfigDeploy : AbstractScriptComponentFunction() {
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
val resolution_key = getDynamicProperties("resolution-key").asText()
- log.info("resolution_key: $resolution_key"\n)
+ log.info("resolution_key: $resolution_key"\ n)
val payload = storedContentFromResolvedArtifactNB(resolution_key, "baseconfig")
- log.info("configuration: \n$payload"\n)
+ log.info("configuration: \n$payload"\ n)
log.info("Waiting 1 minute and 30 seconds or vLB to initialize ...")
Thread.sleep(90000)
val netconf_device = netconfDevice("netconf-connection")
@@ -58,8 +58,6 @@ open class ConfigDeploy : AbstractScriptComponentFunction() {
//var payloadObject = JacksonUtils.jsonNode(payload) as ObjectNode
//var vdns_ip: String = payloadObject.get("vdns-instance")[0].get("ip-addr").asText()
netconf_session.disconnect()
-
-
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
diff --git a/components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_RESTCONF/Scripts/kotlin/KotlinRestCall.kt b/components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_RESTCONF/Scripts/kotlin/KotlinRestCall.kt
index 578492f33..91b985040 100644
--- a/components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_RESTCONF/Scripts/kotlin/KotlinRestCall.kt
+++ b/components/model-catalog/blueprint-model/service-blueprint/vLB_CDS_RESTCONF/Scripts/kotlin/KotlinRestCall.kt
@@ -20,7 +20,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB
import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
@@ -30,8 +29,6 @@ import org.springframework.http.HttpMethod
import org.springframework.web.client.RestTemplate
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
-import org.apache.http.client.ClientProtocolException
-import java.io.IOException
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
open class ConfigDeploy : AbstractScriptComponentFunction() {
@@ -53,14 +50,14 @@ open class ConfigDeploy : AbstractScriptComponentFunction() {
val payloadObject = JacksonUtils.jsonNode(payload) as ObjectNode
val vdns_ip: String = payloadObject.get("vdns-instance")[0].get("ip-addr").asText()
-
val blueprintContext = bluePrintRuntimeService.bluePrintContext()
val requirement = blueprintContext.nodeTemplateRequirement(nodeTemplateName, "restconf-connection")
val capabilityProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties(requirement.node!!, requirement.capability!!)
val netconfDeviceInfo = JacksonUtils.getInstanceFromMap(capabilityProperties, NetconfDeviceInfo::class.java)
log.info("Waiting for 2 minutes until vLB intializes ...")
Thread.sleep(120000)
- val uri = "http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances/vdns-instance/$vdns_ip"
+ val uri =
+ "http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances/vdns-instance/$vdns_ip"
val restTemplate = RestTemplate()
val mapOfHeaders = hashMapOf<String, String>()
mapOfHeaders.put("Accept", "application/json")
@@ -71,16 +68,18 @@ open class ConfigDeploy : AbstractScriptComponentFunction() {
basicAuthRestClientProperties.username = "admin"
basicAuthRestClientProperties.password = "admin"
basicAuthRestClientProperties.url = uri
- basicAuthRestClientProperties.additionalHeaders =mapOfHeaders
- val basicAuthRestClientService: BasicAuthRestClientService= BasicAuthRestClientService(basicAuthRestClientProperties)
+ basicAuthRestClientProperties.additionalHeaders = mapOfHeaders
+ val basicAuthRestClientService: BasicAuthRestClientService = BasicAuthRestClientService(basicAuthRestClientProperties)
try {
- val result: BlueprintWebClientService.WebClientResponse<String> = basicAuthRestClientService.exchangeResource(HttpMethod.PUT.name, "", payload)
+ val result: BlueprintWebClientService.WebClientResponse<String> =
+ basicAuthRestClientService.exchangeResource(HttpMethod.PUT.name, "", payload)
print(result)
- basicAuthRestClientProperties.url = "http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances"
- val resultOfGet: BlueprintWebClientService.WebClientResponse<String> = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
+ basicAuthRestClientProperties.url =
+ "http://${netconfDeviceInfo.ipAddress}:8183/restconf/config/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin/vdns-instances"
+ val resultOfGet: BlueprintWebClientService.WebClientResponse<String> =
+ basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
print(resultOfGet)
- }
- catch (e: Exception) {
+ } catch (e: Exception) {
log.info("Caught exception trying to connect to vLB!!")
throw BluePrintProcessorException("${e.message}")
}
@@ -93,27 +92,36 @@ open class ConfigDeploy : AbstractScriptComponentFunction() {
}
class NetconfDeviceInfo {
+
@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 = 5
+
@get:JsonIgnore
var source: String? = null
+
@get:JsonIgnore
var replyTimeout: Int = 5
+
@get:JsonIgnore
var idleTimeout: Int = 99999
override fun toString(): String {
return "$ipAddress:$port"
}
- //TODO: should this be a data class instead? Is anything using the JSON serdes?
+
+ // TODO: should this be a data class instead? Is anything using the JSON serdes?
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
@@ -123,4 +131,4 @@ class NetconfDeviceInfo {
override fun hashCode(): Int {
return javaClass.hashCode()
}
-} \ No newline at end of file
+}