本文整理汇总了Java中com.xensource.xenapi.Session.logout方法的典型用法代码示例。如果您正苦于以下问题:Java Session.logout方法的具体用法?Java Session.logout怎么用?Java Session.logout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.xensource.xenapi.Session
的用法示例。
在下文中一共展示了Session.logout方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: existsNFSStore
import com.xensource.xenapi.Session; //导入方法依赖的package包/类
public boolean existsNFSStore(String name,String host, String address, String path) throws Exception {
if(address == null || path == null || address.isEmpty() || path.isEmpty()) {
return false;
}
HostnameVerifier _hnv = new HTTPSHostnameVerifier();
HttpsURLConnection.setDefaultHostnameVerifier(_hnv);
Connection _connection = new Connection(new URL(this._url));
Session.loginWithPassword(_connection, this._user, this._password, APIVersion.latest().toString());
try {
Map<SR, SR.Record> _srs = SR.getAllRecords(_connection);
for(SR _sr : _srs.keySet()) {
if(name.equals(_sr.getNameLabel(_connection))) {
return true;
}
}
} catch(Exception _ex) {
System.out.println("HypervisorManagerXen::existsNFSStore:error - " + _ex.getMessage());
} finally {
Session.logout(_connection);
}
return false;
}
示例2: getStoreNames
import com.xensource.xenapi.Session; //导入方法依赖的package包/类
public List<String> getStoreNames() throws Exception {
List<String> _stores = new ArrayList<String>();
HostnameVerifier _hnv = new HTTPSHostnameVerifier();
HttpsURLConnection.setDefaultHostnameVerifier(_hnv);
Connection _connection = new Connection(new URL(this._url));
Session.loginWithPassword(_connection, this._user, this._password, APIVersion.latest().toString());
try {
for(SR _sr : SR.getAllRecords(_connection).keySet()) {
_stores.add(_sr.getNameLabel(_connection));
}
} catch(Exception _ex) {
throw new Exception("hypervisor error - " + _ex.getMessage());
} finally {
Session.logout(_connection);
}
return _stores;
}
示例3: getStores
import com.xensource.xenapi.Session; //导入方法依赖的package包/类
public List<Map<String, String>> getStores() throws Exception {
List<Map<String, String>> _stores = new ArrayList<Map<String, String>>();
HostnameVerifier _hnv = new HTTPSHostnameVerifier();
HttpsURLConnection.setDefaultHostnameVerifier(_hnv);
Connection _connection = new Connection(new URL(this._url));
Session.loginWithPassword(_connection, this._user, this._password, APIVersion.latest().toString());
try {
for(SR _sr : SR.getAllRecords(_connection).keySet()) {
Map<String,String> _store = new HashMap<String, String>();
_store.put("name", _sr.getNameLabel(_connection));
_store.put("free", String.valueOf(_sr.getPhysicalSize(_connection) - _sr.getPhysicalUtilisation(_connection)));
_store.put("directory-based", "");
_store.put("path", "");
_store.put("mode", "");
_stores.add(_store);
}
} catch(Exception _ex) {
throw new Exception("hypervisor error - " + _ex.getMessage());
} finally {
Session.logout(_connection);
}
return _stores;
}
示例4: getVirtualMachineNames
import com.xensource.xenapi.Session; //导入方法依赖的package包/类
public List<String> getVirtualMachineNames() throws Exception {
List<String> _vms = new ArrayList<String>();
HostnameVerifier _hnv = new HTTPSHostnameVerifier();
HttpsURLConnection.setDefaultHostnameVerifier(_hnv);
Connection _connection = new Connection(new URL(this._url));
Session.loginWithPassword(_connection, this._user, this._password, APIVersion.latest().toString());
try {
Map<VM, VM.Record> _vm_records = VM.getAllRecords(_connection);
for(VM _vm_record : _vm_records.keySet()) {
if(_vm_record.getIsATemplate(_connection) || _vm_record.getNameLabel(_connection).startsWith("wbsairback-")) {
continue;
}
_vms.add(_vm_record.getNameLabel(_connection));
}
} catch(Exception _ex) {
throw new Exception("hypervisor error - " + _ex.getMessage());
} finally {
Session.logout(_connection);
}
return _vms;
}
示例5: HypervisorManagerXen
import com.xensource.xenapi.Session; //导入方法依赖的package包/类
public HypervisorManagerXen(String address, String user, String password) throws Exception {
if(!NetworkManager.isValidAddress(address)) {
throw new Exception("invalid network address");
}
StringBuilder _sb = new StringBuilder();
_sb.append("https://");
_sb.append(address);
this._url = _sb.toString();
this._user = user;
this._password = password;
try {
logger.debug("Connecting to xen at {} with user:{}", new Object[]{_url, _user});
HostnameVerifier _hnv = new HTTPSHostnameVerifier();
HttpsURLConnection.setDefaultHostnameVerifier(_hnv);
KeyStore _store = KeyStore.getInstance("JKS");
TrustManagerFactory _tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
_tmf.init(_store);
X509TrustManager x509Manager = (X509TrustManager) _tmf.getTrustManagers()[0];
HTTPSTrustManager _httpstm = new HTTPSTrustManager(x509Manager);
SSLContext _ctx = SSLContext.getInstance("TLS");
_ctx.init(null, new TrustManager[] { _httpstm }, null);
HttpsURLConnection.setDefaultSSLSocketFactory(_ctx.getSocketFactory());
logger.debug("Environment prepared to connect. Conecting...");
Connection _connection = new Connection(new URL(this._url));
logger.debug("Conected. Trying to log on ...");
Session.loginWithPassword(_connection, this._user, this._password, APIVersion.latest().toString());
logger.debug("Logued. So logging out ...");
Session.logout(_connection);
logger.debug("Logged out successfully");
} catch (Exception ex) {
logger.error("Error connecting with XEN server. Ex: {}", ex.getMessage());
throw new Exception ("Error connecting with XEN server. Ex: "+ex.getMessage());
}
}
示例6: getHostForVirtualMachine
import com.xensource.xenapi.Session; //导入方法依赖的package包/类
public String getHostForVirtualMachine(String vmName) throws Exception {
if(vmName == null || vmName.isEmpty()) {
throw new Exception("invalid virtual machine name");
}
HostnameVerifier _hnv = new HTTPSHostnameVerifier();
HttpsURLConnection.setDefaultHostnameVerifier(_hnv);
Connection _connection = new Connection(new URL(this._url));
Session.loginWithPassword(_connection, this._user, this._password, APIVersion.latest().toString());
try {
VM _vm = new ArrayList<VM>(VM.getByNameLabel(_connection, vmName)).get(0);
if(_vm == null) {
throw new Exception("virtual machine not found");
} else {
return vmName;
}
// Host _host = _vm.getResidentOn(_connection);
// if(_host == null) {
// return null;
// }
// return _host.getNameLabel(_connection);
} catch(Exception _ex) {
throw new Exception("hypervisor error - " + _ex.getMessage());
} finally {
Session.logout(_connection);
}
}
示例7: getVirtualMachines
import com.xensource.xenapi.Session; //导入方法依赖的package包/类
public List<Map<String, String>> getVirtualMachines(String storage) throws Exception {
List<Map<String, String>> _vms = new ArrayList<Map<String, String>>();
HostnameVerifier _hnv = new HTTPSHostnameVerifier();
HttpsURLConnection.setDefaultHostnameVerifier(_hnv);
Connection _connection = new Connection(new URL(this._url));
Session.loginWithPassword(_connection, this._user, this._password, APIVersion.latest().toString());
try {
for(SR _sr : SR.getByNameLabel(_connection, storage)) {
for(VDI _vdi : _sr.getVDIs(_connection)) {
for(VBD _vbd : _vdi.getVBDs(_connection)) {
VM _vm_record = _vbd.getVM(_connection);
StringBuilder _sb = new StringBuilder();
Map<String, String> _vm = new HashMap<String, String>();
_vm.put("name", _vm_record.getNameLabel(_connection));
_vm.put("datastore", storage);
_sb = new StringBuilder();
for(VIF _vif : _vm_record.getVIFs(_connection)) {
if(_sb.length() > 0) {
_sb.append(":");
}
_sb.append(_vif.getDevice(_connection));
}
_vm.put("network", _sb.toString());
_vms.add(_vm);
}
}
}
} catch(Exception _ex) {
throw new Exception("hypervisor error - " + _ex.getMessage());
} finally {
Session.logout(_connection);
}
return _vms;
}
示例8: getVirtualMachine
import com.xensource.xenapi.Session; //导入方法依赖的package包/类
public Map<String, String> getVirtualMachine(String name) throws Exception {
if(name == null || name.isEmpty()) {
throw new Exception("invalid virtual machine name");
}
HostnameVerifier _hnv = new HTTPSHostnameVerifier();
HttpsURLConnection.setDefaultHostnameVerifier(_hnv);
Connection _connection = new Connection(new URL(this._url));
Session.loginWithPassword(_connection, this._user, this._password, APIVersion.latest().toString());
Map<String,String> _machine = new HashMap<String, String>();
try {
VM _vm = new ArrayList<VM>(VM.getByNameLabel(_connection, name)).get(0);
if(_vm == null) {
throw new Exception("virtual machine not found");
}
_machine.put("name", _vm.getNameLabel(_connection));
StringBuilder _sb = new StringBuilder();
for(VBD _vbd : _vm.getVBDs(_connection)) {
if(_sb.length() > 0) {
_sb.append(":");
}
_sb.append(_vbd.getVDI(_connection).getSR(_connection).getNameLabel(_connection));
}
_machine.put("datastore", _sb.toString());
_sb = new StringBuilder();
for(VIF _vif : _vm.getVIFs(_connection)) {
if(_sb.length() > 0) {
_sb.append(":");
}
_sb.append(_vif.getDevice(_connection));
}
_machine.put("network", _sb.toString());
} catch(Exception _ex) {
throw new Exception("hypervisor error - " + _ex.getMessage());
} finally {
Session.logout(_connection);
}
return _machine;
}