/** * 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; }
@Override public void close() { if (this.userSession == null) { return; } try { this.vimPort.logout(this.serviceContent.getSessionManager()); } catch (Exception e) { Throwable cause = e.getCause(); throw new BasicConnectionException( "failed to close properly: " + e.getMessage() + " : " + cause .getMessage(), cause); } finally { this.userSession = null; this.serviceContent = null; this.vimPort = null; this.pbmPort = null; this.pbmService = null; } }
public SessionManager getSessionManager() { return (SessionManager) createMO(getServiceContent().getSessionManager()); }
public Connection disconnect() { if (this.isConnected()) { try { vimPort.logout(serviceContent.getSessionManager()); } catch (Exception e) { Throwable cause = e.getCause(); throw new BasicConnectionException("Failed to disconnect properly: " + e.getMessage() + " : " + cause.getMessage(), cause); } finally { userSession = null; serviceContent = null; vimPort = null; vimService = null; } } return this; }
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); }
public String getGenericServiceTicket(String url) { SessionManagerHttpServiceRequestSpec spec = new SessionManagerHttpServiceRequestSpec(); spec.setMethod("httpPut"); spec.setUrl(url); String ticket = null; try { ticket = this.vimPort.acquireGenericServiceTicket(this.getServiceContent() .getSessionManager(), spec).getId(); } catch (Exception ex) { Throwable cause = (ex.getCause() != null) ? ex.getCause() : ex; throw new BasicConnectionException( "failed to fetch GenericServiceTicket: " + ex.getMessage() + " : " + cause.getMessage(), cause); } return ticket; }
UserSession userSession = vimPort.login(serviceContent.getSessionManager(), user, password, null); log.trace("Logged in successfully to vSphere host '{}'", server);
@SuppressWarnings("rawtypes") private void makeConnection(String url, String username, String password, boolean trustEveryone) throws RuntimeFaultFaultMsg, InvalidLocaleFaultMsg, InvalidLoginFaultMsg, KeyManagementException, NoSuchAlgorithmException { vimService = new VimService(); vimPort = vimService.getVimPort(); populateContextMap(url, username, password); if (Boolean.TRUE.equals(trustEveryone)) { DisableSecurity.trustEveryone(); } serviceContent = vimPort.retrieveServiceContent(this.getServiceInstanceReference()); userSession = vimPort.login(serviceContent.getSessionManager(), username, password, null); }
this.serviceContent.getSessionManager(), null); } finally { this.serviceContent.getSessionManager(), this.username, this.password,