------=_Part_9958888_908590827.1495020114002
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
I am trying to add direct LUN disk to a VM with python ovirtsdk4 ( storage domain is iscsi
) .
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 ?
def add_VM_disk( self ):
vms_service = self .connection.system_service().vms_service()
vm = vms_service.list( search = 'name=myvm' )[ 0 ]
# Locate the service that manages the disk attachments of the virtual
# machine:
disk_attachments_service = vms_service.vm_service(vm.id).disk_attachments_service()
# Use the "add" method of the disk attachments service to add the disk.
# Note that the size of the disk, the `provisioned_size` attribute, is
# specified in bytes, so to create a disk of 10 GiB the value should
# be 10 * 2^30.
disk_attachment = disk_attachments_service.add(
types.DiskAttachment(
disk =types.Disk(
name = 'mydisk' ,
description = 'My disk' ,
format =types.DiskFormat.COW,
provisioned_size = 10 * 2 ** 30 ,
),
interface =types.DiskInterface.VIRTIO,
bootable = False ,
active = True ,
),
)
------=_Part_9958888_908590827.1495020114002
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<html><body><div style=3D"font-family: times new roman, new york,
times, se=
rif; font-size: 12pt; color: #000000"><div><span style=3D"font-size:
12pt;"=
<br></span></div><div><span
style=3D"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,
attac=
hed 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=3D"color: #000080;
font-weight: bold;" =
style=3D"font-family: "DejaVu Sans Mono"; font-size: 9.2pt; color=
: rgb(0, 0, 128); font-weight: bold;">def </span><span
style=3D"background-=
color: rgb(255, 255, 255); font-family: "DejaVu Sans Mono"; font-=
size: 9.2pt;">add_VM_disk(</span><span data-mce-style=3D"color:
#94558d;" s=
tyle=3D"font-family: "DejaVu Sans Mono"; font-size: 9.2pt; color:=
rgb(148, 85, 141);">self</span><span style=3D"background-color:
rgb(255, 2=
55, 255); font-family: "DejaVu Sans Mono"; font-size:
9.2pt;">):<=
/span></div><div><pre style=3D"background-color: #ffffff;
font-family: 'Dej=
aVu Sans Mono'; font-size: 9.2pt;" data-mce-style=3D"background-color:
#fff=
fff; font-family: 'DejaVu Sans Mono'; font-size: 9.2pt;"><br>
vms_servic=
e =3D <span style=3D"color: #94558d;" data-mce-style=3D"color:
#94558d;">se=
lf</span>.connection.system_service().vms_service()<br> vm =3D vms_servi=
ce.list(<span style=3D"color: #660099;" data-mce-style=3D"color:
#660099;">=
search</span>=3D<span style=3D"color: #008000; font-weight: bold;"
data-mce=
-style=3D"color: #008000; font-weight:
bold;">'name=3Dmyvm'</span>)[<span s=
tyle=3D"color: #0000ff;" data-mce-style=3D"color:
#0000ff;">0</span>]<br><d=
iv><br></div> <span style=3D"color: #808080; font-style:
italic;" data-m=
ce-style=3D"color: #808080; font-style: italic;"># Locate the service that =
manages the disk attachments of the virtual<br></span><span
style=3D"color:=
#808080; font-style: italic;" data-mce-style=3D"color: #808080; font-style=
: italic;"> # machine:<br></span><span style=3D"color:
#808080; font-sty=
le: italic;" data-mce-style=3D"color: #808080; font-style: italic;">
</s=
pan>disk_attachments_service =3D vms_service.vm_service(vm.id).disk_attachm=
ents_service()<br><div><br></div> <span style=3D"color:
#808080; font-st=
yle: italic;" data-mce-style=3D"color: #808080; font-style: italic;">#
Use =
the "add" method of the disk attachments service to add the
disk.<br></span=
<span style=3D"color: #808080; font-style: italic;"
data-mce-style=3D"colo=
r: #808080; font-style: italic;"> # Note
that the size of the disk, the =
`provisioned_size` attribute, is<br></span><span style=3D"color:
#808080; f=
ont-style: italic;" data-mce-style=3D"color: #808080; font-style:
italic;">=
# specified in bytes, so to create a disk of 10 GiB the value should<br=
</span><span style=3D"color: #808080; font-style:
italic;" data-mce-style=
=3D"color: #808080; font-style: italic;">
# be 10 * 2^30.<br></span><spa=
n style=3D"color: #808080; font-style: italic;" data-mce-style=3D"color:
#8=
08080; font-style: italic;"> </span><span style=3D"color:
#808080;" data=
-mce-style=3D"color: #808080;">disk_attachment </span>=3D
disk_attachments_=
service.add(<br> types.DiskAttachment(<br> <span
style=3D=
"color: #660099;" data-mce-style=3D"color:
#660099;">disk</span>=3Dtypes.Di=
sk(<br> <span style=3D"color: #660099;"
data-mce-style=3D"co=
lor: #660099;">name</span>=3D<span style=3D"color: #008000;
font-weight: bo=
ld;" data-mce-style=3D"color: #008000; font-weight:
bold;">'mydisk'</span>,=
<br> <span style=3D"color: #660099;"
data-mce-style=3D"color=
: #660099;">description</span>=3D<span style=3D"color: #008000;
font-weight=
: bold;" data-mce-style=3D"color: #008000; font-weight: bold;">'My
disk'</s=
pan>,<br> <span style=3D"color: #660099;"
data-mce-style=3D"=
color: #660099;">format</span>=3Dtypes.DiskFormat.COW,<br>
<=
span style=3D"color: #660099;" data-mce-style=3D"color:
#660099;">provision=
ed_size</span>=3D<span style=3D"color: #0000ff;"
data-mce-style=3D"color: #=
0000ff;">10 </span>* <span style=3D"color: #0000ff;"
data-mce-style=3D"colo=
r: #0000ff;">2 </span>** <span style=3D"color: #0000ff;"
data-mce-style=3D"=
color: #0000ff;">30</span>,<br> ),<br>
<span style=3D=
"color: #660099;" data-mce-style=3D"color:
#660099;">interface</span>=3Dtyp=
es.DiskInterface.VIRTIO,<br> <span style=3D"color: #660099;"
dat=
a-mce-style=3D"color: #660099;">bootable</span>=3D<span
style=3D"color: #00=
0080; font-weight: bold;" data-mce-style=3D"color: #000080; font-weight: bo=
ld;">False</span>,<br> <span style=3D"color:
#660099;" data-mce-=
style=3D"color: #660099;">active</span>=3D<span style=3D"color:
#000080; fo=
nt-weight: bold;" data-mce-style=3D"color: #000080; font-weight:
bold;">Tru=
e</span>,<br> ),<br>
)</pre></div><div><br></div><div><br></div><=
div><br></div></div></body></html>
------=_Part_9958888_908590827.1495020114002--