diff options
author | dfarrelly <david.farrelly@est.tech> | 2020-02-14 14:46:06 +0000 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2020-02-20 14:54:42 +0000 |
commit | 9e3c594bc3cf74ab5748c14bcde81dec7f062fa0 (patch) | |
tree | 8c782779b7dd77806aec9814303541c095d911ef /components/model-catalog/blueprint-model/uat-blueprints | |
parent | dcf0322610861aec8078d783e5ee8107eb5bdb3e (diff) |
Update restconf executor to return response
*Update restconfApplyDeviceConfig function to return request response
*Modify pnf_config_aai CBA to test new functionality
Issue-ID: CCSDK-2097
Change-Id: Id6109d8c3a8fa4e2ba1b102c4d2697ae6a03f8e2
Signed-off-by: dfarrelly <david.farrelly@est.tech>
Diffstat (limited to 'components/model-catalog/blueprint-model/uat-blueprints')
2 files changed, 20 insertions, 2 deletions
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt index 6a034ab94..f0190e8ec 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt @@ -31,11 +31,14 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restco import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.logger +import com.fasterxml.jackson.databind.ObjectMapper +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService.WebClientResponse class RestconfConfigDeploy : AbstractScriptComponentFunction() { private val CONFIGLET_TEMPLATE_NAME = "config-assign" private val CONFIGLET_RESOURCE_PATH = "yang-ext:mount/mynetconf:netconflist" private val RESTCONF_SERVER_IDENTIFIER = "sdnc" + private val mapper = ObjectMapper() private val log = logger(AbstractScriptComponentFunction::class.java) override suspend fun processNB(executionRequest: ExecutionServiceInput) { @@ -58,9 +61,17 @@ class RestconfConfigDeploy : AbstractScriptComponentFunction() { val currentConfig: Any = restconfDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH) log.info("Current configuration subtree : $currentConfig") //Apply configlet - restconfApplyDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH, + val result = restconfApplyDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH, storedContentFromResolvedArtifactNB(resolutionKey, CONFIGLET_TEMPLATE_NAME), - mutableMapOf("Content-Type" to "application/yang.patch+json")) + mutableMapOf("Content-Type" to "application/yang.patch+json")) as WebClientResponse<*> + + val jsonResult = mapper.readTree((result.body).toString()) + + if(jsonResult.get("ietf-yang-patch:yang-patch-status").get("errors") != null) { + log.error("There was an error configuring device") + } else { + log.info("Device has been configured succesfully") + } } catch (err: Exception) { log.error("an error occurred while configuring device {}", err) diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Tests/uat.yaml b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Tests/uat.yaml index 0692eea7f..13e10f34b 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Tests/uat.yaml +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Tests/uat.yaml @@ -123,6 +123,13 @@ external-services: operation: merge target: / value: { netconflist: { netconf: [ { netconf-id: "30", netconf-param: "3000" }]}} + response: + body: + ietf-yang-patch:yang-patch-status: + patch-id: patch-1 + ok: [ + null + ] - request: method: DELETE path: *configUri |