<div dir="ltr"><div><div><div>I've sent following example to our Python SDK,<br></div>feel free to try and review:<br><br> <a href="https://gerrit.ovirt.org/#/c/77003/1">https://gerrit.ovirt.org/#/c/77003/1</a><br><br></div>Also you may checkout relevant Ansible module, which support this<br></div>functionality as well:<br><br> <a href="http://docs.ansible.com/ansible/ovirt_disks_module.html">http://docs.ansible.com/ansible/ovirt_disks_module.html</a><br><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 17, 2017 at 1:21 PM, Guy Chen <span dir="ltr"><<a href="mailto:guchen@redhat.com" target="_blank">guchen@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><div><span style="font-size:12pt"><br></span></div><div><span style="font-size:12pt">I am trying to add direct LUN disk to a VM with python ovirtsdk4 ( storage domain is iscsi ) .</span></div><div>Adding a COW disk is working as in the SDK example, attached below, i have tried different things that i saw online but did not work, anybody have an example of how to add a direct LUN disk ?</div><div><br></div><div><span style="font-family:"DejaVu Sans Mono";font-size:9.2pt;color:rgb(0,0,128);font-weight:bold">def </span><span style="background-color:rgb(255,255,255);font-family:"DejaVu Sans Mono";font-size:9.2pt">add_VM_disk(</span><span style="font-family:"DejaVu Sans Mono";font-size:9.2pt;color:rgb(148,85,141)">self</span><span style="background-color:rgb(255,255,255);font-family:"DejaVu Sans Mono";font-size:9.2pt">):</span></div><div><pre style="background-color:#ffffff;font-family:'DejaVu Sans Mono';font-size:9.2pt"><br> vms_service = <span style="color:#94558d">self</span>.connection.system_<wbr>service().vms_service()<br> vm = vms_service.list(<span style="color:#660099">search</span>=<span style="color:#008000;font-weight:bold">'name=<wbr>myvm'</span>)[<span style="color:#0000ff">0</span>]<br><div><br></div> <span style="color:#808080;font-style:italic"># Locate the service that manages the disk attachments of the virtual<br></span><span style="color:#808080;font-style:italic"> # machine:<br></span><span style="color:#808080;font-style:italic"> </span>disk_attachments_service = vms_service.vm_service(<a href="http://vm.id" target="_blank">vm.id</a>).<wbr>disk_attachments_service()<br><div><br></div> <span style="color:#808080;font-style:italic"># Use the "add" method of the disk attachments service to add the disk.<br></span><span style="color:#808080;font-style:italic"> # Note that the size of the disk, the `provisioned_size` attribute, is<br></span><span style="color:#808080;font-style:italic"> # specified in bytes, so to create a disk of 10 GiB the value should<br></span><span style="color:#808080;font-style:italic"> # be 10 * 2^30.<br></span><span style="color:#808080;font-style:italic"> </span><span style="color:#808080">disk_attachment </span>= disk_attachments_service.add(<br> types.DiskAttachment(<br> <span style="color:#660099">disk</span>=types.Disk(<br> <span style="color:#660099">name</span>=<span style="color:#008000;font-weight:bold">'mydisk'</span>,<br> <span style="color:#660099">description</span>=<span style="color:#008000;font-weight:bold">'My disk'</span>,<br> <span style="color:#660099">format</span>=types.DiskFormat.COW,<br> <span style="color:#660099">provisioned_size</span>=<span style="color:#0000ff">10 </span>* <span style="color:#0000ff">2 </span>** <span style="color:#0000ff">30</span>,<br> ),<br> <span style="color:#660099">interface</span>=types.DiskInterface.<wbr>VIRTIO,<br> <span style="color:#660099">bootable</span>=<span style="color:#000080;font-weight:bold">False</span>,<br> <span style="color:#660099">active</span>=<span style="color:#000080;font-weight:bold">True</span>,<br> ),<br> )</pre></div><div><br></div><div><br></div><div><br></div></div></div><br>______________________________<wbr>_________________<br>
Users mailing list<br>
<a href="mailto:Users@ovirt.org">Users@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>