diff options
9 files changed, 78 insertions, 50 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html index bb7647449..df1911a7d 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html @@ -70,7 +70,7 @@ (click)="downloadPackage(viewedPackage.artifactName,viewedPackage.artifactVersion)"><i class="fa"></i> Download</button> - <button class="btn btn-sm btn-primary">Designer Mode</button> + <button class="btn btn-sm btn-primary" (click)="goToDesignerMode()">Designer Mode</button> </div> </div> @@ -130,4 +130,4 @@ </div> </div> </div> -</div>
\ No newline at end of file +</div> diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts index c67331c3e..6de76f949 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts @@ -12,6 +12,7 @@ import {PackageCreationUtils} from '../package-creation/package-creation.utils'; import {PackageCreationModes} from '../package-creation/creationModes/PackageCreationModes'; import {PackageCreationBuilder} from '../package-creation/creationModes/PackageCreationBuilder'; import {saveAs} from 'file-saver'; +import {DesignerStore} from '../designer/designer.store'; @Component({ selector: 'app-configuration-dashboard', @@ -37,7 +38,8 @@ export class ConfigurationDashboardComponent implements OnInit { constructor(private route: ActivatedRoute, private configurationDashboardService: ConfigurationDashboardService, private packageCreationStore: PackageCreationStore, private packageCreationUtils: PackageCreationUtils, - private router: Router) { + private router: Router, + private designerStore: DesignerStore) { } ngOnInit() { @@ -104,6 +106,10 @@ export class ConfigurationDashboardComponent implements OnInit { } this.packageCreationStore.changeDslDefinition(dslDefinition); this.packageCreationStore.setCustomKeys(mapOfCustomKeys); + // console.log(definition.topology_template.content); + if (definition.topology_template.content) { + this.designerStore.saveSourceContent(definition.topology_template.content); + } } else { this.packageCreationStore.addDefinition(filename, fileData); @@ -200,4 +206,7 @@ export class ConfigurationDashboardComponent implements OnInit { this.router.navigate(['/packages']); } + goToDesignerMode() { + this.router.navigate(['/packages/designer']); + } } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts index b72a5bc47..ba8b2f0f1 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts @@ -76,11 +76,11 @@ export class DesignerStore extends Store<DesignerDashboardState> { } saveSourceContent(code: string) { - const topologtTemplate = JSON.parse(code); + const topologyTemplate = JSON.parse(code); this.setState({ ...this.state, sourceContent: code, - template: topologtTemplate + template: topologyTemplate }); } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts index 45a00ff06..a37339d90 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts @@ -1,4 +1,6 @@ -import { MetaDataTabModel } from './metadata/MetaDataTab.model'; +import {MetaDataTabModel} from './metadata/MetaDataTab.model'; + + export class Definition { @@ -50,6 +52,7 @@ export class Base { return this.files.get(key); } } + export class Scripts { public files: Map<string, string>; @@ -83,6 +86,7 @@ export class Template { export class Mapping extends Base { } + export class CBAPackage { public metaData: MetaDataTabModel; diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/VlbDefinition.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/VlbDefinition.ts index 8e2ff475e..630baa1ac 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/VlbDefinition.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/VlbDefinition.ts @@ -1,5 +1,9 @@ import { Any, JsonObject, JsonProperty } from 'json2typescript'; +@JsonObject('topology_template') +export class TemplateTopology { + public content: string; +} @JsonObject export class VlbDefinition { @@ -10,7 +14,8 @@ export class VlbDefinition { imports: Import[]; // tslint:disable-next-line: variable-name dsl_definitions: DslContent; - // topology_template: TopologyTemplate; + // tslint:disable-next-line: variable-name + topology_template: TemplateTopology; } @JsonObject('dsl_definitions') 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 |