org.glassfish.virtualization.libvirt.jna
Class Connect

java.lang.Object
  extended by org.glassfish.virtualization.libvirt.jna.LibVirtObject
      extended by org.glassfish.virtualization.libvirt.jna.Connect

public class Connect
extends LibVirtObject

Reprensents a low level connection to a libvirt library.

Author:
Jerome Dochez

Field Summary
 
Fields inherited from class org.glassfish.virtualization.libvirt.jna.LibVirtObject
libvirt
 
Constructor Summary
Connect(String uri)
          This function should be called first to get a connection to the Hypervisor and xen store
 
Method Summary
 Domain domainDefineXML(String xmlDesc)
          Defines a domain, but does not start it.
 Domain domainLookupByID(int id)
          Try to find a domain based on the hypervisor ID number Note that this won't work for inactive domains which have an ID of -1, in that case a lookup based on the Name or UUId need to be done instead.
 Domain domainLookupByName(String name)
          Looks up a domain based on its name.
 String[] listDefinedDomains()
          Lists the names of the defined but inactive domains
 int[] listDomains()
          Lists the active domains.
 String[] listStoragePools()
          Provides the list of names of active storage pools.
 int numOfDefinedDomains()
          Provides the number of non active domains.
 int numOfDomains()
          Provides the number of active domains.
 int numOfStoragePools()
          Provides the number of active storage pools
 StoragePool storagePoolCreateXML(String xmlDesc, int flags)
          Create a new storage based on its XML description.
 StoragePool storagePoolLookupByName(String name)
          Fetch a storage pool based on its unique name
 
Methods inherited from class org.glassfish.virtualization.libvirt.jna.LibVirtObject
checkForError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connect

public Connect(String uri)
        throws VirtException
This function should be called first to get a connection to the Hypervisor and xen store

Parameters:
uri - URI of the hypervisor
Throws:
VirtException - uf the connection cannot be established.
See Also:
API
Method Detail

numOfDomains

public int numOfDomains()
                 throws VirtException
Provides the number of active domains.

Returns:
the number of active domains
Throws:
VirtException - if an error occurs

listDomains

public int[] listDomains()
                  throws VirtException
Lists the active domains.

Returns:
and array of the IDs of the active domains
Throws:
VirtException - if an error occurs

numOfDefinedDomains

public int numOfDefinedDomains()
                        throws VirtException
Provides the number of non active domains.

Returns:
the number of active domains
Throws:
VirtException - if an error occurs

listDefinedDomains

public String[] listDefinedDomains()
                            throws VirtException
Lists the names of the defined but inactive domains

Returns:
an Array of Strings that contains the names of the defined domains currently inactive
Throws:
VirtException - if an error occurs
See Also:
API

domainLookupByID

public Domain domainLookupByID(int id)
                        throws VirtException
Try to find a domain based on the hypervisor ID number Note that this won't work for inactive domains which have an ID of -1, in that case a lookup based on the Name or UUId need to be done instead.

Parameters:
id - the hypervisor id
Returns:
the Domain object or null if the creation failed
Throws:
VirtException - if an error occurs
See Also:
API

domainLookupByName

public Domain domainLookupByName(String name)
                          throws VirtException
Looks up a domain based on its name.

Parameters:
name - the name of the domain
Returns:
the Domain object of null if it cannot be found
Throws:
VirtException - if an error occurs
See Also:
API

numOfStoragePools

public int numOfStoragePools()
                      throws VirtException
Provides the number of active storage pools

Returns:
the number of pools found
Throws:
VirtException - if an error occurs

listStoragePools

public String[] listStoragePools()
                          throws VirtException
Provides the list of names of active storage pools.

Returns:
an Array of Strings that contains the names of the defined storage pools
Throws:
VirtException - if an error occurs
See Also:
API

storagePoolLookupByName

public StoragePool storagePoolLookupByName(String name)
                                    throws VirtException
Fetch a storage pool based on its unique name

Parameters:
name - name of pool to fetch
Returns:
a StoragePool object, or NULL if no matching pool is found
Throws:
VirtException - if an error occurs
See Also:
API

storagePoolCreateXML

public StoragePool storagePoolCreateXML(String xmlDesc,
                                        int flags)
                                 throws VirtException
Create a new storage based on its XML description. The pool is not persistent, so its definition will disappear when it is destroyed, or if the host is restarted

Parameters:
xmlDesc - XML description for new pool
flags - future flags, use 0 for now
Returns:
a StoragePool object, or NULL if creation failed
Throws:
VirtException - if an error occurs

domainDefineXML

public Domain domainDefineXML(String xmlDesc)
                       throws VirtException
Defines a domain, but does not start it. his definition is persistent, until explicitly undefined with virDomainUndefine(). A previous definition for this domain would be overriden if it already exists.

Parameters:
xmlDesc - the XML description for the domain, preferably in UTF-8
Returns:
the Domain object, null in case of an error
Throws:
VirtException - if an error occurs.
See Also:
The XML format description


Copyright © 2012. All Rights Reserved.