I have the username/password/url to one VC in linked mode. How do I get all the VCs that are in linked mode?
Here is my code to retrieve the UserSession. I know it's possible if you get access to com.vmware.vise.UserSession but I'm not able to do so with com.vmware.vim25.UserSession.
public UserSession connServer(String vcenterIP, String username, String password) throws Exception {
String url = "" + vcenterIP + "/sdk/vimService";
try {
ManagedObjectReference managedObjRef = new ManagedObjectReference();
managedObjRef.setType("ServiceInstance");
managedObjRef.setValue("ServiceInstance");
VimService vimService = new VimService();
VimPortType vimPort = vimService.getVimPort();
Map<String, Object> ctxt = ((BindingProvider) vimPort).getRequestContext();
ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
ctxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
serviceContent = vimPort.retrieveServiceContent(managedObjRef);
if (serviceContent.getSessionManager() != null) {
currentSession = vimPort.login(serviceContent.getSessionManager(), username, password, null);
}
} catch (Exception e) {
System.out.println(e);
}
return currentSession;
}