Feature-9518: Scale-in/Scale-out commands triggered from the UI
* In NS Instances page. Click "Manual Scaling" in the actions menu.
* Then a new pop-up page will opened.
* In the popup there will be a list box which is filled with the all scaling-group-descriptor names captured from all VNFDs in the NSD and whoose scaling-type is "manual".
* Select scale in / scale out.
* When the scaling-group-descriptor name and the scaling direction are 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: Iaaa1500bcabea4ebda89f6c11ea91b28396aa42f
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
index 823d99f..977a87e 100644
--- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
+++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
@@ -36,6 +36,10 @@
<button type="button" class="btn btn-primary dropdown-item" (click)="execNSPrimitiveModal()" placement="left" container="body" ngbTooltip="{{'EXECPRIMITIVE' | translate}}" [disabled]="operationalStatus == 'failed' || configStatus == 'failed'">
<i class="fas fa-magic"></i> {{'EXECPRIMITIVE' | translate}}
</button>
+ <button type="button" class="btn btn-primary dropdown-item" [disabled]="operationalStatus === 'scaling'" (click)="manualScaling()"
+ 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" (click)="historyOfOperations()" placement="left" container="body" ngbTooltip="{{'HISTORYOFOPERATIONS' | translate}}">
<i class="fas fa-history"></i> {{'HISTORYOFOPERATIONS' | translate}}
</button>
@@ -45,4 +49,4 @@
</div>
</div>
</div>
-<app-loader [waitingMessage]="message" *ngIf="isLoadingMetricsResult"></app-loader>
\ No newline at end of file
+<app-loader [waitingMessage]="message" *ngIf="isLoadingNSInstanceAction"></app-loader>
\ No newline at end of file
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
index c3533ea..ed24a67 100644
--- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
+++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
@@ -30,9 +30,12 @@
import { NSDInstanceData } from 'NSInstanceModel';
import { NSPrimitiveComponent } from 'NSPrimitiveComponent';
import { RestService } from 'RestService';
+import { forkJoin, Observable } from 'rxjs';
+import { ScalingComponent } from 'ScalingComponent';
import { SharedService } from 'SharedService';
import { ShowInfoComponent } from 'ShowInfoComponent';
-import { VDU, VNFD } from 'VNFDModel';
+import { isNullOrUndefined } from 'util';
+import { DF, VDU, VNFD } from 'VNFDModel';
/**
* Creating component
* @Component takes NSInstancesActionComponent.html as template url
@@ -59,12 +62,21 @@
/** Operational Status Check @public */
public operationalStatus: string;
+ /** get Admin Details @public */
+ public getAdminDetails: {};
+
+ /** Scaling is accepted @public */
+ public isScalingPresent: boolean = false;
+
/** Check the loading results for loader status @public */
- public isLoadingMetricsResult: boolean = false;
+ public isLoadingNSInstanceAction: boolean = false;
/** Give the message for the loading @public */
public message: string = 'PLEASEWAIT';
+ /** Assign the VNF Details @public */
+ public vnfDetails: VNFD[] = [];
+
/** Instance of the modal service @private */
private modalService: NgbModal;
@@ -87,7 +99,7 @@
private cd: ChangeDetectorRef;
/** Set timeout @private */
- private timeOut: number = 1000;
+ private timeOut: number = 100;
constructor(injector: Injector) {
this.injector = injector;
@@ -107,6 +119,7 @@
this.configStatus = this.value.ConfigStatus;
this.operationalStatus = this.value.OperationalStatus;
this.instanceID = this.value.identifier;
+ this.getAdminDetails = this.value.adminDetails;
}
/** Shows information using modalservice @public */
@@ -154,32 +167,96 @@
/** Redirect to Grafana Metrics @public */
public metrics(): void {
- this.isLoadingMetricsResult = true;
+ this.isLoadingNSInstanceAction = true;
this.restService.getResource(environment.NSDINSTANCES_URL + '/' + this.instanceID).subscribe((nsData: NSDDetails[]): void => {
nsData['vnfd-id'].forEach((vnfdID: string[]): void => {
this.restService.getResource(environment.VNFPACKAGES_URL + '/' + vnfdID)
.subscribe((vnfd: VNFD): void => {
vnfd.vdu.forEach((vduData: VDU): void => {
if (vduData['monitoring-parameter'] !== undefined && vduData['monitoring-parameter'].length > 0) {
- this.isLoadingMetricsResult = false;
+ this.isLoadingNSInstanceAction = false;
const location: string = environment.GRAFANA_URL + '/' + this.instanceID + '/osm-ns-metrics-metrics';
window.open(location);
} else {
- this.isLoadingMetricsResult = false;
+ this.isLoadingNSInstanceAction = false;
this.notifierService.notify('error', this.translateService.instant('GRAFANA.METRICSERROR'));
}
});
- setTimeout((): void => {
- this.cd.detectChanges();
- }, this.timeOut);
+ this.doChanges();
}, (error: ERRORDATA): void => {
this.restService.handleError(error, 'get');
- this.isLoadingMetricsResult = false;
+ this.isLoadingNSInstanceAction = false;
});
});
}, (error: ERRORDATA): void => {
this.restService.handleError(error, 'get');
- this.isLoadingMetricsResult = false;
+ this.isLoadingNSInstanceAction = false;
});
}
+
+ /**
+ * Do the manual scaling
+ * Here we are going to get a list of VNFD ID used in the instances
+ * and have this in array with URL created then pass to checkscaling method for forkjoin to get the data @public
+ */
+ public manualScaling(): void {
+ this.isLoadingNSInstanceAction = true;
+ const tempURL: Observable<{}>[] = [];
+ this.value.vnfID.forEach((id: string): void => {
+ const apiUrl: string = environment.VNFPACKAGESCONTENT_URL + '/' + id;
+ tempURL.push(this.restService.getResource(apiUrl));
+ });
+ this.checkScaling(tempURL);
+ }
+
+ /**
+ * Used to forkjoin to all the request to send parallely, get the data and check 'scaling-aspect' key is present @public
+ */
+ public checkScaling(URLS: Observable<{}>[]): void {
+ forkJoin(URLS).subscribe((data: VNFD[]): void => {
+ this.vnfDetails = data;
+ if (this.vnfDetails.length > 0) {
+ this.vnfDetails.forEach((vnfdData: VNFD): void => {
+ vnfdData.df.forEach((dfData: DF): void => {
+ if (!isNullOrUndefined(dfData['scaling-aspect']) && dfData['scaling-aspect'].length > 0) {
+ this.isScalingPresent = true;
+ }
+ });
+ });
+ }
+ this.isLoadingNSInstanceAction = false;
+ if (this.isScalingPresent) {
+ this.openScaling();
+ } else {
+ this.notifierService.notify('error', this.translateService.instant('SCALINGNOTFOUND'));
+ }
+ this.doChanges();
+ });
+ }
+
+ /** Open the scaling pop-up @public */
+ public openScaling(): void {
+ const modalRef: NgbModalRef = this.modalService.open(ScalingComponent, { backdrop: 'static' });
+ modalRef.componentInstance.params = {
+ id: this.instanceID,
+ vnfID: this.value.vnfID,
+ nsID: this.value['nsd-id'],
+ nsd: this.value.nsd,
+ data: this.vnfDetails
+ };
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
+ if (result) {
+ this.sharedService.callData();
+ }
+ }).catch();
+ }
+
+ /**
+ * Check any changes in the child component @public
+ */
+ public doChanges(): void {
+ setTimeout((): void => {
+ this.cd.detectChanges();
+ }, this.timeOut);
+ }
}