<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 05/08/2012 09:58 AM, John Wayne wrote:
<blockquote
cite="mid:1336442320.14051.YahooMailNeo@web31805.mail.mud.yahoo.com"
type="cite">
<div style="color: rgb(0, 0, 0); background-color: rgb(255, 255,
255); font-family: verdana,helvetica,sans-serif; font-size:
10pt;">
<div>
<div>
<div>hi,</div>
<div>i am getting this error below when i try to create a
storage volume:</div>
<div><br>
</div>
<div>
libvirt.virStoragePool.CreateXML(storagepoolobject,xmldesc,0)</div>
<div>AttributeError: class virStoragePool has no attribute
'CreateXML'</div>
</div>
</div>
</div>
</blockquote>
Please see the above error message carefully, you're calling a error
function name, it should be<br>
'createXML' not 'CreateXML':<br>
<br>
>>> dir(libvirt.virStoragePool)<br>
['UUID', 'UUIDString', 'XMLDesc', '__del__', '__doc__', '__init__',
'__module__', 'autostart', 'build', 'connect', 'create', '<b>createXML</b>',
'createXMLFrom', 'delete', 'destroy', 'info', 'isActive',
'isPersistent', 'listVolumes', 'name', 'numOfVolumes', 'refresh',
'setAutostart', 'storageVolLookupByName', 'undefine']<br>
<br>
<blockquote
cite="mid:1336442320.14051.YahooMailNeo@web31805.mail.mud.yahoo.com"
type="cite">
<div style="color: rgb(0, 0, 0); background-color: rgb(255, 255,
255); font-family: verdana,helvetica,sans-serif; font-size:
10pt;">
<div>
<div>
<div><br>
</div>
<div>my code is:</div>
<div>xmldesc="xml description of storage volume which i got
from sudo virsh vol-dumpxml"</div>
<div><br>
</div>
<div>#get a storage pool object to use in creating a volume</div>
<div>storagepoolobject=libvirt.virConnect.storagePoolLookupByName(conn,'poolname')</div>
<div><br>
</div>
<div>#now try to create the volume using the above storage
pool object</div>
<div>libvirt.virStoragePool.CreateXML(storagepoolobject,xmldesc,0)</div>
<div><br>
</div>
<div><br>
</div>
<div>from python:</div>
<div>-bash-4.1$ python</div>
<div>>>> import libvirt<br>
</div>
<div><br>
</div>
<div>>>> dir(libvirt.virStoragePool)</div>
<div>['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']</div>
<div><br>
</div>
<div>>>> help(libvirt.virStoragePool.createXML)</div>
<div>Help on method createXML in module libvirt:</div>
<div><br>
</div>
<div>createXML(self, xmldesc, flags) unbound
libvirt.virStoragePool method</div>
<div> Create a storage volume within a pool based</div>
<div> on an XML description. Not all pools support</div>
<div> creation of volumes</div>
<div><br>
</div>
<div>from the libvirt.org documentation:</div>
<div><a class="moz-txt-link-freetext" href="http://libvirt.org/html/libvirt-libvirt.html#virStorageVolCreateXML">http://libvirt.org/html/libvirt-libvirt.html#virStorageVolCreateXML</a></div>
<div>virStorageVolPtr<span class="Apple-tab-span"
style="white-space: pre;"> </span>virStorageVolCreateXML<span
class="Apple-tab-span" style="white-space: pre;"> </span>(virStoragePoolPtr
pool, </div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span> const char * xmldesc, </div>
<div><span class="Apple-tab-span" style="white-space: pre;">
</span> unsigned int flags)</div>
<div>Create a storage volume within a pool based on an XML
description. Not all pools support creation of volumes</div>
<div>pool:<span class="Apple-tab-span" style="white-space:
pre;"> </span>pointer to storage pool</div>
<div>xmldesc:<span class="Apple-tab-span"
style="white-space: pre;"> </span>description of volume
to create</div>
<div>flags:<span class="Apple-tab-span" style="white-space:
pre;"> </span>extra flags; not used yet, so callers
should always pass 0</div>
<div>Returns:<span class="Apple-tab-span"
style="white-space: pre;"> </span>the storage volume,
or NULL on error</div>
<div><br>
</div>
</div>
</div>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
libvirt-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:libvirt-users@redhat.com">libvirt-users@redhat.com</a>
<a class="moz-txt-link-freetext" href="https://www.redhat.com/mailman/listinfo/libvirt-users">https://www.redhat.com/mailman/listinfo/libvirt-users</a></pre>
</blockquote>
<br>
</body>
</html>