public ViConnection(String url, String username, char[] password, ExecutorService executor) throws MalformedURLException, RuntimeFaultFaultMsg, InvalidLocaleFaultMsg, InvalidLoginFaultMsg { proxy = ConnectionManager.getConnection(url, executor); serviceInstance = ConnectionManager.getServiceInstance(); serviceContent = proxy.retrieveServiceContent(serviceInstance); sessionManager = serviceContent.getSessionManager(); session = proxy.login(sessionManager, username, new String(password), null); }
/** * Disconnects the user session. * * @throws RuntimeFaultFaultMsg * * @throws Exception */ public void disconnect() throws RuntimeFaultFaultMsg { if (connected) { log.trace("Logging out from vSphere host '{}'", server); vimPort.logout(serviceContent.getSessionManager()); log.trace("Logged out successfully from vSphere host '{}'", server); } connected = false; }
/** @deprecated as of SDK4.1 */ public ObjectContent[] retrieveProperties(PropertyFilterSpec[] specSet) throws InvalidProperty, RuntimeFault, RemoteException { return getVimService().retrieveProperties(getMOR(), specSet); }
public ServiceInstance(URL url, String username, String password, boolean ignoreCert, String namespace) throws RemoteException, MalformedURLException { if(url == null || username==null) { throw new NullPointerException("None of url, username can be null."); } setMOR(SERVICE_INSTANCE_MOR); VimPortType vimService = new VimPortType(url.toString(), ignoreCert); vimService.getWsc().setVimNameSpace(namespace); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); vimService.getWsc().setSoapActionOnApiVersion(serviceContent.getAbout().getApiVersion()); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); //with new SOAP_ACTION setServerConnection(new ServerConnection(url, vimService, this)); UserSession userSession = getSessionManager().login(username, password, null); getServerConnection().setUserSession(userSession); }
ServiceContent serviceContent = vimPort.retrieveServiceContent(serviceInstance); ManagedObjectReference propertyCollectorReference = serviceContent.getPropertyCollector(); RetrieveOptions propertyObjectRetrieveOptions = new RetrieveOptions(); List<ObjectContent> objectContentList = new ArrayList<>(); RetrieveResult results = vimPort.retrievePropertiesEx(propertyCollectorReference, propertyFilterSpecList, propertyObjectRetrieveOptions); results = vimPort.continueRetrievePropertiesEx(propertyCollectorReference, token); token = null; if (results != null) {
updateBindingProvider(getBindingsProvider(), this.uri.toString()); this.serviceContent = this.vimPort .retrieveServiceContent(this.getServiceInstanceReference()); this.userSession = this.vimPort.loginByToken( this.serviceContent.getSessionManager(), null); updateBindingProvider(getBindingsProvider(), this.uri.toString()); this.serviceContent = this.vimPort .retrieveServiceContent(this.getServiceInstanceReference()); this.userSession = this.vimPort.login( this.serviceContent.getSessionManager(), this.username,
ManagedObjectReference filterSpecRef = vimPort.createFilter(serviceContent.getPropertyCollector(), spec, true); updateset = vimPort.waitForUpdatesEx(serviceContent.getPropertyCollector(), version, new WaitOptions()); vimPort.destroyPropertyFilter(filterSpecRef); } catch (RuntimeFaultFaultMsg e) { throw new RuntimeException(e.getMessage());
RetrieveResult results = this.vimPort.retrievePropertiesEx( propertyCollector, Arrays.asList(propertyFilterSpecs), this.vimPort.continueRetrievePropertiesEx(propertyCollector, token) : null;
/** * @return the current session string in format like: * vmware_soap_session="B3240D15-34DF-4BB8-B902-A844FDF42E85" */ public String getSessionStr() { WSClient wsc = vimService.getWsc(); return wsc.getCookie(); }
private ServiceContent retrieveServiceContent() throws RuntimeFault, RemoteException { return getVimService().retrieveServiceContent(getMOR()); }
public UserSession login(String userName, String password, String locale) throws InvalidLogin, InvalidLocale, RuntimeFault, RemoteException { return getVimService().login(getMOR(), userName, password, locale); }
private RetrieveResult containerViewByType(final RetrieveOptions retrieveOptions, final PropertyFilterSpec... propertyFilterSpecs) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg { return vimPort.retrievePropertiesEx(serviceContent.getPropertyCollector(), Arrays.asList(propertyFilterSpecs), retrieveOptions); }
private Map<String, ManagedObjectReference> toMap(RetrieveResult result) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg { final Map<String, ManagedObjectReference> tgtMoref = new HashMap<>(); String token = populate(result, tgtMoref); while (token != null && !token.isEmpty()) { // fetch results based on new token result = vimPort.continueRetrievePropertiesEx(serviceContent.getPropertyCollector(), token); token = populate(result, tgtMoref); } return tgtMoref; }
public ContainerView createContainerView(ManagedEntity container, String[] type, boolean recursive) throws RuntimeFault, RemoteException { if(container==null) { throw new IllegalArgumentException("container must not be null."); } return new ContainerView(getServerConnection(), getVimService().createContainerView(getMOR(), container.getMOR(), type, recursive)); }
String ticket = oldsi.getSessionManager().acquireCloneTicket(); VimPortType vimService = new VimPortType(oldsc.getUrl().toString(), ignoreCert); vimService.getWsc().setVimNameSpace(oldsc.getVimService().getWsc().getVimNameSpace()); vimService.getWsc().setSoapActionOnApiVersion(oldsi.getAboutInfo().getApiVersion());
public void destroyPropertyFilter() throws RuntimeFault, RemoteException { getVimService().destroyPropertyFilter(getMOR()); } }
public PropertyFilter createFilter(PropertyFilterSpec spec, boolean partialUpdates) throws InvalidProperty, RuntimeFault, RemoteException { ManagedObjectReference mor = getVimService().createFilter(getMOR(), spec, partialUpdates); return new PropertyFilter(getServerConnection(), mor); }
public ServiceInstance(URL url, String sessionStr, boolean ignoreCert, String namespace) throws RemoteException, MalformedURLException { if(url == null || sessionStr ==null) { throw new NullPointerException("None of url, session string can be null."); } setMOR(SERVICE_INSTANCE_MOR); VimPortType vimService = new VimPortType(url.toString(), ignoreCert); WSClient wsc = vimService.getWsc(); wsc.setCookie(sessionStr); wsc.setVimNameSpace(namespace); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); wsc.setSoapActionOnApiVersion(serviceContent.getAbout().getApiVersion()); setServerConnection(new ServerConnection(url, vimService, this)); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); //with new SOAP_ACTION UserSession userSession = (UserSession) getSessionManager().getCurrentProperty("currentSession"); getServerConnection().setUserSession(userSession); }
filterSpecRef = vimPort.createFilter(serviceContent.getPropertyCollector(), spec, true); updateset = vimPort.waitForUpdatesEx(serviceContent.getPropertyCollector(), version, waitOptions); if (updateset == null || updateset.getFilterSet() == null) { vimPort.destroyPropertyFilter(filterSpecRef); } catch (RuntimeFaultFaultMsg e) { e.printStackTrace();
this.vimPort.retrievePropertiesEx(this.serviceContent.getPropertyCollector(), propertyFilterSpecs, new RetrieveOptions()); while (token != null && !token.isEmpty()) { rslts = this.vimPort.continueRetrievePropertiesEx( this.serviceContent.getPropertyCollector(), token);