VMware {code} Community
kaustubh_aphale
Contributor
Contributor

Is it possible to get serverInfo from REST backend using vim25 jar?

 
Reply
0 Kudos
5 Replies
Plam_Dimitrov
VMware Employee
VMware Employee

Hello,

Can you add some more details on what you need to achieve. If this is about getting the ServerInfos of a vCenter extension, then yes, this is possible via the ExtensionManager APIs from vim25.

Regards,

Plam

Reply
0 Kudos
kaustubh_aphale
Contributor
Contributor

I want to fetch the vm details from VC from my REST backend in my remote plugin. To fetch these vm details, currently UI calls serverInfo URL and passes the sessionCookie to backend, which is then used to call VCenter API. However, I want to run a batch job in my backend and this sessionCookie will expire after a given interval of time. Hence I was checking if we have any facility to get this sessionCookie independently from backend. If yes, what details of the user would be required?

Reply
0 Kudos
Plam_Dimitrov
VMware Employee
VMware Employee

An arbitrary endpoint, e.g. "/my-endpoint", on the remote plugin backend may be reached by using the JS getProxiedPluginServerOrigin() and appending the path you need, so in this case htmlClientSdk.getProxiedPluginServerOrigin() + "/my-endpoint".

You mention that you pass a "sessionCookie" to this URL- how do you get this session cookie?

The intended way, as shown in the remote plugin sample, is to pass the plugin session ID (PSID) (obtained via htmlClientSdk.app.getSessionInfo()) to the plugin backend and exchange it for a session clone ticket via the Remote Plugin REST APIs. Afterwards, the ticket may be used to clone the VC session which will stay alive for as long as the session is in use (which will be a long time, considering you want to do some periodic operation). Even if the PSID expires, the VC session will stay intact. For remote plugins, there is no other way to obtain a VC session besides using the PSID to get a clone ticket.

Reply
0 Kudos
rajagopalans
Contributor
Contributor

Hello

Is it possible to make other REST API calls from the plugin backend?

I am able to make a REST call to clone the session, with the PSID , but any other REST call (like say https://developer.vmware.com/apis/vsphere-automation/v7.0U1/vcenter/rest/vcenter/network/get/#reques... ) fails with a 404.

For reference, I am on vSphere 6.7

Reply
0 Kudos
Denis_Chorbadzh
VMware Employee
VMware Employee

Hi,

 

Currently, it is not possible to call vCenter Server's REST APIs directly from the plugin's backend by using the cloned session.

 

Best Regards,

Denis

Reply
0 Kudos