[et-mgmt-tools] [PATCH] virtinst: interface for building libvirt storage xml

Cole Robinson crobinso at redhat.com
Wed Aug 6 16:17:03 UTC 2008


The attached patch adds an API to virtinst for building
libvirt storage pool and storage volume xml. This largely
works as it did in my previous posting, but it has had
more thorough testing. There is also some documentation
in the code that should make the design a bit more clear.

The general workflow is as follows:

=========================================
import virtinst.Storage.StoragePool as sp

# This gives the appropriate class for the specified pool type
pool_class = sp.get_pool_class(sp.TYPE_FOO)

# Only required params are a conn/uri and name. Default formats
# and target paths have default values, but source paths/
# devices and hostnames obviously have no sensible default, but
# they still aren't required for object instantiation
pool = pool_class(name="foo", conn=someVirConnectInstance)

pool.source_path = "/dev/foo"
etc.

# Prints xml config: will error if all required members aren't
# specified
pool.get_xml_config()

# Attempts to install and build pool on the passed connection
poolobj = pool.install()

# Will return appropriate volume class for this pool type
vol_class = pool.get_volume_class()

# For volumes, we require a pool instead of conn/uri, as well
# as name and capacity
vol = vol_class(name="volfoo", pool=poolobj, capacity=1234)

volobj = vol.install()

=====================================

This doesn't include iscsi, disk, or logical pools or block
device volumes, but those should mostly be a cut and paste
job and I haven't found the time to test them out yet. There
is no harm in them coming later though.

Any comments appreciated.

Thanks,
Cole
-------------- next part --------------
A non-text attachment was scrubbed...
Name: virtinst-build-storage-xml.patch
Type: text/x-patch
Size: 31172 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/et-mgmt-tools/attachments/20080806/9cd125c5/attachment.bin>


More information about the et-mgmt-tools mailing list