[et-mgmt-tools] [RFC] virtinst: build libvirt storage xml

Cole Robinson crobinso at redhat.com
Wed Jul 23 15:51:40 UTC 2008


I've been working on a virtinst API to build and install xml
for libvirt storage objects. The current version is attached:
so far only nfs, filesystem and dir pools are implemented, as
well as their associated file volumes, but the remainder will
be mostly a cut and paste job. I have some UI wizards for 
building these in virt-manager mostly complete, so this has
been tested to be pretty solid, though there is still some clean
up that needs doing.

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", uri="xen:///")

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)

volobj = vol.install()

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

An active connection/URI/pool object is required. I figure
there isn't a real use case for wanting to generate xml on a
machine without a libvirt setup, and this will ensure in the
future we can check against capabilities xml, make sure we
aren't colliding names and other things.

I think the implemented code covers most of the different
cases for generating storage xml, with the exception of
username and password for iscsi: I see this in the libvirt
code but this isn't documented anywhere, so I'm not sure
if their are any real catches.

Comments welcome.

Thanks,
Cole



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Storage.py
URL: <http://listman.redhat.com/archives/et-mgmt-tools/attachments/20080723/93915813/attachment.ksh>


More information about the et-mgmt-tools mailing list