本文整理汇总了Java中org.sblim.wbem.cim.CIMObject类的典型用法代码示例。如果您正苦于以下问题:Java CIMObject类的具体用法?Java CIMObject怎么用?Java CIMObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CIMObject类属于org.sblim.wbem.cim包,在下文中一共展示了CIMObject类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertyOfCimObject
import org.sblim.wbem.cim.CIMObject; //导入依赖的package包/类
/**
* Returns the value of a given cim object and property.
*
* @param cimObject the Cim object
* @param propertyName the property's name
* @return the value
*/
public String getPropertyOfCimObject(CIMObject cimObject, String propertyName) {
if (cimObject == null) {
return null;
} else {
CIMProperty cimProperty = cimObject.getProperty(propertyName);
if (cimProperty == null) {
return null;
} else {
CIMValue cimValue = cimProperty.getValue();
if (cimValue == null) {
return null;
} else {
Object object = cimValue.getValue();
if (object == null) {
return null;
} else {
return object.toString();
}
}
}
}
}
示例2: retrieveCimInfo
import org.sblim.wbem.cim.CIMObject; //导入依赖的package包/类
private static void retrieveCimInfo(
String urlStr, String sessionId)
{
String serverUrl = urlStr.substring(0,
urlStr.lastIndexOf("/sdk"));
String cimAgentAddress = serverUrl + ":5989";
String namespace = "root/cimv2";
UserPrincipal userPr = new UserPrincipal(sessionId);
PasswordCredential pwCred = new PasswordCredential(
sessionId.toCharArray());
CIMNameSpace ns = new CIMNameSpace(
cimAgentAddress, namespace);
CIMClient cimClient = new CIMClient(ns, userPr, pwCred);
CIMObjectPath rpCOP = new CIMObjectPath(
"CIM_RegisteredProfile");
System.out.println("Looking for children of " +
"CIM_RegisteredProfile");
long enumerationStart = System.currentTimeMillis();
Enumeration rpEnm = cimClient.enumerateInstances(rpCOP);
long enumerationStop = System.currentTimeMillis();
System.out.println("Enumeration completed in: " +
(enumerationStop - enumerationStart) / 1000 + " sec.\n");
while (rpEnm.hasMoreElements())
{
CIMObject rp = (CIMObject) rpEnm.nextElement();
System.out.println(" Found: " + rp);
}
}
示例3: queryCimObjects
import org.sblim.wbem.cim.CIMObject; //导入依赖的package包/类
/**
* Queries a host system for Cim data.
*
* @param hostSystem the host system to query
* @param cimClass the class of Cim objects to retrieve
* @param primaryIpAddress the Ip address to use
* @return the list of Cim objects
* @throws RemoteException
* @throws CIMException
*/
public List<CIMObject> queryCimObjects(HostSystem hostSystem, String cimClass, String primaryIpAddress) throws ConnectException, RemoteException, CIMException {
List<CIMObject> cimObjects = new ArrayList<CIMObject>();
if (!m_hostServiceTickets.containsKey(hostSystem)) {
m_hostServiceTickets.put(hostSystem, hostSystem.acquireCimServicesTicket());
}
HostServiceTicket hostServiceTicket = m_hostServiceTickets.get(hostSystem);
if (!m_hostSystemCimUrls.containsKey(hostSystem)) {
String ipAddress = primaryIpAddress;
if (ipAddress == null) {
ipAddress = getPrimaryHostSystemIpAddress(hostSystem);
}
if (ipAddress == null) {
logger.warn("Cannot determine ip address for host system '{}'", hostSystem.getMOR().getVal());
return cimObjects;
}
m_hostSystemCimUrls.put(hostSystem, "https://" + ipAddress + ":5989");
}
String cimAgentAddress = m_hostSystemCimUrls.get(hostSystem);
String namespace = "root/cimv2";
UserPrincipal userPr = new UserPrincipal(hostServiceTicket.getSessionId());
PasswordCredential pwCred = new PasswordCredential(hostServiceTicket.getSessionId().toCharArray());
CIMNameSpace ns = new CIMNameSpace(cimAgentAddress, namespace);
CIMClient cimClient = new CIMClient(ns, userPr, pwCred);
// very important to query esx5 hosts
cimClient.useMPost(false);
CIMObjectPath rpCOP = new CIMObjectPath(cimClass);
Enumeration<?> rpEnm = cimClient.enumerateInstances(rpCOP);
while (rpEnm.hasMoreElements()) {
CIMObject rp = (CIMObject) rpEnm.nextElement();
cimObjects.add(rp);
}
return cimObjects;
}