[libvirt-users] creation of storage volume fails

Alex Jia ajia at redhat.com
Tue May 8 03:07:21 UTC 2012


On 05/08/2012 09:58 AM, John Wayne wrote:
> hi,
> i am getting this error below when i try to create a storage volume:
>
>     libvirt.virStoragePool.CreateXML(storagepoolobject,xmldesc,0)
> AttributeError: class virStoragePool has no attribute 'CreateXML'
Please see the above error message carefully, you're calling a error 
function name, it should be
'createXML' not 'CreateXML':

 >>> dir(libvirt.virStoragePool)
['UUID', 'UUIDString', 'XMLDesc', '__del__', '__doc__', '__init__', 
'__module__', 'autostart', 'build', 'connect', 'create', '*createXML*', 
'createXMLFrom', 'delete', 'destroy', 'info', 'isActive', 
'isPersistent', 'listVolumes', 'name', 'numOfVolumes', 'refresh', 
'setAutostart', 'storageVolLookupByName', 'undefine']

>
> my code is:
> xmldesc="xml description of storage volume which i got from sudo virsh 
> vol-dumpxml"
>
> #get a storage pool object to use in creating a volume
> storagepoolobject=libvirt.virConnect.storagePoolLookupByName(conn,'poolname')
>
> #now try to create the volume using the above storage pool object
> libvirt.virStoragePool.CreateXML(storagepoolobject,xmldesc,0)
>
>
> from python:
> -bash-4.1$ python
> >>> import libvirt
>
> >>> dir(libvirt.virStoragePool)
> ['UUID', 'UUIDString', 'XMLDesc', '__del__', '__doc__', '__init__', 
> '__module__', 'autostart', 'build', 'connect', 'create', 'createXML', 
> 'createXMLFrom', 'delete', 'destroy', 'info', 'isActive', 
> 'isPersistent', 'listVolumes', 'name', 'numOfVolumes', 'refresh', 
> 'setAutostart', 'storageVolLookupByName', 'undefine']
>
> >>> help(libvirt.virStoragePool.createXML)
> Help on method createXML in module libvirt:
>
> createXML(self, xmldesc, flags) unbound libvirt.virStoragePool method
>     Create a storage volume within a pool based
>     on an XML description. Not all pools support
>     creation of volumes
>
> from the libvirt.org documentation:
> http://libvirt.org/html/libvirt-libvirt.html#virStorageVolCreateXML
> virStorageVolPtrvirStorageVolCreateXML(virStoragePoolPtr pool,
> const char * xmldesc,
> unsigned int flags)
> Create a storage volume within a pool based on an XML description. Not 
> all pools support creation of volumes
> pool:pointer to storage pool
> xmldesc:description of volume to create
> flags:extra flags; not used yet, so callers should always pass 0
> Returns:the storage volume, or NULL on error
>
>
> _______________________________________________
> libvirt-users mailing list
> libvirt-users at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20120508/bbcc696e/attachment.htm>


More information about the libvirt-users mailing list