diff options
author | Lukasz Rajewski <lukasz.rajewski@orange.com> | 2021-03-25 17:47:47 +0100 |
---|---|---|
committer | Lukasz Rajewski <lukasz.rajewski@orange.com> | 2021-03-25 17:48:50 +0100 |
commit | db5afeb31c1e24573b5f85639e19f60f81ef0131 (patch) | |
tree | bfccef4730a42bc064fdaf485b886386a777bf88 /ms/blueprintsprocessor | |
parent | c7bd99a9bf07e3023ab510dfe84fc2acbe74299b (diff) |
Fixed K8s HealthCheck API issue
Fixed K8s HealthCheck API issue
Issue-ID: CCSDK-3230
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Change-Id: Ic341cc7ef36d5fe86cf2b74813bb1f8fc0842f6f
Diffstat (limited to 'ms/blueprintsprocessor')
2 files changed, 94 insertions, 21 deletions
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt index 7834c050d..3305481e1 100644 --- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt +++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt @@ -23,6 +23,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.fasterxml.jackson.module.kotlin.readValue import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance.healthcheck.K8sRbInstanceHealthCheck +import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance.healthcheck.K8sRbInstanceHealthCheckList +import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance.healthcheck.K8sRbInstanceHealthCheckSimple import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -160,7 +162,7 @@ class K8sPluginInstanceApi( } } - fun getInstanceHealthCheckList(instanceId: String): List<K8sRbInstanceHealthCheck>? { + fun getInstanceHealthCheckList(instanceId: String): K8sRbInstanceHealthCheckList? { val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId) try { val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource( @@ -170,8 +172,10 @@ class K8sPluginInstanceApi( ) log.debug(result.toString()) return if (result.status in 200..299) { - val objectMapper = jacksonObjectMapper() - val parsedObject: ArrayList<K8sRbInstanceHealthCheck>? = objectMapper.readValue(result.body) + val parsedObject: K8sRbInstanceHealthCheckList? = JacksonUtils.readValue( + result.body, + K8sRbInstanceHealthCheckList::class.java + ) parsedObject } else if (result.status == 500 && result.body.contains("Error finding master table")) null @@ -208,7 +212,7 @@ class K8sPluginInstanceApi( } } - fun startInstanceHealthCheck(instanceId: String): K8sRbInstanceHealthCheck? { + fun startInstanceHealthCheck(instanceId: String): K8sRbInstanceHealthCheckSimple? { val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId) try { val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource( @@ -218,9 +222,9 @@ class K8sPluginInstanceApi( ) log.debug(result.toString()) return if (result.status in 200..299) { - val parsedObject: K8sRbInstanceHealthCheck? = JacksonUtils.readValue( + val parsedObject: K8sRbInstanceHealthCheckSimple? = JacksonUtils.readValue( result.body, - K8sRbInstanceHealthCheck::class.java + K8sRbInstanceHealthCheckSimple::class.java ) parsedObject } else if (result.status == 500 && result.body.contains("Error finding master table")) diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/healthcheck/K8sRbInstanceHealthCheck.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/healthcheck/K8sRbInstanceHealthCheck.kt index b8e7e835e..0f1f60557 100644 --- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/healthcheck/K8sRbInstanceHealthCheck.kt +++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/healthcheck/K8sRbInstanceHealthCheck.kt @@ -2,22 +2,67 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance.healthchec import com.fasterxml.jackson.annotation.JsonProperty +class K8sRbInstanceHealthCheckSimple { + + @get:JsonProperty("healthcheck-id") + var id: String? = null + + @get:JsonProperty("status") + var status: String? = null + + override fun toString(): String { + return "$id:$status" + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + return true + } + + override fun hashCode(): Int { + return javaClass.hashCode() + } +} + +class K8sRbInstanceHealthCheckList { + + @get:JsonProperty("instance-id") + var instanceId: String? = null + + @get:JsonProperty("healthcheck-summary") + var healthcheckSummary: List<K8sRbInstanceHealthCheckSimple>? = null + + @get:JsonProperty("hooks") + var hooks: List<K8sRbInstanceHealthCheckHook>? = null + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + return true + } + + override fun hashCode(): Int { + return javaClass.hashCode() + } +} + class K8sRbInstanceHealthCheck { - @get:JsonProperty("Id") + @get:JsonProperty("healthcheck-id") var id: String? = null - @get:JsonProperty("StartedAt") - var startedAt: String? = null + @get:JsonProperty("instance-id") + var instanceId: String? = null - @get:JsonProperty("CompletedAt") - var completedAt: String? = null + @get:JsonProperty("info") + var info: String? = null - @get:JsonProperty("Status") + @get:JsonProperty("status") var status: String? = null - @get:JsonProperty("Tests") - var tests: List<K8sHealthCheckTest>? = null + @get:JsonProperty("test-suite") + var testSuite: K8sHealthCheckTest? = null override fun toString(): String { return "$id:$status" @@ -36,9 +81,6 @@ class K8sRbInstanceHealthCheck { class K8sHealthCheckTest { - @get:JsonProperty("Name") - var name: String? = null - @get:JsonProperty("StartedAt") var startedAt: String? = null @@ -48,12 +90,39 @@ class K8sHealthCheckTest { @get:JsonProperty("Status") var status: String? = null - @get:JsonProperty("Info") - var info: String? = null + @get:JsonProperty("TestManifests") + var testManifests: List<String>? = null - override fun toString(): String { - return "$name:$status" + @get:JsonProperty("Results") + var results: List<Any>? = null + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + return true + } + + override fun hashCode(): Int { + return javaClass.hashCode() } +} + +class K8sRbInstanceHealthCheckHook { + + @get:JsonProperty("name") + var name: String? = null + + @get:JsonProperty("kind") + var kind: String? = null + + @get:JsonProperty("path") + var path: String? = null + + @get:JsonProperty("manifest") + var manifest: String? = null + + @get:JsonProperty("events") + var events: List<Any>? = null override fun equals(other: Any?): Boolean { if (this === other) return true |