Fix Bug 2336: Manual Healing option in Ui
*In NS Instances page. Click "Manual Healing" in the actions menu.
*Then a new pop-up page will opened.
*In the popup there will be drop-down containing membervnfIndex and Day1 operation.
*When the membervnfIndex and Day1 operation are selected including muti VDU optional can be selected then Click Apply button.
*The pop-up window is closed and the page is directed to "History of operations" page for this NS.
Change-Id: I3041bcfb56232c6f4b0f56441d89295cc04cfa02
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
(cherry picked from commit 319d328d0bbb1e156ac767851c8c33acb518dc94)
diff --git a/src/app/utilities/healing/HealingComponent.html b/src/app/utilities/healing/HealingComponent.html
new file mode 100644
index 0000000..ad22db6
--- /dev/null
+++ b/src/app/utilities/healing/HealingComponent.html
@@ -0,0 +1,107 @@
+<!--
+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)
+-->
+<div class="modal-header">
+ <h4 class="modal-title" id="modal-basic-title">{{ 'HEALING' | translate }}</h4>
+ <button class="button-xs" type="button" class="close" aria-label="Close" (click)="activeModal.close()">
+ <i class="fas fa-times-circle text-danger"></i>
+ </button>
+</div>
+<form [formGroup]="healingForm" (ngSubmit)="manualHealingTrigger()" autocomplete="off">
+ <div class="modal-body">
+ <div class="form-group row">
+ <label class="col-sm-12 col-form-label mandatory-label"
+ [ngClass]="{'text-danger': healingForm.invalid === true && submitted === true}">
+ {{'MANDATORYCHECK' | translate}}
+ </label>
+ <div class="col-sm-6">
+ <label for="memberVnfIndex"> {{'MEMBERVNFINDEX' | translate}} *</label>
+ </div>
+ <div class="col-sm-6">
+ <ng-select (change)="getVdu($event.vnfinstanceId)" formControlName="memberIndex" [clearable]="false"
+ placeholder="{{'SELECTMEMBERVNFINDEX' | translate}} *" [items]="memberTypes" bindLabel="id" bindValue="id"
+ [ngClass]="{ 'is-invalid': submitted && f.memberIndex.errors }">
+ </ng-select>
+ <small class="form-text text-muted" *ngIf="selectedvnfId !== ''">vnfd-id : {{ selectedvnfId }}</small>
+ </div>
+ </div>
+ <div class="form-group row">
+ <div class="col-sm-6">
+ <label for="memberVnfIndex"> {{'DAY1OPERATION' | translate}}</label>
+ </div>
+ <div class="col-sm-6">
+ <ng-select formControlName="run_day1" [clearable]="false" placeholder="{{'DAY1OPERATION' | translate}}"
+ [items]="day1Operation" bindLabel="name" bindValue="id">
+ </ng-select>
+ </div>
+ </div>
+ <div class="form-group row p-2 bg-light text-white justify-content-end">
+ <div class="col-5">
+ <button class="button-xs" type="button" class="btn btn-primary" (click)="addVdu()">
+ <i class="fas fa-plus-circle"></i>{{'SELECTVDU' | translate}}</button>
+ </div>
+ </div>
+ <ng-container>
+ <div formArrayName="vdu" *ngFor="let params of getControls(); let i = index;">
+ <div class="form-group row" [formGroupName]="i">
+ <div class="card bg-light">
+ <div class="card-body">
+ <div class="form-group row">
+ <label class="col-sm-3 col-md-3 col-form-label" for="vduId_{{i}}">{{'VDUID' |
+ translate}}</label>
+ <div class="col-sm-8 col-md-8">
+ <ng-select (change)="getCountIndex($event.VDU)"
+ placeholder="{{'SELECT' | translate}}" [items]="vduId" bindLabel="VDU"
+ bindValue="VDU" formControlName="vduId" id="vduId_{{i}}"
+ [ngClass]="{ 'is-invalid': submitted && params.controls.vduId.errors }">
+ </ng-select>
+ </div>
+ <label class="col-sm-3 col-md-3 col-form-label" for="countIndex_{{i}}">{{'COUNTINDEX' |
+ translate}}</label>
+ <div class="col-sm-8 col-md-8">
+ <ng-select placeholder="{{'SELECT' | translate}}" [items]="countIndex"
+ bindLabel="count-index" bindValue="count-index" formControlName="countIndex"
+ id="countIndex_{{i}}"
+ [ngClass]="{ 'is-invalid': submitted && params.controls.countIndex.errors }">
+ </ng-select>
+ </div>
+ <label class="col-sm-3 col-md-3 col-form-label" for="runDay1_{{i}}">{{'DAY1OPERATION' |
+ translate}}</label>
+ <div class="col-sm-8 col-md-8">
+ <ng-select formControlName="runDay1" [clearable]="false" placeholder="{{'DAY1OPERATION' |
+ translate}}" [items]="day1Operation" bindLabel="name" bindValue="id">
+ </ng-select>
+ </div>
+ <div class="col-sm-1">
+ <button class="button-xs" type="button" class="close" (click)="removeMapping(i)"
+ placement="right" ngbTooltip="{{ 'CANCEL' | translate }}">
+ <i class="fas fa-minus-circle text-danger"></i>
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </ng-container>
+ </div>
+ <div class="modal-footer">
+ <button type="button" (click)="activeModal.close()" class="btn btn-danger">{{'CANCEL' | translate}}</button>
+ <button type="submit" class="btn btn-primary">{{'APPLY' | translate }}</button>
+ </div>
+</form>
+<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
diff --git a/src/app/utilities/healing/HealingComponent.scss b/src/app/utilities/healing/HealingComponent.scss
new file mode 100644
index 0000000..f7fbc0a
--- /dev/null
+++ b/src/app/utilities/healing/HealingComponent.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/healing/HealingComponent.ts b/src/app/utilities/healing/HealingComponent.ts
new file mode 100644
index 0000000..b3a1072
--- /dev/null
+++ b/src/app/utilities/healing/HealingComponent.ts
@@ -0,0 +1,300 @@
+/*
+ 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 Healing Component
+ */
+import { isNullOrUndefined } from 'util';
+import { HttpHeaders } from '@angular/common/http';
+import { Component, Injector, Input, OnInit } from '@angular/core';
+import { AbstractControl, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { Router } from '@angular/router';
+import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { TranslateService } from '@ngx-translate/core';
+import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, URLPARAMS } from 'CommonModel';
+import { environment } from 'environment';
+import { VDUMAP, VDUMAPPINGS } from 'NSInstanceModel';
+import { RestService } from 'RestService';
+import { SharedService } from 'SharedService';
+import { InstanceData, VDUR, VNFInstanceDetails } from 'VNFInstanceModel';
+/**
+ * Creating component
+ * @Component takes HealingComponent.html as template url
+ */
+@Component({
+ selector: 'app-healing',
+ templateUrl: './HealingComponent.html',
+ styleUrls: ['./HealingComponent.scss']
+})
+export class HealingComponent 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';
+ /** Member index of the NS @public */
+ public memberVNFIndex: {}[] = [];
+ /** Items for the memberVNFIndex @public */
+ public memberTypes: {}[];
+ /** Items for the Day1 operation @public */
+ public day1Operation: {}[];
+ /** Items for the vdu-Id and count-index @public */
+ public vdu: {}[];
+ /** Selected VNFInstanceId @public */
+ public selectedvnfId: string = '';
+ /** Contains vduId @public */
+ public vduId: {};
+ /** VDU Mapping @public */
+ public vduMap: VDUMAP = {};
+ /** Items for countIndex @public */
+ public countIndex: {}[];
+ /** Contains vnfInstanceId of the selected MemberVnfIndex @public */
+ public instanceId: string;
+ /** FormGroup instance added to the form @ html @public */
+ public healingForm: FormGroup;
+ /** Form valid on submit trigger @public */
+ public submitted: boolean = false;
+ /** VDU Form array @private */
+ private vduFormArray: FormArray;
+ /** Array holds VNFR Data filtered with nsr ID @private */
+ private nsIdFilteredData: {}[] = [];
+ /** 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 tranlsate instance @private */
+ private translateService: TranslateService;
+ /** Input contains component objects @private */
+ @Input() private params: URLPARAMS;
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
+ /** Holds teh 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.translateService = this.injector.get(TranslateService);
+ 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.healingForm.controls; }
+
+ /**
+ * Lifecyle Hooks the trigger before component is instantiate
+ */
+ public ngOnInit(): void {
+ this.initializeForm();
+ this.getmemberIndex();
+ this.day1Operation = [
+ { id: 'true', name: this.translateService.instant('True') },
+ { id: '', name: this.translateService.instant('False') }
+ ];
+ this.headers = new HttpHeaders({
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
+ });
+ }
+
+ /** Generate primitive params @public */
+ get vduParamsBuilder(): FormGroup {
+ return this.formBuilder.group({
+ vduId: [null],
+ countIndex: [null],
+ runDay1: [null]
+ });
+ }
+
+ /** Initialize Healing Forms @public */
+ public initializeForm(): void {
+ this.healingForm = this.formBuilder.group({
+ memberIndex: [null, [Validators.required]],
+ run_day1: [null],
+ vdu: this.formBuilder.array([])
+ });
+ }
+
+ /** Handle FormArray Controls @public */
+ public getControls(): AbstractControl[] {
+ return (this.healingForm.get('vdu') as FormArray).controls;
+ }
+
+ /** Get the member-vnf-index from NS Package -> vnf-profile @private */
+ private getmemberIndex(): void {
+ this.isLoadingResults = true;
+ const vnfInstanceData: {}[] = [];
+ this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => {
+ vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => {
+ const nsrId: string = 'nsr-id-ref';
+ const memberIndex: string = 'member-vnf-index-ref';
+ const vnfDataObj: {} =
+ {
+ VNFInstanceId: vnfData._id,
+ // eslint-disable-next-line security/detect-object-injection
+ MemberIndex: vnfData[memberIndex],
+ // eslint-disable-next-line security/detect-object-injection
+ NS: vnfData[nsrId]
+ };
+ vnfInstanceData.push(vnfDataObj);
+ });
+ const nsId: string = 'NS';
+ // eslint-disable-next-line security/detect-object-injection
+ this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData[nsId] === this.params.id);
+ this.nsIdFilteredData.forEach((resVNF: InstanceData): void => {
+ 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 {
+ this.isLoadingResults = true;
+ this.vdu = [];
+ const vnfInstanceData: {}[] = [];
+ this.instanceId = id;
+ if (!isNullOrUndefined(id)) {
+ this.restService.getResource(environment.VNFINSTANCES_URL + '/' + id).
+ subscribe((vnfInstanceDetail: VNFInstanceDetails): void => {
+ this.selectedvnfId = vnfInstanceDetail['vnfd-ref'];
+ if (!isNullOrUndefined(vnfInstanceDetail.vdur)) {
+ vnfInstanceDetail.vdur.forEach((vdu: VDUR): void => {
+ const vnfInstanceDataObj: {} =
+ {
+ 'count-index': vdu['count-index'],
+ VDU: vdu['vdu-id-ref']
+ };
+ vnfInstanceData.push(vnfInstanceDataObj);
+ });
+ this.vdu = vnfInstanceData;
+ this.vduId = this.vdu.filter((vdu: { VDU?: string }, index: number, self: {}[]): {} =>
+ index === self.findIndex((t: { VDU?: string }): {} => (
+ // eslint-disable-next-line security/detect-object-injection
+ t.VDU === vdu.VDU
+ ))
+ );
+ this.isLoadingResults = false;
+ }
+ }
+ , (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'get');
+ this.isLoadingResults = false;
+ });
+ }
+ }
+
+ /** Getting count-index by filtering id */
+ public getCountIndex(id: string): void {
+ const VDU: string = 'VDU';
+ // eslint-disable-next-line security/detect-object-injection
+ this.countIndex = this.vdu.filter((vnfdData: {}[]): boolean => vnfdData[VDU] === id);
+ }
+
+
+ /** Add vdu @public */
+ public addVdu(): void {
+ this.vduFormArray = this.healingForm.get('vdu') as FormArray;
+ this.vduFormArray.push(this.vduParamsBuilder);
+ }
+
+ /** Remove vdu @public */
+ public removeMapping(index: number): void {
+ this.vduFormArray.removeAt(index);
+ }
+
+ /** If form is valid and call healInstances method to initialize healing @public */
+ public manualHealingTrigger(): void {
+ this.submitted = true;
+ let healingPayload: object = {};
+ this.sharedService.cleanForm(this.healingForm);
+ if (this.healingForm.invalid) { return; } // Proceed, onces form is valid
+ this.vduMap.vdu_mappings = [];
+ this.healingForm.value.vdu.forEach((res: VDUMAPPINGS): void => {
+ this.vduMap.vdu_mappings.push({ 'vdu-id': res.vduId, 'count-index': res.countIndex, 'run-day1': Boolean(res.runDay1) });
+ });
+ if (this.vduMap.vdu_mappings.length !== 0) {
+ healingPayload = {
+ healVnfData:
+ [{
+ vnfInstanceId: this.instanceId,
+ cause: 'manual',
+ additionalParams: {
+ 'run-day1': false,
+ vdu: this.vduMap.vdu_mappings
+ }
+ }]
+ };
+ } else {
+ healingPayload = {
+ healVnfData:
+ [{
+ vnfInstanceId: this.instanceId,
+ cause: 'manual',
+ additionalParams: {
+ 'run-day1': Boolean(this.getFormControl('run_day1').value)
+ }
+ }]
+ };
+ }
+ this.healInstances(healingPayload);
+ }
+
+ /** Initialize the healing @public */
+ public healInstances(healingPayload: object): void {
+ this.isLoadingResults = true;
+ const apiURLHeader: APIURLHEADER = {
+ url: environment.NSDINSTANCES_URL + '/' + this.params.id + '/heal',
+ httpOptions: { headers: this.headers }
+ };
+ const modalData: MODALCLOSERESPONSEDATA = {
+ message: 'Done'
+ };
+ this.restService.postResource(apiURLHeader, healingPayload).subscribe((result: {}): void => {
+ this.activeModal.close(modalData);
+ this.router.navigate(['/instances/ns/history-operations/' + this.params.id]).catch((): void => {
+ // Catch Navigation Error
+ });
+ }, (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 {
+ // eslint-disable-next-line security/detect-object-injection
+ return this.healingForm.controls[controlName];
+ }
+}
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
index 517dbde..6a32735 100644
--- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
+++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
@@ -70,6 +70,10 @@
placement="left" data-container="body" ngbTooltip="{{'SCALING' | translate}}">
<i class="fas fa-cubes"></i> {{'SCALING' | translate}}
</button>
+ <button type="button" class="btn btn-primary dropdown-item" [disabled]="operationalStatus === 'healing' || operationalStatus === 'failed' || configStatus === 'failed'" (click)="openHealing()"
+ placement="left" data-container="body" ngbTooltip="{{'HEALING' | translate}}">
+ <i class="fas fa-user-md"></i> {{'HEALING' | translate}}
+ </button>
<button type="button" class="btn btn-primary dropdown-item" (click)="openNsUpdate()" placement="left" data-container="body"
[disabled]="operationalStatus === 'failed' || configStatus === 'failed'" ngbTooltip="{{'NSUPDATE' | translate}}">
<i class="fas fa-arrow-alt-circle-up"></i> {{'NSUPDATE' | translate}}
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
index ea7fa61..08e5e97 100644
--- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
+++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
@@ -27,6 +27,7 @@
import { ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
import { DeleteComponent } from 'DeleteComponent';
import { environment } from 'environment';
+import { HealingComponent } from 'HealingComponent';
import { NSDDetails } from 'NSDModel';
import { NSDInstanceData } from 'NSInstanceModel';
import { NSPrimitiveComponent } from 'NSPrimitiveComponent';
@@ -170,7 +171,7 @@
}
}).catch((): void => {
// Catch Navigation Error
- });
+ });
}
/** History of operations for an Instanace @public */
@@ -285,7 +286,7 @@
}
}).catch((): void => {
// Catch Navigation Error
- });
+ });
}
/** To open VM Migration in NS Instances */
@@ -301,7 +302,7 @@
}
}).catch((): void => {
// Catch Navigation Error
- });
+ });
}
/** To open the Ns Update pop-up */
@@ -317,7 +318,7 @@
}
}).catch((): void => {
// Catch Navigation Error
- });
+ });
}
/** To open the Start, Stop & Rebuild pop-up */
@@ -341,7 +342,7 @@
}
}).catch((): void => {
// Catch Navigation Error
- });
+ });
}
/** To open the vertical Scaling pop-up */
@@ -357,7 +358,23 @@
}
}).catch((): void => {
// Catch Navigation Error
- });
+ });
+ }
+
+ /** Open the Healing pop-up @public */
+ public openHealing(): void {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
+ const modalRef: NgbModalRef = this.modalService.open(HealingComponent, { backdrop: 'static' });
+ modalRef.componentInstance.params = {
+ id: this.instanceID
+ };
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
+ if (result) {
+ this.sharedService.callData();
+ }
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
}
/**
diff --git a/src/app/utilities/scaling/ScalingComponent.html b/src/app/utilities/scaling/ScalingComponent.html
index 803a320..10d5a16 100644
--- a/src/app/utilities/scaling/ScalingComponent.html
+++ b/src/app/utilities/scaling/ScalingComponent.html
@@ -30,7 +30,7 @@
</label>
<div class="col-sm-12">
<ng-select formControlName="memberIndex" [clearable]="false"
- (change)="getScalingGroupDescriptorName($event.vnfdRef)" placeholder="Select Member VNF Index *"
+ (change)="getScalingGroupDescriptorName($event.vnfdRef)" placeholder="{{'SELECTMEMBERVNFINDEX' | translate}} *"
[items]="memberTypes" bindLabel="id" bindValue="id"
[ngClass]="{ 'is-invalid': submitted && f.memberIndex.errors }">
</ng-select>