From: SANDHYA.JS Date: Mon, 2 May 2022 02:55:39 +0000 (+0530) Subject: Feature 10922: Start, Stop and Rebuild X-Git-Tag: v12.0.0rc1~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=3d81a28cd6df38cb070c6a6afbbd1528a766f16e;p=osm%2FNG-UI.git Feature 10922: Start, Stop and Rebuild *Added NG-UI support for Start, Stop and Rebuild *In NS Instances page. Click "Start" or "Stop" or "Rebuild" in the actions menu. *Then a new pop-up page will be opened. *In the popup there will be fields containing membervnfIndex, vduid, count index mandatory fields to start, stop or rebuild VNF Instances *When the fields are selected then Click Apply button. *The pop-up window is closed and the page is directed to "History of operations" page Change-Id: Idc0b6316af06b2190732beb198d1e74bcb8b23b0 Signed-off-by: SANDHYA.JS --- diff --git a/src/app/AppModule.ts b/src/app/AppModule.ts index cc9af15..30c6842 100644 --- a/src/app/AppModule.ts +++ b/src/app/AppModule.ts @@ -74,6 +74,7 @@ import { ScalingComponent } from 'ScalingComponent'; import { SDNControllerActionComponent } from 'SDNControllerActionComponent'; import { SharedModule } from 'SharedModule'; import { ShowInfoComponent } from 'ShowInfoComponent'; +import { StartStopRebuildComponent } from 'StartStopRebuildComponent'; import { SwitchProjectComponent } from 'SwitchProjectComponent'; import { UsersActionComponent } from 'UsersActionComponent'; import { UserSettingsComponent } from 'UserSettingsComponent'; @@ -133,7 +134,8 @@ const customNotifierOptions: NotifierOptions = { ChangePasswordComponent, VmMigrationComponent, NsUpdateComponent, - WarningComponent + WarningComponent, + StartStopRebuildComponent ], imports: [ NotifierModule.withConfig(customNotifierOptions), @@ -210,7 +212,8 @@ const customNotifierOptions: NotifierOptions = { ChangePasswordComponent, VmMigrationComponent, NsUpdateComponent, - WarningComponent + WarningComponent, + StartStopRebuildComponent ] }) diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html index 92e462f..db3311a 100644 --- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html +++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html @@ -28,7 +28,26 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i -
+
+ + +
+
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts index 3735df7..1c3f1f2 100644 --- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts +++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts @@ -35,6 +35,7 @@ import { forkJoin, Observable } from 'rxjs'; import { ScalingComponent } from 'ScalingComponent'; import { SharedService } from 'SharedService'; import { ShowInfoComponent } from 'ShowInfoComponent'; +import { StartStopRebuildComponent } from 'StartStopRebuildComponent'; import { isNullOrUndefined } from 'util'; import { VmMigrationComponent } from 'VmMigrationComponent'; import { DF, VDU, VNFD } from 'VNFDModel'; @@ -284,6 +285,27 @@ export class NSInstancesActionComponent { }).catch(); } + /** To open the Start, Stop & Rebuild pop-up */ + public openStart(actionType: string): void { + const modalRef: NgbModalRef = this.modalService.open(StartStopRebuildComponent, { backdrop: 'static' }); + modalRef.componentInstance.params = { + id: this.instanceID + }; + if (actionType === 'start') { + modalRef.componentInstance.instanceTitle = this.translateService.instant('START'); + } else if (actionType === 'stop') { + modalRef.componentInstance.instanceTitle = this.translateService.instant('STOP'); + } else { + modalRef.componentInstance.instanceTitle = this.translateService.instant('REBUILD'); + } + modalRef.componentInstance.instanceType = actionType; + modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { + if (result) { + this.sharedService.callData(); + } + }).catch(); + } + /** * Check any changes in the child component @public */ diff --git a/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.html b/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.html new file mode 100644 index 0000000..b0bba96 --- /dev/null +++ b/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.html @@ -0,0 +1,71 @@ + + +
+ + +
+ \ No newline at end of file diff --git a/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.scss b/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.scss new file mode 100644 index 0000000..f7fbc0a --- /dev/null +++ b/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.scss @@ -0,0 +1,17 @@ +/* + Copyright 2020 TATA ELXSI + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Author: SANDHYA JS (sandhya.j@tataelxsi.co.in) +*/ diff --git a/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.ts b/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.ts new file mode 100644 index 0000000..18b6058 --- /dev/null +++ b/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.ts @@ -0,0 +1,278 @@ +/* + Copyright 2020 TATA ELXSI + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Author: SANDHYA JS (sandhya.j@tataelxsi.co.in) +*/ +/** + * @file StartStopRebuild Component + */ +import { HttpHeaders } from '@angular/common/http'; +import { Component, Injector, Input, OnInit } from '@angular/core'; +import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, URLPARAMS } from 'CommonModel'; +import { environment } from 'environment'; +import { StartStopRebuild } from 'NSInstanceModel'; +import { RestService } from 'RestService'; +import { SharedService } from 'SharedService'; +import { isNullOrUndefined } from 'util'; +import { DF, VNFD } from 'VNFDModel'; +import { VDUR, VNFInstanceDetails } from 'VNFInstanceModel'; + +/** + * Creating component + * @Component takes StartStopRebuildComponent.html as template url + */ +@Component({ + selector: 'app-start-stop-rebuild', + templateUrl: './StartStopRebuildComponent.html', + styleUrls: ['./StartStopRebuildComponent.scss'] +}) +export class StartStopRebuildComponent implements OnInit { + /** To inject services @public */ + public injector: Injector; + /** Instance for active modal service @public */ + public activeModal: NgbActiveModal; + /** Check the loading results @public */ + public isLoadingResults: Boolean = false; + /** Give the message for the loading @public */ + public message: string = 'PLEASEWAIT'; + /** FormGroup instance added to the form @ html @public */ + public startForm: FormGroup; + /** Items for the memberVNFIndex @public */ + public memberTypes: {}[]; + /** Contains MemberVNFIndex values @public */ + public memberVnfIndex: {}[] = []; + /** Contains vnfInstanceId of the selected MemberVnfIndex @public */ + public instanceId: string; + /** Items for vduId & countIndex @public */ + public vdu: {}[]; + /** Selected VNFInstanceId @public */ + public selectedvnfId: string = ''; + /** Check day1-2 operation @public */ + public 'day1-2': boolean; + /** Array holds VNFR Data filtered with nsr ID @public */ + public nsIdFilteredData: {}[] = []; + /** Form valid on submit trigger @public */ + public submitted: boolean = false; + /** Input contains Modal dialog component Instance @public */ + @Input() public instanceType: string; + /** Input contains Modal dialog component Instance @public */ + @Input() public instanceTitle: string; + /** Input contains component objects @private */ + @Input() private params: URLPARAMS; + /** FormBuilder instance added to the formBuilder @private */ + private formBuilder: FormBuilder; + /** Instance of the rest service @private */ + private restService: RestService; + /** Controls the header form @private */ + private headers: HttpHeaders; + /** Contains all methods related to shared @private */ + private sharedService: SharedService; + /** Holds the instance of AuthService class of type AuthService @private */ + private router: Router; + constructor(injector: Injector) { + this.injector = injector; + this.restService = this.injector.get(RestService); + this.activeModal = this.injector.get(NgbActiveModal); + this.formBuilder = this.injector.get(FormBuilder); + this.sharedService = this.injector.get(SharedService); + this.router = this.injector.get(Router); + } + /** convenience getter for easy access to form fields */ + get f(): FormGroup['controls'] { return this.startForm.controls; } + /** + * Lifecyle Hooks the trigger before component is instantiate + */ + public ngOnInit(): void { + this.initializeForm(); + this.getMemberVnfIndex(); + this.headers = new HttpHeaders({ + 'Content-Type': 'application/json', + Accept: 'application/json', + 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0' + }); + } + /** Initialize start, stop or rebuild Forms @public */ + public initializeForm(): void { + this.startForm = this.formBuilder.group({ + memberVnfIndex: [null, [Validators.required]], + vduId: [null, [Validators.required]], + countIndex: [null, [Validators.required]] + }); + } + + /** Getting MemberVnfIndex using VNFInstances API @public */ + public getMemberVnfIndex(): void { + const vnfInstanceData: {}[] = []; + this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => { + vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => { + const vnfDataObj: {} = + { + VNFD: vnfData['vnfd-ref'], + VNFInstanceId: vnfData._id, + MemberIndex: vnfData['member-vnf-index-ref'], + NS: vnfData['nsr-id-ref'], + VNFID: vnfData['vnfd-id'] + }; + vnfInstanceData.push(vnfDataObj); + }); + const nsId: string = 'NS'; + this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData[nsId] === this.params.id); + this.nsIdFilteredData.forEach((resVNF: {}[]): void => { + const memberIndex: string = 'MemberIndex'; + const vnfinstanceID: string = 'VNFInstanceId'; + const assignMemberIndex: {} = { + id: resVNF[memberIndex], + vnfinstanceId: resVNF[vnfinstanceID] + }; + this.memberVnfIndex.push(assignMemberIndex); + }); + this.memberTypes = this.memberVnfIndex; + this.isLoadingResults = false; + }, (error: ERRORDATA): void => { + this.restService.handleError(error, 'get'); + this.isLoadingResults = false; + }); + } + + /** Getting vdu-id & count-index from VNFInstance API */ + public getVdu(id: string): void { + const vnfInstanceData: {}[] = []; + const vnfrDetails: {}[] = []; + this.getFormControl('vduId').setValue(null); + this.getFormControl('countIndex').setValue(null); + if (!isNullOrUndefined(id)) { + this.restService.getResource(environment.VNFINSTANCES_URL + '/' + id). + subscribe((vnfInstanceDetail: VNFInstanceDetails[]): void => { + this.instanceId = id; + this.selectedvnfId = vnfInstanceDetail['vnfd-ref']; + const VDU: string = 'vdur'; + if (vnfInstanceDetail[VDU] !== undefined) { + vnfInstanceDetail[VDU].forEach((vdu: VDUR): void => { + const vnfInstanceDataObj: {} = + { + 'count-index': vdu['count-index'], + VDU: vdu['vdu-id-ref'] + + }; + vnfInstanceData.push(vnfInstanceDataObj); + }); + this.vdu = vnfInstanceData; + } + this.checkDay12Operation(this.selectedvnfId); + }, (error: ERRORDATA): void => { + this.restService.handleError(error, 'get'); + this.isLoadingResults = false; + }); + } + } + + /** To check primitve actions from VNFR */ + public checkDay12Operation(id: string): void { + const apiUrl: string = environment.VNFPACKAGES_URL + '?id=' + id; + this.restService.getResource(apiUrl).subscribe((vnfdInfo: VNFD[]): void => { + const vnfInstances: VNFD = vnfdInfo[0]; + if (!isNullOrUndefined(vnfInstances.df)) { + vnfInstances.df.forEach((df: DF): void => { + if (df['lcm-operations-configuration'] !== undefined) { + if (df['lcm-operations-configuration']['operate-vnf-op-config']['day1-2'] !== undefined) { + this['day1-2'] = true; + } + } else { + this['day1-2'] = false; + } + }); + } + }, (error: ERRORDATA): void => { + this.isLoadingResults = false; + this.restService.handleError(error, 'get'); + }); + } + /** Check Instance type is start or stop or rebuild and proceed action */ + public instanceCheck(instanceType: string): void { + this.submitted = true; + this.sharedService.cleanForm(this.startForm); + if (this.startForm.invalid) { return; } // Proceed, onces form is valid + if (instanceType === 'start') { + const startPayload: StartStopRebuild = { + updateType: 'OPERATE_VNF', + operateVnfData: { + vnfInstanceId: this.instanceId, + changeStateTo: 'start', + additionalParam: { + 'run-day1': false, + vdu_id: this.startForm.value.vduId, + 'count-index': this.startForm.value.countIndex + } + } + }; + this.startInitialization(startPayload); + } else if (instanceType === 'stop') { + const stopPayload: StartStopRebuild = { + updateType: 'OPERATE_VNF', + operateVnfData: { + vnfInstanceId: this.instanceId, + changeStateTo: 'stop', + additionalParam: { + 'run-day1': false, + vdu_id: this.startForm.value.vduId, + 'count-index': this.startForm.value.countIndex + } + } + }; + this.startInitialization(stopPayload); + } else { + const rebuildPayload: StartStopRebuild = { + updateType: 'OPERATE_VNF', + operateVnfData: { + vnfInstanceId: this.instanceId, + changeStateTo: 'rebuild', + additionalParam: { + 'run-day1': (this['day1-2'] === true) ? true : false, + vdu_id: this.startForm.value.vduId, + 'count-index': this.startForm.value.countIndex + } + } + }; + this.startInitialization(rebuildPayload); + } + } + + /** Initialize the start, stop or rebuild operation @public */ + public startInitialization(startPayload: object): void { + this.isLoadingResults = true; + const apiURLHeader: APIURLHEADER = { + url: environment.NSDINSTANCES_URL + '/' + this.params.id + '/update', + httpOptions: { headers: this.headers } + }; + const modalData: MODALCLOSERESPONSEDATA = { + message: 'Done' + }; + this.restService.postResource(apiURLHeader, startPayload).subscribe((result: {}): void => { + this.activeModal.close(modalData); + this.router.navigate(['/instances/ns/history-operations/' + this.params.id]).catch(); + }, (error: ERRORDATA): void => { + this.restService.handleError(error, 'post'); + this.isLoadingResults = false; + }); + } + + /** Used to get the AbstractControl of controlName passed @private */ + private getFormControl(controlName: string): AbstractControl { + return this.startForm.controls[controlName]; + } +} diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 9fa8bd4..3da4bea 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -183,6 +183,10 @@ "UPDATEPOLICIESCONTENT": "Diese Aktion umfasst die Neuerstellung der Richtlinien dieser VNF. Sind Sie sicher, dass Sie fortfahren möchten", "REDEPLOYCONTENT": "Diese Aktion umfasst die erneute Bereitstellung aller Ressourcen dieser VNF. Sind Sie sicher, dass Sie fortfahren möchten", "TERMINATEVNFCONTENT": "Diese Aktion beinhaltet das Beenden dieser VNF. Sind Sie sicher, dass Sie fortfahren möchten", + "REBUILD": "Wiederaufbau", + "START": "Start", + "STOP": "Halt", + "VIMACTION": "VIM-Aktion", "PAGE": { "DASHBOARD": { "DASHBOARD": "Instrumententafel", diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 6f00d56..8825b38 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -183,6 +183,10 @@ "UPDATEPOLICIESCONTENT": "This action involves recreating the policies of this VNF. Are you sure you want to proceed", "REDEPLOYCONTENT": "This action involves redeploying all resources of this VNF. Are you sure you want to proceed", "TERMINATEVNFCONTENT": "This action involves terminating this VNF. Are you sure you want to proceed", + "REBUILD": "Rebuild", + "START": "Start", + "STOP": "Stop", + "VIMACTION": "VIM Action", "PAGE": { "DASHBOARD": { "DASHBOARD": "Dashboard", diff --git a/src/assets/i18n/es.json b/src/assets/i18n/es.json index 6c49608..c45ef4d 100644 --- a/src/assets/i18n/es.json +++ b/src/assets/i18n/es.json @@ -183,6 +183,10 @@ "UPDATEPOLICIESCONTENT": "Esta acción implica recrear las políticas de este VNF. Estas seguro que deseas continuar", "REDEPLOYCONTENT": "Esta acción implica redistribuir todos los recursos de este VNF. Estas seguro que deseas continuar", "TERMINATEVNFCONTENT": "Esta acción implica la terminación de este VNF. Estas seguro que deseas continuar", + "REBUILD": "Reconstruir", + "START": "Comienzo", + "STOP": "Parada", + "VIMACTION": "Acción VIM", "PAGE": { "DASHBOARD": { "DASHBOARD": "Tablero", diff --git a/src/assets/i18n/pt.json b/src/assets/i18n/pt.json index 03b698f..7e936ce 100644 --- a/src/assets/i18n/pt.json +++ b/src/assets/i18n/pt.json @@ -183,6 +183,10 @@ "UPDATEPOLICIESCONTENT": "Esta ação envolve a recriação das políticas desta VNF. Tem certeza de que deseja continuar", "REDEPLOYCONTENT": "Esta ação envolve a redistribuição de todos os recursos desta VNF. Tem certeza de que deseja continuar", "TERMINATEVNFCONTENT": "Esta ação envolve encerrar este VNF. Tem certeza de que deseja continuar", + "REBUILD": "Reconstruir", + "START": "Começar", + "STOP": "Pare", + "VIMACTION": "Ação VIM", "PAGE": { "DASHBOARD": { "DASHBOARD": "painel de controle", diff --git a/src/models/NSInstanceModel.ts b/src/models/NSInstanceModel.ts index 66a6da8..99af8d7 100644 --- a/src/models/NSInstanceModel.ts +++ b/src/models/NSInstanceModel.ts @@ -185,6 +185,26 @@ export interface TERMINATEVNF { removeVnfInstanceId: string; } +/** Interface for Start, Stop & Rebuild */ +export interface StartStopRebuild { + updateType: string; + operateVnfData: OPERATEVNFDATA; +} + +/** Interface for operateVnfData in Start, Stop and Rebuild */ +export interface OPERATEVNFDATA { + additionalParam: ADDITIONALPARAMS; + vnfInstanceId: string; + changeStateTo: string; +} + +/** Interface for additionalParam in Start, Stop and Rebuild */ +export interface ADDITIONALPARAMS { + 'run-day1': boolean; + 'vdu_id': string; + 'count-index': string; +} + /** Interface for InstantiateParam */ interface InstantiateParam { nsdId: string; diff --git a/tsconfig.json b/tsconfig.json index cba3c42..cce28e0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -155,6 +155,7 @@ "VmMigrationComponent": ["src/app/utilities/vm-migration/VmMigrationComponent"], "NsUpdateComponent": ["src/app/utilities/ns-update/NsUpdateComponent"], "WarningComponent": ["src/app/utilities/warning/WarningComponent"], + "StartStopRebuildComponent": ["src/app/utilities/start-stop-rebuild/StartStopRebuildComponent"] } } } \ No newline at end of file