aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgummar <raj.gumma@est.tech>2020-03-04 14:35:07 +0000
committergummar <raj.gumma@est.tech>2020-03-04 16:12:19 +0000
commitf4ac359d80d043a2d0e6eaf1730813b81f2c837f (patch)
tree14710c41d82417c2005840d173f5a0f980026755
parent7a8bfb25a92a9400862d70e690313a4e743124da (diff)
Fix case for all Software upgrade actions
Issue-ID: CCSDK-2145 Signed-off-by: gummar <raj.gumma@est.tech> Change-Id: Ic29056d100ffba9d6d1c2a6b3f73d6a95f3bee28
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/PNF_CDS_RESTCONF.json32
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/data_types.json8
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfSoftwareUpgrade.kt36
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Tests/uat.yaml20
4 files changed, 53 insertions, 43 deletions
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/PNF_CDS_RESTCONF.json b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/PNF_CDS_RESTCONF.json
index 747fd8c19..d84fd8182 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/PNF_CDS_RESTCONF.json
+++ b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/PNF_CDS_RESTCONF.json
@@ -30,12 +30,12 @@
"get_input" : "resolution-key"
}
},
- "downloadNESW-properties" : {
+ "downloadNESw-properties" : {
"resolution-key" : {
"get_input" : "resolution-key"
}
},
- "activateNESW-properties" : {
+ "activateNESw-properties" : {
"resolution-key" : {
"get_input" : "resolution-key"
}
@@ -118,11 +118,11 @@
}
}
},
- "downloadNESW" : {
+ "downloadNESw" : {
"steps" : {
"activate-process" : {
"description" : "Trigger download new software for sw upgrade",
- "target" : "downloadNESW",
+ "target" : "downloadNESw",
"activities" : [ {
"call_operation" : ""
} ]
@@ -133,18 +133,18 @@
"required" : true,
"type" : "string"
},
- "downloadNESW-properties" : {
- "description" : "Dynamic PropertyDefinition for downloadNESW workflow(software-upgrade).",
+ "downloadNESw-properties" : {
+ "description" : "Dynamic PropertyDefinition for downloadNESw workflow(software-upgrade).",
"required" : true,
- "type" : "dt-downloadNESW-properties"
+ "type" : "dt-downloadNESw-properties"
}
}
},
- "activateNESW" : {
+ "activateNESw" : {
"steps" : {
"activate-process" : {
"description" : "Trigger activation of target software version for pnf upgrade",
- "target" : "activateNESW",
+ "target" : "activateNESw",
"activities" : [ {
"call_operation" : ""
} ]
@@ -155,10 +155,10 @@
"required" : true,
"type" : "string"
},
- "activateNESW-properties" : {
- "description" : "Dynamic PropertyDefinition for activateNESW workflow(software-upgrade).",
+ "activateNESw-properties" : {
+ "description" : "Dynamic PropertyDefinition for activateNESw workflow(software-upgrade).",
"required" : true,
- "type" : "dt-activateNESW-properties"
+ "type" : "dt-activateNESw-properties"
}
}
},
@@ -290,7 +290,7 @@
}
}
},
- "downloadNESW" : {
+ "downloadNESw" : {
"type" : "component-script-executor",
"interfaces" : {
"ComponentScriptExecutor" : {
@@ -304,7 +304,7 @@
"inputs" : {
"script-type" : "kotlin",
"script-class-reference" : "cba.pnf.swug.RestconfSoftwareUpgrade",
- "dynamic-properties" : "*downloadNESW-properties"
+ "dynamic-properties" : "*downloadNESw-properties"
},
"outputs" : {
"response-data" : "",
@@ -341,7 +341,7 @@
}
}
},
- "activateNESW" : {
+ "activateNESw" : {
"type" : "component-script-executor",
"interfaces" : {
"ComponentScriptExecutor" : {
@@ -355,7 +355,7 @@
"inputs" : {
"script-type" : "kotlin",
"script-class-reference" : "cba.pnf.swug.RestconfSoftwareUpgrade",
- "dynamic-properties" : "*activateNESW-properties"
+ "dynamic-properties" : "*activateNESw-properties"
},
"outputs" : {
"response-data" : "",
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/data_types.json b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/data_types.json
index 2a42ac091..cd91f4b3a 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/data_types.json
+++ b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Definitions/data_types.json
@@ -32,8 +32,8 @@
},
"derived_from": "tosca.datatypes.Dynamic"
},
- "dt-downloadNESW-properties": {
- "description": "Dynamic DataType definition for the downloadNESW workflow(upgrade-software).",
+ "dt-downloadNESw-properties": {
+ "description": "Dynamic DataType definition for the downloadNESw workflow(upgrade-software).",
"version": "1.0.0",
"properties": {
"pnf-id": {
@@ -45,8 +45,8 @@
},
"derived_from": "tosca.datatypes.Dynamic"
},
- "dt-activateNESW-properties": {
- "description": "Dynamic DataType definition for the activateNESW workflow(upgrade-software).",
+ "dt-activateNESw-properties": {
+ "description": "Dynamic DataType definition for the activateNESw workflow(upgrade-software).",
"version": "1.0.0",
"properties": {
"pnf-id": {
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfSoftwareUpgrade.kt b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfSoftwareUpgrade.kt
index 9d00c60d8..0540efe80 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfSoftwareUpgrade.kt
+++ b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfSoftwareUpgrade.kt
@@ -45,11 +45,7 @@ class RestconfSoftwareUpgrade : AbstractScriptComponentFunction() {
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
// Extract request properties
- val properties = requestPayloadActionProperty(executionRequest.actionIdentifiers.actionName + "-properties")!!.get(0)
- val model= SoftwareUpgradeModel(getDynamicProperties("resolution-key").asText(),
- BluePrintDependencyService.restClientService(RESTCONF_SERVER_IDENTIFIER),
- properties.get("pnf-id").textValue(), properties.get("target-software-version").textValue(),
- Action.getEnumFromActionName(executionRequest.actionIdentifiers.actionName))
+ val model= validatedPayload(executionRequest)
log.info("Blueprint invoked for ${model.resolutionKey} for SW Upgrade : " +
"${model.action} for sw version ${model.targetSwVersion} on pnf: ${model.deviceId}")
@@ -61,8 +57,8 @@ class RestconfSoftwareUpgrade : AbstractScriptComponentFunction() {
when (model.action) {
Action.PRE_CHECK -> processPreCheck(model)
- Action.DOWNLOAD_NE_SW -> processDownloadNESW(model)
- Action.ACTIVATE_NE_SW -> processActivateNESW(model)
+ Action.DOWNLOAD_NE_SW -> processDownloadNESw(model)
+ Action.ACTIVATE_NE_SW -> processActivateNESw(model)
Action.POST_CHECK -> processPostCheck(model)
Action.CANCEL -> processCancel(model)
}
@@ -74,6 +70,19 @@ class RestconfSoftwareUpgrade : AbstractScriptComponentFunction() {
}
}
+ private fun validatedPayload(executionRequest: ExecutionServiceInput): SoftwareUpgradeModel {
+ val properties = requestPayloadActionProperty(executionRequest.actionIdentifiers.actionName + "-properties")!!.get(0)
+ if(!properties?.get("pnf-id")?.textValue().isNullOrEmpty() &&
+ !properties?.get("target-software-version")?.textValue().isNullOrEmpty()) {
+ return SoftwareUpgradeModel(getDynamicProperties("resolution-key").asText(),
+ BluePrintDependencyService.restClientService(RESTCONF_SERVER_IDENTIFIER),
+ properties.get("pnf-id").textValue(), properties.get("target-software-version").textValue(),
+ Action.getEnumFromActionName(executionRequest.actionIdentifiers.actionName))
+ }else{
+ throw BluePrintException("Invalid parameters sent to CDS. Request parameters pnf-id or target-software-version missing")
+ }
+ }
+
private suspend fun processPreCheck(model: SoftwareUpgradeModel) {
log.debug("In PNF SW upgrade : processPreCheck")
//Log the current configuration for the subtree
@@ -82,8 +91,8 @@ class RestconfSoftwareUpgrade : AbstractScriptComponentFunction() {
log.info("PNF is Healthy!")
}
- private suspend fun processDownloadNESW(model: SoftwareUpgradeModel) {
- log.debug("In PNF SW upgrade : processDownloadNESW")
+ private suspend fun processDownloadNESw(model: SoftwareUpgradeModel) {
+ log.debug("In PNF SW upgrade : processDownloadNESw")
//Check if there is existing config for the targeted software version
var downloadConfigPayload: String
@@ -106,12 +115,13 @@ class RestconfSoftwareUpgrade : AbstractScriptComponentFunction() {
checkExecution(model)
}
- private suspend fun processActivateNESW(model: SoftwareUpgradeModel) {
- log.debug("In PNF SW upgrade : processActivateNESW")
+ private suspend fun processActivateNESw(model: SoftwareUpgradeModel) {
+ log.debug("In PNF SW upgrade : processActivateNESw")
//Check if the software is downloaded and ready to be activated
if (checkIfSwReadyToPerformAction(Action.DOWNLOAD_NE_SW, model)) {
var activateConfigPayload: String = contentFromResolvedArtifactNB("configure")
activateConfigPayload = activateConfigPayload.replace("%actionName%", Action.ACTIVATE_NE_SW.name)
+ activateConfigPayload = activateConfigPayload.replace("%id%", model.yangId)
log.info("Config Payload to start activate : $activateConfigPayload")
//Apply configlet
restconfApplyDeviceConfig(model.client, model.deviceId, CONFIGLET_RESOURCE_PATH, activateConfigPayload,
@@ -176,8 +186,8 @@ class RestconfSoftwareUpgrade : AbstractScriptComponentFunction() {
enum class Action(val actionName: String, val completionStatus: String) {
PRE_CHECK("preCheck", "INITIALIZED"),
- DOWNLOAD_NE_SW("downloadNESW", "DOWNLOAD_COMPLETED"),
- ACTIVATE_NE_SW("activateNESW", "ACTIVATION_COMPLETED"),
+ DOWNLOAD_NE_SW("downloadNESw", "DOWNLOAD_COMPLETED"),
+ ACTIVATE_NE_SW("activateNESw", "ACTIVATION_COMPLETED"),
POST_CHECK("postCheck", "ACTIVATION_COMPLETED"),
CANCEL("cancel", "CANCELLED")
;
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Tests/uat.yaml b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Tests/uat.yaml
index 7136b1b0f..c2fd3f788 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Tests/uat.yaml
+++ b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Tests/uat.yaml
@@ -86,18 +86,18 @@ processes:
message: success
payload:
preCheck-response: {}
- - name: downloadNESW
+ - name: downloadNESw
request:
commonHeader: *swugCommonHeader
actionIdentifiers: &download-ai
blueprintName: PNF_CDS_RESTCONF
blueprintVersion: "1.0.0"
- actionName: downloadNESW
+ actionName: downloadNESw
mode: sync
payload:
- downloadNESW-request:
+ downloadNESw-request:
resolution-key: *resKey
- downloadNESW-properties: *actionProps
+ downloadNESw-properties: *actionProps
expectedResponse:
commonHeader: *swugCommonHeader
actionIdentifiers: *download-ai
@@ -107,19 +107,19 @@ processes:
errorMessage: null
message: success
payload:
- downloadNESW-response: {}
- - name: activateNESW
+ downloadNESw-response: {}
+ - name: activateNESw
request:
commonHeader: *swugCommonHeader
actionIdentifiers: &activate-ai
blueprintName: PNF_CDS_RESTCONF
blueprintVersion: "1.0.0"
- actionName: activateNESW
+ actionName: activateNESw
mode: sync
payload:
- activateNESW-request:
+ activateNESw-request:
resolution-key: *resKey
- activateNESW-properties: *actionProps
+ activateNESw-properties: *actionProps
expectedResponse:
commonHeader: *swugCommonHeader
actionIdentifiers: *activate-ai
@@ -129,7 +129,7 @@ processes:
errorMessage: null
message: success
payload:
- activateNESW-response: {}
+ activateNESw-response: {}
- name: postCheck
request:
commonHeader: *swugCommonHeader