當前位置: 首頁>>代碼示例>>Java>>正文


Java CIMObjectPath類代碼示例

本文整理匯總了Java中org.sblim.wbem.cim.CIMObjectPath的典型用法代碼示例。如果您正苦於以下問題:Java CIMObjectPath類的具體用法?Java CIMObjectPath怎麽用?Java CIMObjectPath使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CIMObjectPath類屬於org.sblim.wbem.cim包,在下文中一共展示了CIMObjectPath類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: retrieveCimInfo

import org.sblim.wbem.cim.CIMObjectPath; //導入依賴的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);
  }
}
 
開發者ID:Juniper,項目名稱:vijava,代碼行數:33,代碼來源:CimTicket.java

示例2: queryCimObjects

import org.sblim.wbem.cim.CIMObjectPath; //導入依賴的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;
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:61,代碼來源:VmwareViJavaAccess.java


注:本文中的org.sblim.wbem.cim.CIMObjectPath類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。