VMware {code} Community
ngenereux
Contributor
Contributor

sms and pbm session cloning in remote plugins

In our current local plugin, we use the vim25.jar library for most integrations. However, we also use sms.jar and pbm.jar available from the VMware vSphere Management SDK for some additional features. In the local plugin case, we are able to create sessions for these libraries using the session cookie available from the ServerInfo object retrieved from the UserSession that is part of the vsphere-client-lib's UserSessionService interface. However, in the remote plugin architecture it does not appear that we have access to the session cookie through similar paths. Additionally, the SmsPortType and PbmPortType classes do not have the cloneSession method available on VimPortType.

What is the correct way to create SmsPortType and PbmPortType objects in the remote plugin architecture which share the user's session the same way the VimPortType object in the sdk sample does?

Reply
0 Kudos
3 Replies
ngenereux
Contributor
Contributor

I had some time to dig into this over the last few days, and I can answer my own question with proof of concept. I wanted to post my code with the results here, but I've spent the last half hour fighting with the forum submit button and an "Access Denied" error which I'm pretty sure is happening because of the code I'm trying to include. Instead I'll just outline the solution.

First, the remote client SDK has the SessionServiceImpl class which helps manage sessions. It includes a line which calls vimPort.cloneSession. As mentioned above, SmsPortType and PbmPortType don't have this method, but this is where we get the session cookie we need.

Second, the vSphere Management SDK has the SmServiceConnection which contains an example of creating an SmsPortType using a session cookie obtained from a vimPort.login call. vimPort.login is called which gets the cookie, readSessionCookieFromHeaders extracts the cookie from the vimport object, then initSmsPort configures an SmsPortType with that cookie. This code works for both the SmsPortType and PbmPortType objects. I had to make a couple of modifications to properly set the SSL Socket Factory and cleanup the way the cookie is set, but in general the approach works fine.

Reply
0 Kudos
amarinov
VMware Employee
VMware Employee

Hi ngenereux,

Thank you for sharing the solution as I guess that other people have/might hit the same issue .

Thanks,
Aleksandar

Reply
0 Kudos
amarinov
VMware Employee
VMware Employee

Hi ngenereuxm,

If possible can you please share your sample code @ https://code.vmware.com/samples.

Thanks,
Aleksandar

Reply
0 Kudos