VMware {code} Community
wodge
Enthusiast
Enthusiast

Listing vCenters existing in inventory

Hi,

We are using the Plugin Seed (v 0.9.7) - soon to upgrade to 0.9.8...

We would like to be able to list the uuids / names of vCenter instances that are available  to the webclient installation where the plugin is installed (these will be those connected in linked mode and so appearing within the inventory).

Could you please adivse if it is possible to do this within the Angular code? If not, would it be required to perform the funciton at the service layer, and how please (e.g. through the SDK)?

Thank you,

Warren

0 Kudos
2 Replies
laurentsd
VMware Employee
VMware Employee

The vCenter instances used for the current user are available in the UserSession JS objects.  See vSphereClientSdkTypes.ts, UserSession has an array of ServerInfo objects:

export interface WebPlatform {

   callActionsController(url: string, jsonData: string, targets?: string😞 void;
   closeDialog(): void;
   getClientType(): string;
   getClientVersion(): string;
   getString(bundleName: string, key: string, params: any😞 string;
   getRootPath(): string;
   getUserSession(): UserSession;
   openModalDialog(title, url, width, height, objectId): void;
   sendModelChangeEvent(objectId, opType): void;
   sendNavigationRequest(targetViewId, objectId): void;
   setDialogSize(width, height): void;
   setDialogTitle(title): void;
   setGlobalRefreshHandler(callback, document): void;
}

export class UserSession {

   userName: string;
   clientId: string;
   locale: string;
   serversInfo: ServerInfo[];
}

export class ServerInfo {

   serviceGuid: string;
   serviceUrl: string;
   sessionKey: string
;
}

0 Kudos
_vladi_
VMware Employee
VMware Employee

You can also have a look at the latest version of the GlobalView sample (vcView.js file) from the SDK Fling. It demonstrates a simple way to make a VC selector using pure JavaScript (you can do this easily with TypeScript using Laurent's info above).

0 Kudos