Feature 11052: support for vms remote console for plugin vcenter
Change-Id: I328f4626dda94d9c4322c285b1e9216ed8f03673
Signed-off-by: Isabel Lloret <illoret@indra.es>
diff --git a/src/app/AppModule.ts b/src/app/AppModule.ts
index cd145c3..d8689af 100644
--- a/src/app/AppModule.ts
+++ b/src/app/AppModule.ts
@@ -73,6 +73,7 @@
import { ShowInfoComponent } from 'ShowInfoComponent';
import { SidebarComponent } from 'SidebarComponent';
import { StartStopRebuildComponent } from 'StartStopRebuildComponent';
+import { ShowVduConsoleComponent } from 'ShowVduConsoleComponent';
import { SwitchProjectComponent } from 'SwitchProjectComponent';
import { UsersActionComponent } from 'UsersActionComponent';
import { UserSettingsComponent } from 'UserSettingsComponent';
@@ -136,6 +137,7 @@
NsUpdateComponent,
WarningComponent,
StartStopRebuildComponent,
+ ShowVduConsoleComponent,
HealingComponent,
NSConfigTemplateActionComponent,
OkaPackagesActionComponent
diff --git a/src/app/instances/ns-instances/NSInstancesComponent.ts b/src/app/instances/ns-instances/NSInstancesComponent.ts
index 34719f3..065a56b 100644
--- a/src/app/instances/ns-instances/NSInstancesComponent.ts
+++ b/src/app/instances/ns-instances/NSInstancesComponent.ts
@@ -30,9 +30,11 @@
import { NSDInstanceData, NSInstanceDetails } from 'NSInstanceModel';
import { NSInstancesActionComponent } from 'NSInstancesActionComponent';
import { RestService } from 'RestService';
-import { Subscription } from 'rxjs';
+import { forkJoin, Subscription } from 'rxjs';
import { isNullOrUndefined } from 'SharedService';
import { SharedService } from 'SharedService';
+import { VimAccountDetails } from 'VimAccountModel';
+
/**
* Creating component
@@ -246,44 +248,64 @@
/** generateData initiate the ns-instance list @public */
public generateData(): void {
this.isLoadingResults = true;
- this.restService.getResource(environment.NSDINSTANCES_URL).subscribe((nsdInstancesData: NSInstanceDetails[]): void => {
- this.nsInstanceData = [];
- nsdInstancesData.forEach((nsdInstanceData: NSInstanceDetails): void => {
- const nsDataObj: NSDInstanceData = {
- name: nsdInstanceData.name,
- identifier: nsdInstanceData.id,
- NsdName: nsdInstanceData['nsd-name-ref'],
- OperationalStatus: nsdInstanceData['operational-status'],
- ConfigStatus: nsdInstanceData['config-status'],
- DetailedStatus: nsdInstanceData['detailed-status'],
- memberIndex: nsdInstanceData.nsd.df,
- nsConfig: nsdInstanceData.nsd['ns-configuration'],
- adminDetails: nsdInstanceData._admin,
- vnfID: nsdInstanceData['vnfd-id'],
- nsd: nsdInstanceData.nsd,
- 'nsd-id': nsdInstanceData['nsd-id'],
- vcaStatus: nsdInstanceData.vcaStatus,
- constituent: nsdInstanceData['constituent-vnfr-ref'],
- 'create-time': this.sharedService.convertEpochTime(Number(nsdInstanceData['create-time']))
- };
- this.nsInstanceData.push(nsDataObj);
- });
- if (this.nsInstanceData.length > 0) {
- this.checkDataClass = 'dataTables_present';
- } else {
- this.checkDataClass = 'dataTables_empty';
- }
- this.dataSource.load(this.nsInstanceData).then((data: {}): void => {
+ forkJoin([
+ this.restService.getResource(environment.VIMACCOUNTS_URL),
+ this.restService.getResource(environment.NSDINSTANCES_URL)
+ ]).subscribe({
+ next: ([vimAccounts, nsdInstancesData]: [VimAccountDetails[], NSInstanceDetails[]]) => {
+ // Transforms vimAccounts to a map (will be used to enrich ns instance data)
+ const vimsMap = this.transformVimListToMap(vimAccounts);
+
+ // Transform nsInstances to the format needed in the web
+ this.nsInstanceData = [];
+ nsdInstancesData.forEach((nsdInstanceData: NSInstanceDetails): void => {
+ const nsDataObj: NSDInstanceData = {
+ name: nsdInstanceData.name,
+ identifier: nsdInstanceData.id,
+ NsdName: nsdInstanceData['nsd-name-ref'],
+ OperationalStatus: nsdInstanceData['operational-status'],
+ ConfigStatus: nsdInstanceData['config-status'],
+ DetailedStatus: nsdInstanceData['detailed-status'],
+ memberIndex: nsdInstanceData.nsd.df,
+ nsConfig: nsdInstanceData.nsd['ns-configuration'],
+ adminDetails: nsdInstanceData._admin,
+ vnfID: nsdInstanceData['vnfd-id'],
+ nsd: nsdInstanceData.nsd,
+ 'nsd-id': nsdInstanceData['nsd-id'],
+ vcaStatus: nsdInstanceData.vcaStatus,
+ constituent: nsdInstanceData['constituent-vnfr-ref'],
+ 'create-time': this.sharedService.convertEpochTime(Number(nsdInstanceData['create-time'])),
+ vimType: vimsMap.get(nsdInstanceData['datacenter'])?.vim_type
+ };
+ this.nsInstanceData.push(nsDataObj);
+ });
+ if (this.nsInstanceData.length > 0) {
+ this.checkDataClass = 'dataTables_present';
+ } else {
+ this.checkDataClass = 'dataTables_empty';
+ }
+ this.dataSource.load(this.nsInstanceData).then((data: {}): void => {
+ this.isLoadingResults = false;
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
+ },
+ error: (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'get');
this.isLoadingResults = false;
- }).catch((): void => {
- // Catch Navigation Error
- });
- }, (error: ERRORDATA): void => {
- this.restService.handleError(error, 'get');
- this.isLoadingResults = false;
+ }
});
}
+ /** transforms vim list to map to be able to recover vim data fast by name */
+ private transformVimListToMap(vimList: VimAccountDetails[]): Map<string, VimAccountDetails> {
+ const vimMap = new Map<string, VimAccountDetails>();
+ vimList.forEach((vim) => {
+ vimMap.set(vim._id, vim);
+ });
+ return vimMap;
+ }
+
/** smart table listing manipulation @public */
public onChange(perPageValue: number): void {
this.dataSource.setPaging(1, perPageValue, true);
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
index c2f8a78..c19acc4 100644
--- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
+++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
@@ -49,6 +49,10 @@
[disabled]="operationalStatus === 'failed' || configStatus === 'failed'" ngbTooltip="{{'VMMIGRATION' | translate}}">
<i class="fas fa-angle-double-left"></i> {{'VMMIGRATION' | translate}}
</button>
+ <button *ngIf="showConsoleAction" type="button" class="btn btn-primary dropdown-item" (click)="openConsole()" placement="left"
+ data-container="body" ngbTooltip="{{'CONSOLE' | translate}}">
+ <i class="fas fa-desktop"></i> {{'CONSOLE' | translate}}
+ </button>
</div>
</div>
<div class="btn-group" placement="bottom-right" ngbDropdown display="dynamic" container="body">
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
index 8ae776f..2d2575e 100644
--- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
+++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.ts
@@ -36,6 +36,7 @@
import { ScalingComponent } from 'ScalingComponent';
import { SharedService, isNullOrUndefined } from 'SharedService';
import { ShowInfoComponent } from 'ShowInfoComponent';
+import { ShowVduConsoleComponent } from 'ShowVduConsoleComponent';
import { StartStopRebuildComponent } from 'StartStopRebuildComponent';
import { VmMigrationComponent } from 'VmMigrationComponent';
import { DF, VDU, VNFD } from 'VNFDModel';
@@ -89,6 +90,12 @@
/** Contains operational dashboard view @public */
public isShowOperationalDashboard: boolean = false;
+ /** Controls to show additional operations buttons */
+ public showConsoleAction: boolean = false;
+
+ /** Vim types for wich console operation button must be show */
+ private static readonly NS_CONSOLE_OPERATION_VIM_TYPES: string[] = ['vcenter'];
+
/** Instance of the modal service @private */
private modalService: NgbModal;
@@ -146,6 +153,15 @@
}
this.isShowOperationalDashboard = !isNullOrUndefined(this.value.vcaStatus) ?
Object.keys(this.value.vcaStatus).length === 0 && typeof this.value.vcaStatus === 'object' : true;
+ // Check if additional operations buttons must be showns
+ this.checkShowExtraActionsButtons();
+ }
+
+ /** Checks if the console option in the actions dropdown must be shown */
+ private checkShowExtraActionsButtons() {
+ if (NSInstancesActionComponent.NS_CONSOLE_OPERATION_VIM_TYPES.includes(this.value.vimType)) {
+ this.showConsoleAction = true;
+ }
}
/** Shows information using modalservice @public */
@@ -349,6 +365,21 @@
});
}
+ /** Open the show remote console pop-up @public */
+ public openConsole(): void {
+ const modalRef: NgbModalRef = this.modalService.open(ShowVduConsoleComponent, { backdrop: 'static' });
+ modalRef.componentInstance.params = {
+ id: this.instanceID
+ };
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
+ if (result) {
+ this.sharedService.callData();
+ }
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
+ }
+
/** Open the Healing pop-up @public */
public openHealing(): void {
// eslint-disable-next-line security/detect-non-literal-fs-filename
diff --git a/src/app/utilities/show-vdu-console/ShowVduConsoleComponent.html b/src/app/utilities/show-vdu-console/ShowVduConsoleComponent.html
new file mode 100644
index 0000000..613f3cc
--- /dev/null
+++ b/src/app/utilities/show-vdu-console/ShowVduConsoleComponent.html
@@ -0,0 +1,71 @@
+<!--
+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: Isabel Lloret (illoret@minsait.com)
+-->
+<div class="modal-header">
+ <h4 class="modal-title" id="modal-basic-title"> {{'CONSOLE' | 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]="consoleForm" (ngSubmit)="prepareGetConsole()" autocomplete="off">
+ <div class="modal-body">
+ <div class="form-group row">
+ <label class="col-sm-12 col-form-label mandatory-label"
+ [ngClass]="{'text-danger': consoleForm.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="memberVnfIndex" [clearable]="false"
+ placeholder="{{'SELECTMEMBERVNFINDEX' | translate}}" [items]="memberTypes" bindLabel="id"
+ bindValue="id" [ngClass]="{ 'is-invalid': submitted && f.memberVnfIndex.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="vdu-id"> {{'VDUID' | translate}} *</label>
+ </div>
+ <div class="col-sm-6">
+ <ng-select formControlName="vduId" [clearable]="false" (change)="getCountIndex($event.VDU)"
+ placeholder="{{'SELECT' | translate}} {{'VDUID' | translate}}" [items]="vduId" bindLabel="VDU"
+ bindValue="VDU" [ngClass]="{ 'is-invalid': submitted && f.vduId.errors }">
+ </ng-select>
+ </div>
+ </div>
+ <div class="form-group row">
+ <div class="col-sm-6">
+ <label for="count-index"> {{'COUNTINDEX' | translate}} *</label>
+ </div>
+ <div class="col-sm-6">
+ <ng-select formControlName="countIndex" [clearable]="false"
+ placeholder="{{'SELECT' | translate}} {{'COUNTINDEX' | translate}}" [items]="countIndex"
+ bindLabel="count-index" bindValue="count-index"
+ [ngClass]="{ 'is-invalid': submitted && f.countIndex.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/show-vdu-console/ShowVduConsoleComponent.scss b/src/app/utilities/show-vdu-console/ShowVduConsoleComponent.scss
new file mode 100644
index 0000000..11a6e59
--- /dev/null
+++ b/src/app/utilities/show-vdu-console/ShowVduConsoleComponent.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: Isabel Lloret (illoret@minsait.com)
+*/
\ No newline at end of file
diff --git a/src/app/utilities/show-vdu-console/ShowVduConsoleComponent.ts b/src/app/utilities/show-vdu-console/ShowVduConsoleComponent.ts
new file mode 100644
index 0000000..47fc2ad
--- /dev/null
+++ b/src/app/utilities/show-vdu-console/ShowVduConsoleComponent.ts
@@ -0,0 +1,340 @@
+/*
+ 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: I.Lloret <illoret@minsait.com>
+*/
+/**
+ * @file ShowVduConsoleComponent 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 { NotifierService } from 'angular-notifier';
+import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, URLPARAMS } from 'CommonModel';
+import { environment } from 'environment';
+import { ShowVduConsole, OperateVnfResult } from 'NSInstanceModel';
+import { RestService } from 'RestService';
+import { SharedService, isNullOrUndefined } from 'SharedService';
+import { DF, VNFD } from 'VNFDModel';
+import { InstanceData, VDUR, VNFInstanceDetails } from 'VNFInstanceModel';
+
+/**
+ * Creating component
+ * @Component takes ShowVduConsoleComponent.html as template url
+ */
+@Component({
+ selector: 'app-show-vdu-console',
+ templateUrl: './ShowVduConsoleComponent.html',
+ styleUrls: ['./ShowVduConsoleComponent.scss']
+})
+export class ShowVduConsoleComponent 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 consoleForm: 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 */
+ /** TODO - show remove this probably */
+ 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;
+ /** Contains vduId @public */
+ public vduId: {};
+ /** Items for countIndex @public */
+ public countIndex: {}[];
+ /** 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;
+ /** Notifier service to popup notification @private */
+ private notifierService: NotifierService;
+ /** Contains tranlsate instance @private */
+ private translateService: TranslateService;
+ /** Controls the header form @private */
+ private headers: HttpHeaders;
+ private consoleRequestStartTime: number;
+ /** 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.notifierService = this.injector.get(NotifierService);
+ this.translateService = this.injector.get(TranslateService);
+ 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.consoleForm.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.consoleForm = this.formBuilder.group({
+ memberVnfIndex: [null, [Validators.required]],
+ vduId: [null, [Validators.required]],
+ countIndex: [null, [Validators.required]]
+ });
+ }
+
+ /** Getting MemberVnfIndex using VNFInstances API @public */
+ public getMemberVnfIndex(): void {
+ this.isLoadingResults = true;
+ const vnfInstanceData: {}[] = [];
+ this.restService.getResource(environment.VNFINSTANCES_URL).subscribe((vnfInstancesData: VNFInstanceDetails[]): void => {
+ vnfInstancesData.forEach((vnfData: VNFInstanceDetails): void => {
+ const vnfdRef: string = 'vnfd-ref';
+ const memberIndex: string = 'member-vnf-index-ref';
+ const nsrId: string = 'nsr-id-ref';
+ const vnfId: string = 'vnfd-id';
+ const vnfDataObj: {} =
+ {
+ // eslint-disable-next-line security/detect-object-injection
+ VNFD: vnfData[vnfdRef],
+ 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],
+ // eslint-disable-next-line security/detect-object-injection
+ VNFID: vnfData[vnfId]
+ };
+ 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 {
+ const vnfInstanceData: {}[] = [];
+ 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';
+ // eslint-disable-next-line security/detect-object-injection
+ if (vnfInstanceDetail[VDU] !== undefined) {
+ // eslint-disable-next-line security/detect-object-injection
+ vnfInstanceDetail[VDU].forEach((vdu: VDUR): void => {
+ const vnfInstanceDataObj: {} =
+ {
+ 'count-index': vdu['count-index'],
+ VDU: vdu['vdu-id-ref']
+ };
+ vnfInstanceData.push(vnfInstanceDataObj);
+ });
+ this.vdu = vnfInstanceData;
+ const vduName: string = 'VDU';
+ this.vduId = this.vdu.filter((vdu: {}, index: number, self: {}[]): {} =>
+ index === self.findIndex((t: {}): {} => (
+ // eslint-disable-next-line security/detect-object-injection
+ t[vduName] === vdu[vduName]
+ ))
+ );
+ }
+ this.checkDay12Operation(this.selectedvnfId);
+ }, (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);
+ }
+
+ /** 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 and sends a request to get console */
+ public prepareGetConsole(): void {
+ this.submitted = true;
+ this.sharedService.cleanForm(this.consoleForm);
+ if (this.consoleForm.invalid) { return; } // Proceed, onces form is valid
+ const prepareConsolePayload: ShowVduConsole = {
+ updateType: 'OPERATE_VNF',
+ operateVnfData: {
+ vnfInstanceId: this.instanceId,
+ changeStateTo: 'console',
+ additionalParam: {
+ 'run-day1': false,
+ vdu_id: this.consoleForm.value.vduId,
+ 'count-index': this.consoleForm.value.countIndex
+ }
+ }
+ };
+ this.startGetConsole(prepareConsolePayload);
+ }
+
+ /** Initialize get console operation @public */
+ public startGetConsole(prepareConsolePayload: object): void {
+ this.message = 'LAUNCHINGCONSOLE';
+ this.consoleRequestStartTime = Date.now();
+ 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, prepareConsolePayload).subscribe((result: OperateVnfResult): void => {
+ // Start waiting for the operation to complete
+ this.waitOperationCompleted(result.id);
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'post');
+ this.isLoadingResults = false;
+ });
+ }
+
+ private waitOperationCompleted(operationId: string): void {
+ let elapsedTime = 0;
+ const interval = 3000; // 3 seconds interval between status checks
+ const maxWaitTime = 2 * 60 * 1000; // 2 minutes in milliseconds
+
+ // Set interval to periodically check if the operation is completed
+ const checkInterval = setInterval(() => {
+ if (elapsedTime >= maxWaitTime) {
+ clearInterval(checkInterval); // Stop polling after 2 minutes
+ this.notifierService.notify('error', this.translateService.instant('OPERATIONFAILED'));
+ this.isLoadingResults = false;
+ return;
+ }
+
+ this.getOperationStatus(operationId).subscribe((operationData: any) => {
+ if (operationData && operationData.operationState === 'COMPLETED') {
+ clearInterval(checkInterval); // Stop polling when operation is completed
+ elapsedTime = (Date.now() - this.consoleRequestStartTime);
+ this.openVmrcConsole(operationData.operationResultData.url);
+ // Close the modal window now
+ const modalData: MODALCLOSERESPONSEDATA = {
+ message: 'Done'
+ };
+ this.activeModal.close(modalData);
+ this.router.navigate(['/instances/ns/']).catch((): void => {
+ // Catch Navigation Error
+ });
+ } else if (operationData && operationData.operationState === 'FAILED') {
+ clearInterval(checkInterval); // Stop polling on error
+ this.notifierService.notify('error', this.translateService.instant('OPERATIONFAILED'));
+ this.isLoadingResults = false;
+ }
+ }, (error: ERRORDATA) => {
+ clearInterval(checkInterval); // Stop polling on error
+ this.restService.handleError(error, 'post');
+ this.isLoadingResults = false;
+ });
+ elapsedTime += interval;
+ }, interval);
+ }
+
+ /** obtain the status of the getconsole operation */
+ private getOperationStatus(operationId: string) {
+ const operationQueryUrl: string = environment.NSHISTORYOPERATIONS_URL + '/' + operationId;
+ // Make GET request to check operation status
+ return this.restService.getResource(operationQueryUrl);
+ }
+
+ private openVmrcConsole(vmrcUrl) {
+ const link = document.createElement('a');
+ link.href = vmrcUrl;
+ link.style.display = 'none';
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ }
+
+ /** Used to get the AbstractControl of controlName passed @private */
+ private getFormControl(controlName: string): AbstractControl {
+ // eslint-disable-next-line security/detect-object-injection
+ return this.consoleForm.controls[controlName];
+ }
+}
diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json
index c53e157..ac668eb 100644
--- a/src/assets/i18n/de.json
+++ b/src/assets/i18n/de.json
@@ -83,6 +83,9 @@
"RECENTLY": "Vor kurzem",
"TOPOLOGY": "Topologie",
"PLEASEWAIT": "Warten Sie mal",
+ "LAUNCHINGCONSOLE": "Konsole wird gestartet, bitte warten",
+ "OPERATIONFAILED": "Operation fehlgeschlagen",
+ "CONSOLE": "Console",
"RESOURCEORCHESTRATOR": "Ressource Orchestrator",
"VIEW": "Aussicht",
"DROP": "Fallen",
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index 19be970..427561d 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -83,6 +83,9 @@
"RECENTLY": "Recently",
"TOPOLOGY": "Topology",
"PLEASEWAIT": "Please Wait",
+ "LAUNCHINGCONSOLE": "Launching console, please wait",
+ "OPERATIONFAILED": "Operation failed",
+ "CONSOLE": "Console",
"RESOURCEORCHESTRATOR": "Resource Orchestrator",
"VIEW": "View",
"DROP": "Drop",
diff --git a/src/assets/i18n/es.json b/src/assets/i18n/es.json
index 01b7a99..c5a9959 100644
--- a/src/assets/i18n/es.json
+++ b/src/assets/i18n/es.json
@@ -83,6 +83,9 @@
"RECENTLY": "Recientemente",
"TOPOLOGY": "Topología",
"PLEASEWAIT": "Por favor, espere",
+ "LAUNCHINGCONSOLE": "Lanzando consola, por favor espere",
+ "OPERATIONFAILED": "Error en la operacion",
+ "CONSOLE": "Consola",
"RESOURCEORCHESTRATOR": "Orquestador de recursos",
"VIEW": "Ver",
"DROP": "soltar",
diff --git a/src/assets/i18n/pt.json b/src/assets/i18n/pt.json
index f96300d..538661a 100644
--- a/src/assets/i18n/pt.json
+++ b/src/assets/i18n/pt.json
@@ -83,6 +83,9 @@
"RECENTLY": "Recentemente",
"TOPOLOGY": "Topologia",
"PLEASEWAIT": "Por favor, espere",
+ "LAUNCHINGCONSOLE": "Iniciando o console, por favor aguarde",
+ "OPERATIONFAILED": "A operação falhou",
+ "CONSOLE": "Console",
"RESOURCEORCHESTRATOR": "Orquestrador de Recursos",
"VIEW": "Visão",
"DROP": "Solta",
diff --git a/src/models/CommonModel.ts b/src/models/CommonModel.ts
index 8595e4f..001d970 100644
--- a/src/models/CommonModel.ts
+++ b/src/models/CommonModel.ts
@@ -376,3 +376,4 @@
unlock?: boolean;
renew?: boolean;
}
+
diff --git a/src/models/NSInstanceModel.ts b/src/models/NSInstanceModel.ts
index 569e1ac..3604a27 100644
--- a/src/models/NSInstanceModel.ts
+++ b/src/models/NSInstanceModel.ts
@@ -199,6 +199,12 @@
operateVnfData: OPERATEVNFDATA;
}
+/** Interface for Show Vdu Console */
+export interface ShowVduConsole {
+ updateType: string;
+ operateVnfData: OPERATEVNFDATA;
+}
+
/** Interface for operateVnfData in Start, Stop and Rebuild */
export interface OPERATEVNFDATA {
additionalParam: ADDITIONALPARAMS;
@@ -213,6 +219,12 @@
'count-index': string;
}
+/** Interface for the result of an operate vnf operation */
+export interface OperateVnfResult {
+ id: string,
+ nsName: string
+}
+
/** Interface for VerticalScaling */
export interface VerticalScaling {
lcmOperationType: string;
@@ -277,6 +289,7 @@
'nsd-id': string;
constituent: string[];
'create-time'?: string;
+ vimType?: string;
}
/** Interface for the operationparams */