当前位置: 首页>>代码示例>>Java>>正文


Java APIVersion类代码示例

本文整理汇总了Java中com.xensource.xenapi.APIVersion的典型用法代码示例。如果您正苦于以下问题:Java APIVersion类的具体用法?Java APIVersion怎么用?Java APIVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


APIVersion类属于com.xensource.xenapi包,在下文中一共展示了APIVersion类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: existsNFSStore

import com.xensource.xenapi.APIVersion; //导入依赖的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;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:27,代码来源:HypervisorManagerXen.java

示例2: getStoreNames

import com.xensource.xenapi.APIVersion; //导入依赖的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;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:20,代码来源:HypervisorManagerXen.java

示例3: getStores

import com.xensource.xenapi.APIVersion; //导入依赖的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;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:26,代码来源:HypervisorManagerXen.java

示例4: getVirtualMachineNames

import com.xensource.xenapi.APIVersion; //导入依赖的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;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:24,代码来源:HypervisorManagerXen.java

示例5: HypervisorManagerXen

import com.xensource.xenapi.APIVersion; //导入依赖的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());
	}
       
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:38,代码来源:HypervisorManagerXen.java

示例6: getHostForVirtualMachine

import com.xensource.xenapi.APIVersion; //导入依赖的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);
		}
	}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:30,代码来源:HypervisorManagerXen.java

示例7: getVirtualMachines

import com.xensource.xenapi.APIVersion; //导入依赖的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;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:37,代码来源:HypervisorManagerXen.java

示例8: getVirtualMachine

import com.xensource.xenapi.APIVersion; //导入依赖的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;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:43,代码来源:HypervisorManagerXen.java


注:本文中的com.xensource.xenapi.APIVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。