Feature-9518: Scale-in/Scale-out commands triggered from the UI 65/10565/9
authorBarath Kumar R <barath.r@tataelxsi.co.in>
Tue, 30 Mar 2021 06:20:42 +0000 (11:50 +0530)
committerrbara <barath.r@tataelxsi.co.in>
Thu, 15 Apr 2021 15:59:48 +0000 (17:59 +0200)
 * 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>
18 files changed:
src/app/AppModule.ts
src/app/instances/ns-history-operations/HistoryOperationsComponent.ts
src/app/instances/ns-instances/NSInstancesComponent.html
src/app/instances/ns-instances/NSInstancesComponent.ts
src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
src/app/utilities/scaling/ScalingComponent.html [new file with mode: 0644]
src/app/utilities/scaling/ScalingComponent.scss [new file with mode: 0644]
src/app/utilities/scaling/ScalingComponent.ts [new file with mode: 0644]
src/assets/i18n/de.json
src/assets/i18n/en.json
src/assets/i18n/es.json
src/assets/i18n/pt.json
src/models/CommonModel.ts
src/models/NSDModel.ts
src/models/NSInstanceModel.ts
src/models/VNFDModel.ts
tsconfig.json

index 5cfa65b..70f10dc 100644 (file)
@@ -67,6 +67,7 @@ import { PageNotFoundComponent } from 'PageNotFound';
 import { PDUInstancesActionComponent } from 'PDUInstancesActionComponent';
 import { ProjectLinkComponent } from 'ProjectLinkComponent';
 import { ProjectsActionComponent } from 'ProjectsAction';
+import { ScalingComponent } from 'ScalingComponent';
 import { SDNControllerActionComponent } from 'SDNControllerActionComponent';
 import { ShowInfoComponent } from 'ShowInfoComponent';
 import { SwitchProjectComponent } from 'SwitchProjectComponent';
@@ -121,7 +122,8 @@ const customNotifierOptions: NotifierOptions = {
         PDUInstancesActionComponent,
         SDNControllerActionComponent,
         SwitchProjectComponent,
-        GoToTopDirective
+        GoToTopDirective,
+        ScalingComponent
     ],
     imports: [
         NotifierModule.withConfig(customNotifierOptions),
@@ -191,7 +193,8 @@ const customNotifierOptions: NotifierOptions = {
         WIMAccountsActionComponent,
         PDUInstancesActionComponent,
         SDNControllerActionComponent,
-        SwitchProjectComponent
+        SwitchProjectComponent,
+        ScalingComponent
     ]
 })
 
index a0cac86..7f268d1 100644 (file)
@@ -33,6 +33,7 @@ import { RestService } from 'RestService';
 import { Subscription } from 'rxjs';
 import { SharedService } from 'SharedService';
 import { ShowInfoComponent } from 'ShowInfoComponent';
+import { isNullOrUndefined } from 'util';
 
 /**
  * Creating component
@@ -231,12 +232,16 @@ export class HistoryOperationsComponent implements OnInit {
   /** generateData initiate the ns-instance list @private */
   private generateData(): void {
     this.isLoadingResults = true;
-    this.restService.getResource(this.historyURL).subscribe((nsdInstancesData: {}[]) => {
+    this.restService.getResource(this.historyURL).subscribe((nsdInstancesData: {}[]): void => {
       this.nsAndnstInstanceData = [];
-      nsdInstancesData.forEach((nsdAndnstInstanceData: NSDInstanceData) => {
+      nsdInstancesData.forEach((nsdAndnstInstanceData: NSDInstanceData): void => {
+        let scaleType: string = '';
+        if (!isNullOrUndefined(nsdAndnstInstanceData.operationParams.scaleVnfData)) {
+          scaleType = ' (' + nsdAndnstInstanceData.operationParams.scaleVnfData.scaleVnfType + ')';
+        }
         const nsAndnstDataObj: {} = {
           id: nsdAndnstInstanceData.id,
-          type: nsdAndnstInstanceData.lcmOperationType,
+          type: nsdAndnstInstanceData.lcmOperationType + scaleType,
           state: nsdAndnstInstanceData.operationState,
           startTime: this.sharedService.convertEpochTime(nsdAndnstInstanceData.startTime),
           statusEnteredTime: this.sharedService.convertEpochTime(nsdAndnstInstanceData.statusEnteredTime)
@@ -249,11 +254,11 @@ export class HistoryOperationsComponent implements OnInit {
       } else {
         this.checkDataClass = 'dataTables_empty';
       }
-      this.dataSource.load(this.nsAndnstInstanceData).then((data: {}) => {
+      this.dataSource.load(this.nsAndnstInstanceData).then((data: {}): void => {
         //empty block
       }).catch();
       this.isLoadingResults = false;
-    }, (error: ERRORDATA) => {
+    }, (error: ERRORDATA): void => {
       this.isLoadingResults = false;
       if (error.error.status === HttpStatus.NOT_FOUND || error.error.status === HttpStatus.UNAUTHORIZED) {
         this.router.navigateByUrl('404', { skipLocationChange: true }).catch();
index 6047a2f..523ee44 100644 (file)
@@ -31,6 +31,7 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
             <span><i class="fas fa-check-circle text-success"></i>{{operationalStateSecondStep}} /
                 {{configStateSecondStep}}</span>
             <span><i class="fas fa-times-circle text-danger"></i>{{operationalStateThirdStep}}</span>
+            <span><i class="fas fa-compress-alt text-success"></i>{{operationalStateFourthStep}}</span>
         </nav>
     </div>
     <page-per-row class="mr-2" (pagePerRow)="onChange($event)"></page-per-row>
index 41bb384..3f20710 100644 (file)
@@ -81,6 +81,9 @@ export class NSInstancesComponent implements OnInit {
     /** operational State failed data @public */
     public operationalStateThirdStep: string = CONFIGCONSTANT.operationalStateThirdStep;
 
+    /** operational State scaling data @public */
+    public operationalStateFourthStep: string = CONFIGCONSTANT.operationalStateFourthStep;
+
     /** Config State init data @public */
     public configStateFirstStep: string = CONFIGCONSTANT.configStateFirstStep;
 
@@ -153,7 +156,8 @@ export class NSInstancesComponent implements OnInit {
                         list: [
                             { value: this.operationalStateFirstStep, title: this.operationalStateFirstStep },
                             { value: this.operationalStateSecondStep, title: this.operationalStateSecondStep },
-                            { value: this.operationalStateThirdStep, title: this.operationalStateThirdStep }
+                            { value: this.operationalStateThirdStep, title: this.operationalStateThirdStep },
+                            { value: this.operationalStateFourthStep, title: this.operationalStateFourthStep }
                         ]
                     }
                 },
@@ -170,6 +174,10 @@ export class NSInstancesComponent implements OnInit {
                         return `<span class="icon-label" title="${row.OperationalStatus}">
                         <i class="fas fa-times-circle text-danger"></i>
                         </span>`;
+                    } else if (row.OperationalStatus === this.operationalStateFourthStep) {
+                        return `<span class="icon-label" title="${row.OperationalStatus}">
+                        <i class="fas fa-compress-alt text-success"></i>
+                        </span>`;
                     } else {
                         return `<span>${row.OperationalStatus}</span>`;
                     }
@@ -230,7 +238,11 @@ export class NSInstancesComponent implements OnInit {
                     ConfigStatus: nsdInstanceData['config-status'],
                     DetailedStatus: nsdInstanceData['detailed-status'],
                     memberIndex: nsdInstanceData.nsd.df,
-                    nsConfig: nsdInstanceData.nsd['ns-configuration']
+                    nsConfig: nsdInstanceData.nsd['ns-configuration'],
+                    adminDetails: nsdInstanceData._admin,
+                    vnfID: nsdInstanceData['vnfd-id'],
+                    nsd: nsdInstanceData.nsd,
+                    'nsd-id': nsdInstanceData['nsd-id']
                 };
                 this.nsInstanceData.push(nsDataObj);
             });
index 823d99f..977a87e 100644 (file)
@@ -36,6 +36,10 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
             <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 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
         </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
index c3533ea..ed24a67 100644 (file)
@@ -30,9 +30,12 @@ import { NSDDetails } from 'NSDModel';
 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 @@ export class NSInstancesActionComponent {
   /** 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 @@ export class NSInstancesActionComponent {
   private cd: ChangeDetectorRef;
 
   /** Set timeout @private */
-  private timeOut: number = 1000;
+  private timeOut: number = 100;
 
   constructor(injector: Injector) {
     this.injector = injector;
@@ -107,6 +119,7 @@ export class NSInstancesActionComponent {
     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 @@ export class NSInstancesActionComponent {
 
   /** 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);
   }
 }
diff --git a/src/app/utilities/scaling/ScalingComponent.html b/src/app/utilities/scaling/ScalingComponent.html
new file mode 100644 (file)
index 0000000..4bcb084
--- /dev/null
@@ -0,0 +1,62 @@
+<!--
+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: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+-->
+<div class="modal-header">
+    <h4 class="modal-title" id="modal-basic-title">{{ 'SCALING' | 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]="scalingForm" (ngSubmit)="manualScalingTrigger()" autocomplete="off">
+    <div class="modal-body">
+        <div class="form-group row">
+            <label class="col-sm-12 col-form-label mandatory-label"
+                [ngClass]="{'text-danger': scalingForm.invalid === true && submitted === true}">
+                {{'MANDATORYCHECK' | translate}}
+            </label>
+            <div class="col-sm-12">
+                <ng-select formControlName="memberIndex" [clearable]="false"
+                    (change)="getScalingGroupDescriptorName($event.name)" placeholder="Select Member VNF Index *"
+                    [items]="memberVNFIndex" 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-12">
+                <ng-select formControlName="scalingname" [clearable]="false" placeholder="Select scaling-aspect *"
+                    [items]="scalingGroup" bindLabel="name" bindValue="id"
+                    [ngClass]="{ 'is-invalid': submitted && f.scalingname.errors }">
+                </ng-select>
+            </div>
+        </div>
+        <div class="form-group row">
+            <div class="col-sm-12">
+                <ng-select formControlName="scaleType" [clearable]="false" placeholder="Select Scale Type *"
+                    [items]="scaleTypes" bindLabel="name" bindValue="id"
+                    [ngClass]="{ 'is-invalid': submitted && f.scaleType.errors }">
+                </ng-select>
+            </div>
+        </div>
+    </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/scaling/ScalingComponent.scss b/src/app/utilities/scaling/ScalingComponent.scss
new file mode 100644 (file)
index 0000000..b11bf46
--- /dev/null
@@ -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: BARATH KUMAR R (barath.r@tataelxsi.co.in)
+*/
diff --git a/src/app/utilities/scaling/ScalingComponent.ts b/src/app/utilities/scaling/ScalingComponent.ts
new file mode 100644 (file)
index 0000000..930eb86
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ 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: BARATH KUMAR R (barath.r@tataelxsi.co.in)
+*/
+/**
+ * @file Scaling 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 { TranslateService } from '@ngx-translate/core';
+import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, URLPARAMS } from 'CommonModel';
+import { environment } from 'environment';
+import { DF as NSDF, VNFPROFILE } from 'NSDModel';
+import { RestService } from 'RestService';
+import { SharedService } from 'SharedService';
+import { isNullOrUndefined } from 'util';
+import { DF, SCALING, VNFD } from 'VNFDModel';
+
+/**
+ * Creating component
+ * @Component takes ScalingComponent.html as template url
+ */
+@Component({
+    selector: 'app-scaling',
+    templateUrl: './ScalingComponent.html',
+    styleUrls: ['./ScalingComponent.scss']
+})
+export class ScalingComponent 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';
+    /** Contains the scaling group descriptor names @public */
+    public scalingGroup: {}[];
+    /** Member index of the NS @public */
+    public memberVNFIndex: {}[];
+    /** handles the selected VNFID @public */
+    public selectedVNFID: string = '';
+    /** Items for the Scale Types @public */
+    public scaleTypes: {}[];
+    /** FormGroup instance added to the form @ html @public */
+    public scalingForm: FormGroup;
+    /** Form valid on submit trigger @public */
+    public submitted: boolean = false;
+    /** 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.scalingForm.controls; }
+
+    /**
+     * Lifecyle Hooks the trigger before component is instantiate
+     */
+    public ngOnInit(): void {
+        this.initializeForm();
+        this.getmemberIndex();
+        this.scaleTypes = [
+            { id: 'SCALE_OUT', name: this.translateService.instant('SCALEOUT') },
+            { id: 'SCALE_IN', name: this.translateService.instant('SCALEIN') }
+        ];
+        this.headers = new HttpHeaders({
+            'Content-Type': 'application/json',
+            Accept: 'application/json',
+            'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
+        });
+    }
+
+    /** Initialize Scaling Forms @public */
+    public initializeForm(): void {
+        this.scalingForm = this.formBuilder.group({
+            memberIndex: [null, [Validators.required]],
+            scalingname: [null, [Validators.required]],
+            scaleType: [null, [Validators.required]]
+        });
+    }
+
+    /** Get the member-vnf-index from NS Package -> vnf-profile @public */
+    public getmemberIndex(): void {
+        if (this.params.nsd.df.length > 0) {
+            const getconstituentVNFD: {}[] = [];
+            this.params.nsd.df.forEach((data: NSDF): void => {
+                data['vnf-profile'].forEach((vnfProfile: VNFPROFILE): void => {
+                    const assignMemberIndex: {} = {
+                        id: vnfProfile.id,
+                        name: vnfProfile['vnfd-id']
+                    };
+                    getconstituentVNFD.push(assignMemberIndex);
+                });
+            });
+            this.memberVNFIndex = getconstituentVNFD;
+        }
+    }
+
+    /** Get the scaling-group-descriptor name @public */
+    public getScalingGroupDescriptorName(vnfID: string): void {
+        this.selectedVNFID = vnfID;
+        this.scalingGroup = [];
+        this.getFormControl('scalingname').setValue(null);
+        const scalingGroupDescriptorName: SCALING[] = [];
+        if (!isNullOrUndefined(this.params.data)) {
+            console.log(this.params.data);
+            const vnfdPackageDetails: VNFD = this.params.data.filter((vnfdData: VNFD): boolean => vnfdData.id === vnfID)[0];
+            if (vnfdPackageDetails.df.length > 0) {
+                vnfdPackageDetails.df.forEach((df: DF): void => {
+                    if (!isNullOrUndefined(df['scaling-aspect']) && df['scaling-aspect'].length > 0) {
+                        df['scaling-aspect'].forEach((scalingAspect: SCALING): void => {
+                            scalingGroupDescriptorName.push(scalingAspect);
+                        });
+                    }
+                });
+                this.scalingGroup = scalingGroupDescriptorName;
+            }
+        }
+    }
+
+    /** If form is valid and call scaleInstances method to initialize scaling @public */
+    public manualScalingTrigger(): void {
+        this.submitted = true;
+        this.sharedService.cleanForm(this.scalingForm);
+        if (this.scalingForm.invalid) { return; } // Proceed, onces form is valid
+        const scalingPayload: object = {
+            scaleType: 'SCALE_VNF',
+            scaleVnfData:
+            {
+                scaleVnfType: this.scalingForm.value.scaleType,
+                scaleByStepData: {
+                    'scaling-group-descriptor': this.scalingForm.value.scalingname,
+                    'member-vnf-index': this.scalingForm.value.memberIndex
+                }
+            }
+        };
+        this.scaleInstances(scalingPayload);
+    }
+
+    /** Initialize the scaling @public */
+    public scaleInstances(scalingPayload: object): void {
+        this.isLoadingResults = true;
+        const apiURLHeader: APIURLHEADER = {
+            url: environment.NSDINSTANCES_URL + '/' + this.params.id + '/scale',
+            httpOptions: { headers: this.headers }
+        };
+        const modalData: MODALCLOSERESPONSEDATA = {
+            message: 'Done'
+        };
+        this.restService.postResource(apiURLHeader, scalingPayload).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.scalingForm.controls[controlName];
+    }
+}
index c57a06b..0c45011 100644 (file)
     "TYPEINFO": "Um einen neuen TYPW hinzuzufügen, geben Sie oben die Eingabe ein",
     "UPLOADCONFIGLABEL": "Bitte laden Sie eine Datei im .yaml- oder .yml-Format hoch",
     "NEWVERSIONTAG": "Hier ist die neue Version {{appVersion}} von OSM!",
+    "SCALEOUT": "Scale Out",
+    "SCALEIN": "Scale In",
+    "SCALING": "Manuelle Skalierung",
+    "SCALINGNOTFOUND": "scaling-aspect nicht in vnfd gefunden",
     "PAGE": {
         "DASHBOARD": {
             "DASHBOARD": "Instrumententafel",
index 1698772..62138c9 100644 (file)
     "TYPEINFO": "To add a new TYPE, Please enter input above",
     "UPLOADCONFIGLABEL": "Please upload file with .yaml or .yml format",
     "NEWVERSIONTAG": "Here is the new version {{appVersion}} of OSM!",
+    "SCALEOUT": "Scale Out",
+    "SCALEIN": "Scale In",
+    "SCALING": "Manual Scaling",
+    "SCALINGNOTFOUND": "scaling-aspect not found in vnfd",
     "PAGE": {
         "DASHBOARD": {
             "DASHBOARD": "Dashboard",
index e080ea8..729ec4c 100644 (file)
     "TYPEINFO": "Para agregar un nuevo TIPO, ingrese la entrada de arriba",
     "UPLOADCONFIGLABEL": "Cargue el archivo con formato .yaml o .yml",
     "NEWVERSIONTAG": "¡Aquí está la nueva versión {{appVersion}} de OSM!",
+    "SCALEOUT": "Desescalar",
+    "SCALEIN": "Escalar",
+    "SCALING": "Escalado manual",
+    "SCALINGNOTFOUND": "scaling-aspect no encontrado en vnfd",
     "PAGE": {
         "DASHBOARD": {
             "DASHBOARD": "Tablero",
index 24b5300..5af81aa 100644 (file)
     "TYPEINFO": "Para adicionar um novo TIPO, insira a entrada acima",
     "UPLOADCONFIGLABEL": "Faça o upload do arquivo no formato .yaml ou .yml",
     "NEWVERSIONTAG": "Aqui está a nova versão {{appVersion}} do OSM!",
+    "SCALEOUT": "Dimensionar",
+    "SCALEIN": "Escala em",
+    "SCALING": "Escalonamento Manual",
+    "SCALINGNOTFOUND": "scaling-aspect não encontrado no vnfd",
     "PAGE": {
         "DASHBOARD": {
             "DASHBOARD": "painel de controle",
index 7284bbc..2d1c9c3 100644 (file)
@@ -16,6 +16,8 @@
  Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
  */
 import { HttpHeaders } from '@angular/common/http';
+import { NSD } from 'NSInstanceModel';
+import { VNFD } from 'VNFDModel';
 
 /**
  * @file  Model for Commonly used information.
@@ -48,6 +50,7 @@ export enum CONFIGCONSTANT {
     operationalStateFirstStep = 'init',
     operationalStateSecondStep = 'running',
     operationalStateThirdStep = 'failed',
+    operationalStateFourthStep = 'scaling',
     configStateFirstStep = 'init',
     configStateSecondStep = 'configured',
     configStateThirdStep = 'failed',
@@ -108,6 +111,10 @@ export interface URLPARAMS {
     nsConfig?: object;
     projectID?: string;
     username?: string;
+    vnfID?: [];
+    nsID?: string;
+    nsd?: NSD;
+    data?: VNFD[];
 }
 /** Handle the Delete params */
 export interface DELETEPARAMS {
index 131af47..48e7387 100644 (file)
@@ -34,7 +34,6 @@ export interface NSData {
 /** Interface for the nscompose descriptors content */
 export interface NSDDetails {
     'connection-point': CONNECTIONPOINT[];
-    'constituent-vnfd': CONSTITUENTVNFD[];
     description: string;
     id: string;
     logo: string;
@@ -57,12 +56,6 @@ export interface CONNECTIONPOINT {
     'vld-id-ref': string;
 }
 
-/** Interface for the constituent-vnfd */
-export interface CONSTITUENTVNFD {
-    'member-vnf-index': number;
-    'vnfd-id-ref': string;
-}
-
 /** Interface for the vld */
 export interface VLD {
     id: string;
index 6bafcdd..ce44122 100644 (file)
@@ -19,7 +19,7 @@
  * @file  Model for NS Instance related information.
  */
 // tslint:disable: completed-docs
-import { CONSTITUENTVNFD, DF, VLD } from 'NSDModel';
+import { DF, VLD } from 'NSDModel';
 import { VNFDAdminDetails } from 'VNFDModel';
 
 /** Interface for NSInstanceDetails */
@@ -34,6 +34,7 @@ export interface NSInstanceDetails {
     'operational-status': string;
     'datacenter': string;
     nsd: NSD;
+    'nsd-id': string;
     name: string;
     'name-ref': string;
     id: string;
@@ -104,7 +105,6 @@ export interface NSD {
     version: string;
     _id: string;
     id: string;
-    'constituent-vnfd': CONSTITUENTVNFD[];
     vendor: string;
     vdur: string[];
     'connection-point': CONNECTIONPOINT[];
@@ -179,6 +179,29 @@ export interface NSDInstanceData {
     state?: string;
     memberIndex?: DF[];
     nsConfig?: object;
+    adminDetails?: object;
+    vnfID?: string[];
+    nsd?: NSD;
+    operationParams?: OPERATIONPARAMS;
+    'nsd-id': string;
+}
+
+/** Interface for the operationparams */
+export interface OPERATIONPARAMS{
+    scaleType?: string;
+    scaleVnfData?: SCALEVNFDATA;
+}
+
+/** Interface for the scaleVnfData */
+export interface SCALEVNFDATA{
+    scaleVnfType?: string;
+    scaleByStepData?: SCALEBYSTEPDATA;
+}
+
+/** Interface for the scaleByStepData */
+export interface SCALEBYSTEPDATA{
+    'scaling-group-descriptor'?: string;
+    'member-vnf-index'?: string;
 }
 
 /** Interface for the nsInfo */
index 4f76f7c..7029ace 100644 (file)
@@ -83,6 +83,7 @@ export interface DF {
     'instantiation-level'?: INSTANTIATIONLEVEL[];
     'vdu-profile'?: VDUPROFILE[];
     'vnf-configuration-id'?: string;
+    'scaling-aspect'?: SCALING[];
 }
 /** Interface for INSTANTIATIONLEVEL */
 export interface INSTANTIATIONLEVEL {
@@ -103,6 +104,31 @@ export interface VDUPROFILE {
     'vdu-configuration-id'?: string;
     'vdu-configuration'?: VDUCONFIG;
 }
+/** Interface for SCALING */
+export interface SCALING {
+    'aspect-delta-details'?: object;
+    id: string;
+    name?: string;
+    'max-scale-level'?: number;
+    'scaling-policy'?: SCALINGPOLICY[];
+}
+/** Interface for SCALINGPOLICY */
+export interface SCALINGPOLICY {
+    'cooldown-time': number;
+    name?: string;
+    'scaling-criteria': SCALINGCRITERIA[];
+    'scaling-type'?: string;
+    'threshold-time'?: number;
+}
+/** Interface for SCALINGCRITERIA */
+export interface SCALINGCRITERIA {
+    name?: string;
+    'scale-in-relational-operation': string;
+    'scale-in-threshold'?: string;
+    'scale-out-relational-operation'?: string;
+    'scale-out-threshold'?: string;
+    'vnf-monitoring-param-ref'?: string;
+}
 /** Interface for VDUCONFIG */
 export interface VDUCONFIG {
     id: string;
index 7bac1a3..4ca53c1 100644 (file)
             "OsmRepositoriesDetails":["src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent"],
             "OsmRepositoriesAction" : ["src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent"],
             "OsmRepoModel": ["src/models/OsmRepoModel"],
-            "OsmRepoCreateUpdate": ["src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent"]
+            "OsmRepoCreateUpdate": ["src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent"],
+            "ScalingComponent": ["src/app/utilities/scaling/ScalingComponent"]
         }
     }
 }
\ No newline at end of file