Class VmwareViJavaAccess

  • All Implemented Interfaces:
    AutoCloseable

    public class VmwareViJavaAccess
    extends Object
    implements AutoCloseable
    The Class VmwareViJavaAccess

    This class provides all the functionality to query Vmware infrastructure components.

    Author:
    Christian Pape
    • Constructor Detail

      • VmwareViJavaAccess

        public VmwareViJavaAccess​(String hostname,
                                  String username,
                                  String password)
        Constructor for creating a instance for a given server and credentials.
        Parameters:
        hostname - the vCenter's hostname
        username - the username
        password - the password
      • VmwareViJavaAccess

        public VmwareViJavaAccess​(String hostname)
                           throws IOException
        Constructor for creating a instance for a given server. Checks whether credentials are available in the Vmware config file.
        Parameters:
        hostname - the vCenter's hostname
        Throws:
        IOException
      • VmwareViJavaAccess

        public VmwareViJavaAccess​(VmwareServer vmwareServer)
    • Method Detail

      • getTimeout

        public int getTimeout()
      • setTimeout

        public boolean setTimeout​(int timeout)
        Sets the timeout for server connections.
        Parameters:
        timeout - the timeout to be used for connecting
        Returns:
        true, if the operation was successful
      • disconnect

        public void disconnect()
        Disconnects from the server.
      • relax

        protected void relax()
        This method is used to "relax" the policies concerning self-signed certificates.
      • getPerfCounterInfoMap

        public Map<Integer,​com.vmware.vim25.PerfCounterInfo> getPerfCounterInfoMap()
        This method retrieves the performance counters available.
        Returns:
        a map of performance counters
      • getManagedEntityByManagedObjectId

        public com.vmware.vim25.mo.ManagedEntity getManagedEntityByManagedObjectId​(String managedObjectId)
        Returns a managed entitiy for a given managed object Id.
        Parameters:
        managedObjectId - the managed object Id
        Returns:
        the managed entity
      • getVirtualMachineByManagedObjectId

        public com.vmware.vim25.mo.VirtualMachine getVirtualMachineByManagedObjectId​(String managedObjectId)
        Returns a virtual machine by a given managed object Id.
        Parameters:
        managedObjectId - the managed object Id
        Returns:
        the virtual machine object
      • getHostSystemByManagedObjectId

        public com.vmware.vim25.mo.HostSystem getHostSystemByManagedObjectId​(String managedObjectId)
        Returns a host system by a given managed object Id.
        Parameters:
        managedObjectId - the managed object Id
        Returns:
        the host system object
      • queryPerformanceValues

        public VmwarePerformanceValues queryPerformanceValues​(com.vmware.vim25.mo.ManagedEntity managedEntity)
                                                       throws RemoteException
        This method queries performance values for a given managed entity.
        Parameters:
        managedEntity - the managed entity to query
        Returns:
        the perfomance values
        Throws:
        RemoteException
      • queryCimObjects

        public List<org.sblim.wbem.cim.CIMObject> queryCimObjects​(com.vmware.vim25.mo.HostSystem hostSystem,
                                                                  String cimClass,
                                                                  String primaryIpAddress)
                                                           throws ConnectException,
                                                                  RemoteException,
                                                                  org.sblim.wbem.cim.CIMException
        Queries a host system for Cim data.
        Parameters:
        hostSystem - the host system to query
        cimClass - the class of Cim objects to retrieve
        primaryIpAddress - the Ip address to use
        Returns:
        the list of Cim objects
        Throws:
        RemoteException
        org.sblim.wbem.cim.CIMException
        ConnectException
      • queryCimObjects

        public List<org.sblim.wbem.cim.CIMObject> queryCimObjects​(com.vmware.vim25.mo.HostSystem hostSystem,
                                                                  String cimClass)
                                                           throws ConnectException,
                                                                  RemoteException,
                                                                  org.sblim.wbem.cim.CIMException
        Queries a host system for Cim data.
        Parameters:
        hostSystem - the host system to query
        cimClass - the class of Cim objects to retrieve
        Returns:
        the list of Cim objects
        Throws:
        RemoteException
        org.sblim.wbem.cim.CIMException
        ConnectException
      • getPrimaryHostSystemIpAddress

        public String getPrimaryHostSystemIpAddress​(com.vmware.vim25.mo.HostSystem hostSystem)
        Searches for the primary ip address of a host system.

        The idea is to resolve the HostSystem's name and use the resulting IP if the IP is listed on the available addresses list, otherwise, use the first ip listed on the available list.

        Parameters:
        hostSystem - the host system to query
        Returns:
        the primary ip address
      • getHostSystemIpAddresses

        public TreeSet<String> getHostSystemIpAddresses​(com.vmware.vim25.mo.HostSystem hostSystem)
        Searches for all ip addresses of a host system
        Parameters:
        hostSystem - the host system to query
        Returns:
        the ip addresses of the host system, the first one is the primary
      • getVirtualMachineIpAddresses

        public TreeSet<String> getVirtualMachineIpAddresses​(com.vmware.vim25.mo.VirtualMachine virtualMachine)
        Searches for all ip addresses of a virtual machine
        Parameters:
        virtualMachine - the virtual machine to query
        Returns:
        the ip addresses of the virtual machine, the first one is the primary
      • searchManagedEntities

        public com.vmware.vim25.mo.ManagedEntity[] searchManagedEntities​(String type)
                                                                  throws RemoteException
        Searches for a managed entity by a given type.
        Parameters:
        type - the type string to search for
        Returns:
        the list of managed entities found
        Throws:
        RemoteException
      • getMajorApiVersion

        public int getMajorApiVersion()
        Return the major API version for this management server
        Returns:
        the major API version
      • getPropertyOfCimObject

        public String getPropertyOfCimObject​(org.sblim.wbem.cim.CIMObject cimObject,
                                             String propertyName)
        Returns the value of a given cim object and property.
        Parameters:
        cimObject - the Cim object
        propertyName - the property's name
        Returns:
        the value
      • setServiceInstancePool

        public static void setServiceInstancePool​(ServiceInstancePool serviceInstancePool)