diff options
author | Mohamed Asgar Samiulla(ma926a) <ma926a@us.att.com> | 2018-04-17 15:14:28 +0530 |
---|---|---|
committer | Mohamed Asgar Samiulla(ma926a) <ma926a@us.att.com> | 2018-04-17 15:14:54 +0530 |
commit | 7f0939f148645d3b47653dbee7fadc341b16c1c2 (patch) | |
tree | 8871e8ce9a961bdd29f462e6a12c23660c33f6c2 /src/app/vnfs/build-artifacts/reference-dataform | |
parent | 05fc71b2f0612509c4da0ad74bf15f7001ea4e34 (diff) |
VM data retrieval from APPC for open stack action
VM data retrieval and stopping user not to navigate to PD and template
if mandatory fields are missing in reference data.
Issue-ID: APPC-853
Change-Id: Id43500579c6d222a2c17a53db9213372afec565f
Signed-off-by: Mohamed Asgar Samiulla(ma926a) <ma926a@us.att.com>
Diffstat (limited to 'src/app/vnfs/build-artifacts/reference-dataform')
-rw-r--r-- | src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts | 10 | ||||
-rw-r--r-- | src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts | 33 |
2 files changed, 39 insertions, 4 deletions
diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts index 72f56a7..43a367a 100644 --- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts +++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.spec.ts @@ -972,4 +972,14 @@ describe('ReferenceDataformComponent', () => { expect(spy).toHaveBeenCalled() }); + it('Should return valid data in getArtifactsOpenStack', () => { + component.tempAllData = [{"action":"OpenStack Actions","action-level":"vnf","scope":{"vnf-type":"OpenStack test8","vnfc-type":""},"template":"N","vm":[],"device-protocol":"OpenStack","user-name":"","port-number":"","artifact-list":[],"scopeType":"vnf-type"},{"action":"AllAction","action-level":"vnf","scope":{"vnf-type":"OpenStack test8","vnfc-type":""},"artifact-list":[{"artifact-name":"reference_AllAction_OpenStacktest8_0.0.1V.json","artifact-type":"reference_template"}]},{"action":"Migrate","action-level":"vm","scope":{"vnf-type":"OpenStack test8","vnfc-type":null},"vnfc-function-code-list":["First","Second","Third","Fourth","Fifth"],"template":"N","device-protocol":"OS"},{"action":"Reboot","action-level":"vm","scope":{"vnf-type":"OpenStack test8","vnfc-type":null},"vnfc-function-code-list":["First","Second","Fourth","Fifth"],"template":"N","device-protocol":"OS"},{"action":"Rebuild","action-level":"vm","scope":{"vnf-type":"OpenStack test8","vnfc-type":null},"vnfc-function-code-list":["First","Second","Third","Fourth"],"template":"N","device-protocol":"OS"},{"action":"Snapshot","action-level":"vm","scope":{"vnf-type":"OpenStack test8","vnfc-type":null},"vnfc-function-code-list":["First","Third"],"template":"N","device-protocol":"OS"},{"action":"AttachVolume","action-level":"vm","scope":{"vnf-type":"OpenStack test8","vnfc-type":null},"vnfc-function-code-list":["First","Second","Third","Fourth"],"template":"N","device-protocol":"OS"},{"action":"DetachVolume","action-level":"vm","scope":{"vnf-type":"OpenStack test8","vnfc-type":null},"vnfc-function-code-list":["First","Fourth"],"template":"N","device-protocol":"OS"}] + let firstArrayElement = ["VM Type","First","Second","Third","Fourth","Fifth"]; + let remUploadedDataArray = [["Migrate","Y","Y","Y","Y","Y"],["Reboot","Y","Y","","Y","Y"],["Rebuild","Y","Y","Y","Y"],["Snapshot","Y","","Y"],["AttachVolume","Y","Y","Y","Y"],["DetachVolume","Y","","","Y"]]; + + component.getArtifactsOpenStack(); + + expect(component.firstArrayElement).toEqual(firstArrayElement); + expect(component.remUploadedDataArray).toEqual(remUploadedDataArray); + }); }); diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts index 72501ab..62b3044 100644 --- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts +++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts @@ -895,15 +895,19 @@ export class ReferenceDataformComponent implements OnInit { this.toggleIdentifier(data) this.oldAction = this.currentAction;// this.referenceDataObject.action + ''; this.referenceDataObject.action = this.currentAction + this.populateExistinAction(data); if (this.oldAction === 'OpenStack Actions') { + this.uploadedDataArray = []; this.remUploadedDataArray = []; this.firstArrayElement = []; this.uploadFileName = ''; + //this.tempAllData = []; } this.clearCache(); this.refernceScopeObj.from = ''; + this.getArtifactsOpenStack() } else { this.toggleIdentifier(data) this.currentAction = this.referenceDataObject.action; @@ -914,8 +918,15 @@ export class ReferenceDataformComponent implements OnInit { this.clearVnfcData() this.refernceScopeObj.from = ''; } + // Enable or Block Template and PD Tabs - this.buildDesignComponent.getRefData(this.referenceDataObject); + if(this.currentAction == 'ConfigScaleOut' && this.templateIdentifier) { + let referenceDataObjectTemp = this.referenceDataObject; + referenceDataObjectTemp['template-id'] = this.templateIdentifier; + this.buildDesignComponent.getRefData(referenceDataObjectTemp); + } else { + this.buildDesignComponent.getRefData(this.referenceDataObject); + } }); } else { this.actionChanged = true; @@ -923,8 +934,15 @@ export class ReferenceDataformComponent implements OnInit { this.populateExistinAction(data); this.resetVmsForScaleout(data); this.toggleIdentifier(data); + // Enable or Block Template and PD Tabs - this.buildDesignComponent.getRefData(this.referenceDataObject); + if(this.currentAction == 'ConfigScaleOut' && this.templateIdentifier) { + let referenceDataObjectTemp = this.referenceDataObject; + referenceDataObjectTemp['template-id'] = this.templateIdentifier; + this.buildDesignComponent.getRefData(referenceDataObjectTemp); + } else { + this.buildDesignComponent.getRefData(this.referenceDataObject); + } } this.configDrp(data) } @@ -977,6 +995,11 @@ export class ReferenceDataformComponent implements OnInit { if (data == null) { return; } + // Enable or Block Template and PD Tabs + let referenceDataObjectTemp = this.referenceDataObject; + referenceDataObjectTemp['template-id'] = data; + this.buildDesignComponent.getRefData(referenceDataObjectTemp); + if ((userForm.valid) && this.oldAction != '' && this.oldAction != undefined) { this.currentAction = "ConfigScaleOut" let referenceObject = this.prepareReferenceObject(); @@ -1324,22 +1347,24 @@ export class ReferenceDataformComponent implements OnInit { trackByFn(index, item) { return index; } - getArtifactsOpenStack() { + getArtifactsOpenStack() { var array = [] var vnfcFunctionCodeArrayList = []; var vnfcSet = new Set(); - vnfcSet.add("VM Type") for (var i = 0; i < this.tempAllData.length; i++) { if (!this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions) && (this.tempAllData[i].action != 'AllAction')) { var vnfcFunctionCodeArray = this.tempAllData[i]["vnfc-function-code-list"] + vnfcSet.add("Actions") for (var j = 0; j < vnfcFunctionCodeArray.length; j++) { vnfcSet.add(vnfcFunctionCodeArray[j]) } vnfcFunctionCodeArrayList.push([this.tempAllData[i].action].concat(this.tempAllData[i]["vnfc-function-code-list"])) } } + var vnfcSetArray = Array.from(vnfcSet); let vnfcSetArrayLen = vnfcSetArray.length; + for (let i = 0; i < vnfcFunctionCodeArrayList.length; i++) { let element = vnfcFunctionCodeArrayList[i]; for (let j = 1; j < element.length; j++) { |