Class GetCim


  • public class GetCim
    extends java.lang.Object
    provides helper functions for getting objects needed to work with CIM related services from the initial vSphere connection. This class is designed to be as stand-alone as possible.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  GetCim.PasswordCredential
      The default PasswordCredential will prevent us from using sessionId's that can be over 16 characters in length.
    • Constructor Summary

      Constructors 
      Constructor Description
      GetCim​(Connection connection)
      Only appropriate for direct connections to ESX hosts
      GetCim​(Connection connection, java.lang.String cimHostname)
      Appropriate for connections that are to a vCenter then to a managed host.
      GetCim​(Connection connection, java.lang.String cimHostname, GetHost getHost)
      if you already constructed a getHost utility use this constructor, appropriate for connecting to a vCenter and a managed host.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.cim.CIMObjectPath baseObjectPath​(java.net.URL base, java.lang.String namespace)
      Note base + namespace must make sense.
      javax.wbem.client.WBEMClient client​(com.vmware.vim25.HostServiceTicket ticket, java.net.URL baseUrl, java.lang.String namespace)  
      javax.wbem.client.WBEMClient client​(com.vmware.vim25.HostServiceTicket ticket, java.net.URL url, java.lang.String namespace, java.lang.String classname)
      creates a web client from a ticket, a URL, and a namespace and classname to query
      javax.wbem.client.WBEMClient client​(com.vmware.vim25.HostServiceTicket ticket, javax.cim.CIMObjectPath path)
      Creates a web client using the HostServiceTicket object.
      javax.wbem.client.WBEMClient client​(java.lang.String username, java.lang.String password, java.net.URL baseUrl, java.lang.String namespace)  
      javax.wbem.client.WBEMClient client​(java.lang.String username, java.lang.String password, java.net.URL url, java.lang.String namespace, java.lang.String path)
      creates a web client using all string based parameters
      javax.wbem.client.WBEMClient client​(java.lang.String username, java.lang.String password, javax.cim.CIMObjectPath path)
      Creates a web client using username, password, and a path
      javax.wbem.client.WBEMClient client​(javax.security.auth.Subject subject, java.net.URL url, java.lang.String namespace, java.lang.String classname)
      if you know how to build your own security subject, use this method instead
      javax.wbem.client.WBEMClient client​(javax.security.auth.Subject subject, javax.cim.CIMObjectPath path)  
      javax.cim.CIMObjectPath objectPath​(java.net.URL base, java.lang.String namespace, java.lang.String cimclassname)
      builds a CIMObjectPath based on URI elements
      javax.security.auth.Subject subject​(com.vmware.vim25.HostServiceTicket ticket)
      A subject is an authentication construct.
      javax.security.auth.Subject subject​(java.lang.String principal, java.lang.String passwordCredential)
      Builds a security subject object based on the principal name and credential you pass.
      com.vmware.vim25.HostServiceTicket ticket()
      works only for vCenter, this grants us a ticket to access a ESX host controlled by our vCenter
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • WBEMCLIENT_FORMAT

        public static final java.lang.String WBEMCLIENT_FORMAT
        See Also:
        Constant Field Values
      • INTEROP_NAMESPACE

        public static final java.lang.String INTEROP_NAMESPACE
        See Also:
        Constant Field Values
      • NAMESPACES

        public static final java.lang.String[] NAMESPACES
        Namespaces are static per server. You may query available namespaces using a service location protocol (SLP) agent or simply use the hard coded namespaces known to be hard coded onto the ESX and ESXi hosts.
      • cimHostname

        public final java.lang.String cimHostname
      • getHost

        public final GetHost getHost
    • Constructor Detail

      • GetCim

        public GetCim​(Connection connection,
                      java.lang.String cimHostname,
                      GetHost getHost)
        if you already constructed a getHost utility use this constructor, appropriate for connecting to a vCenter and a managed host.
        Parameters:
        connection -
        cimHostname -
        getHost -
      • GetCim

        public GetCim​(Connection connection,
                      java.lang.String cimHostname)
        Appropriate for connections that are to a vCenter then to a managed host.
        Parameters:
        connection -
        cimHostname -
      • GetCim

        public GetCim​(Connection connection)
        Only appropriate for direct connections to ESX hosts
        Parameters:
        connection -
    • Method Detail

      • ticket

        public com.vmware.vim25.HostServiceTicket ticket()
        works only for vCenter, this grants us a ticket to access a ESX host controlled by our vCenter
        Returns:
        a valid ticket to use for login
        See Also:
        HostServiceTicket
      • baseObjectPath

        public javax.cim.CIMObjectPath baseObjectPath​(java.net.URL base,
                                                      java.lang.String namespace)
        Note base + namespace must make sense. There are various formula for creating a valid CIMObjectPath ultimately, these are URI when represented in string form.
        Parameters:
        base -
        namespace -
        Returns:
        object path representing the query
        See Also:
        CIMObjectPath
      • objectPath

        public javax.cim.CIMObjectPath objectPath​(java.net.URL base,
                                                  java.lang.String namespace,
                                                  java.lang.String cimclassname)
        builds a CIMObjectPath based on URI elements
        Parameters:
        base - - base URL of the CIM server
        namespace - - namespace to read
        cimclassname - - name of the class to look at
        Returns:
        fully constructed but CIMObjectPath (will not have properties since it was locally constructed)
        See Also:
        CIMObjectPath
      • client

        public javax.wbem.client.WBEMClient client​(com.vmware.vim25.HostServiceTicket ticket,
                                                   javax.cim.CIMObjectPath path)
        Creates a web client using the HostServiceTicket object.

        NOTE: you must be connected to a vCenter for this to make sense

        Parameters:
        ticket - granted by vCenter
        path - the initial path for the client to talk to
        Returns:
        a WBEMClient
        See Also:
        WBEMClient
      • client

        public javax.wbem.client.WBEMClient client​(java.lang.String username,
                                                   java.lang.String password,
                                                   javax.cim.CIMObjectPath path)
        Creates a web client using username, password, and a path
        Parameters:
        username -
        password -
        path -
        Returns:
        a web client
        See Also:
        WBEMClient
      • client

        public javax.wbem.client.WBEMClient client​(javax.security.auth.Subject subject,
                                                   javax.cim.CIMObjectPath path)
        Parameters:
        subject - - a security subject built for authentication on the CIM server
        path - - initial search path
        Returns:
        a client ready to work with CIM data
        Throws:
        com.vmware.cim.helpers.GetCim.GetCimWBEMException - if we cannot initialize the client
        See Also:
        WBEMClient
      • client

        public javax.wbem.client.WBEMClient client​(java.lang.String username,
                                                   java.lang.String password,
                                                   java.net.URL url,
                                                   java.lang.String namespace,
                                                   java.lang.String path)
        creates a web client using all string based parameters
        Parameters:
        username -
        password -
        url -
        namespace -
        path -
        Returns:
        a web client
        See Also:
        WBEMClient
      • client

        public javax.wbem.client.WBEMClient client​(com.vmware.vim25.HostServiceTicket ticket,
                                                   java.net.URL url,
                                                   java.lang.String namespace,
                                                   java.lang.String classname)
        creates a web client from a ticket, a URL, and a namespace and classname to query
        Parameters:
        ticket -
        url -
        namespace -
        classname -
        Returns:
        a web client
        See Also:
        WBEMClient
      • client

        public javax.wbem.client.WBEMClient client​(javax.security.auth.Subject subject,
                                                   java.net.URL url,
                                                   java.lang.String namespace,
                                                   java.lang.String classname)
        if you know how to build your own security subject, use this method instead
        Parameters:
        subject -
        url -
        namespace -
        classname -
        Returns:
        a client
        See Also:
        WBEMClient
      • subject

        public javax.security.auth.Subject subject​(com.vmware.vim25.HostServiceTicket ticket)
        A subject is an authentication construct. The vSphere API allows you to obtain a ticket from the vSphere SDK and use that ticket to construct a subject based on it.

        Returns:
        the subject built with the ticket for use in WBEMClient
        See Also:
        WBEMClient, Subject
      • subject

        public javax.security.auth.Subject subject​(java.lang.String principal,
                                                   java.lang.String passwordCredential)
        Builds a security subject object based on the principal name and credential you pass.

        Parameters:
        principal -
        passwordCredential -
        Returns:
        a subject for use in the WBEMClient
      • client

        public javax.wbem.client.WBEMClient client​(com.vmware.vim25.HostServiceTicket ticket,
                                                   java.net.URL baseUrl,
                                                   java.lang.String namespace)
      • client

        public javax.wbem.client.WBEMClient client​(java.lang.String username,
                                                   java.lang.String password,
                                                   java.net.URL baseUrl,
                                                   java.lang.String namespace)