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/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);