<html><body><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 data-mce-style="color: #000080; font-weight: bold;" 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 data-mce-style="color: #94558d;" 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;" data-mce-style="background-color: #ffffff; font-family: 'DejaVu Sans Mono'; font-size: 9.2pt;"><br> vms_service = <span style="color: #94558d;" data-mce-style="color: #94558d;">self</span>.connection.system_service().vms_service()<br> vm = vms_service.list(<span style="color: #660099;" data-mce-style="color: #660099;">search</span>=<span style="color: #008000; font-weight: bold;" data-mce-style="color: #008000; font-weight: bold;">'name=myvm'</span>)[<span style="color: #0000ff;" data-mce-style="color: #0000ff;">0</span>]<br><div><br></div> <span style="color: #808080; font-style: italic;" data-mce-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;" data-mce-style="color: #808080; font-style: italic;"> # machine:<br></span><span style="color: #808080; font-style: italic;" data-mce-style="color: #808080; font-style: italic;"> </span>disk_attachments_service = vms_service.vm_service(vm.id).disk_attachments_service()<br><div><br></div> <span style="color: #808080; font-style: italic;" data-mce-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;" data-mce-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;" data-mce-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;" data-mce-style="color: #808080; font-style: italic;"> # be 10 * 2^30.<br></span><span style="color: #808080; font-style: italic;" data-mce-style="color: #808080; font-style: italic;"> </span><span style="color: #808080;" data-mce-style="color: #808080;">disk_attachment </span>= disk_attachments_service.add(<br> types.DiskAttachment(<br> <span style="color: #660099;" data-mce-style="color: #660099;">disk</span>=types.Disk(<br> <span style="color: #660099;" data-mce-style="color: #660099;">name</span>=<span style="color: #008000; font-weight: bold;" data-mce-style="color: #008000; font-weight: bold;">'mydisk'</span>,<br> <span style="color: #660099;" data-mce-style="color: #660099;">description</span>=<span style="color: #008000; font-weight: bold;" data-mce-style="color: #008000; font-weight: bold;">'My disk'</span>,<br> <span style="color: #660099;" data-mce-style="color: #660099;">format</span>=types.DiskFormat.COW,<br> <span style="color: #660099;" data-mce-style="color: #660099;">provisioned_size</span>=<span style="color: #0000ff;" data-mce-style="color: #0000ff;">10 </span>* <span style="color: #0000ff;" data-mce-style="color: #0000ff;">2 </span>** <span style="color: #0000ff;" data-mce-style="color: #0000ff;">30</span>,<br> ),<br> <span style="color: #660099;" data-mce-style="color: #660099;">interface</span>=types.DiskInterface.VIRTIO,<br> <span style="color: #660099;" data-mce-style="color: #660099;">bootable</span>=<span style="color: #000080; font-weight: bold;" data-mce-style="color: #000080; font-weight: bold;">False</span>,<br> <span style="color: #660099;" data-mce-style="color: #660099;">active</span>=<span style="color: #000080; font-weight: bold;" data-mce-style="color: #000080; font-weight: bold;">True</span>,<br> ),<br> )</pre></div><div><br></div><div><br></div><div><br></div></div></body></html>