add direct LUN disk to a VM with python SDK

<br></span></div><div><span style=3D"font-size: 12pt;">I am trying to add =
<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=
------=_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;"= 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= 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--

--Apple-Mail=_287C8533-0DD4-49B1-824D-8C8E893889AC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Did you have a look at: = http://ovirt.github.io/ovirt-engine-sdk/master/services.m.html#ovirtsdk4.s= ervices.DisksService = <http://ovirt.github.io/ovirt-engine-sdk/master/services.m.html#ovirtsdk4.= services.DisksService> = http://ovirt.github.io/ovirt-engine-sdk/master/types.m.html#ovirtsdk4.type= s.LogicalUnit = <http://ovirt.github.io/ovirt-engine-sdk/master/types.m.html#ovirtsdk4.typ= es.LogicalUnit> In my case a attached LUN is exported as: <disk = href=3D"/ovirt-engine/api/disks/638676d4-01f3-422c-b14b-0e8f4ba0529d" = id=3D"638676d4-01f3-422c-b14b-0e8f4ba0529d"> <alias>xxx</alias> <description></description> <lun_storage id=3D"3600c0ff00026285a4613e55701000000"> <logical_units> <logical_unit id=3D"3600c0ff00026285a4613e55701000000"> <disk_id>638676d4-01f3-422c-b14b-0e8f4ba0529d</disk_id> <lun_mapping>39</lun_mapping> <paths>0</paths> <product_id>MSA 2040 SAS</product_id> = <serial>SHP_MSA_2040_SAS_00c0ff26285a00004613e55701000000</serial> <size>536870912000</size> <vendor_id>HP</vendor_id> </logical_unit> </logical_units> </lun_storage> <name>3dpse_crawl_tp</name> <propagate_errors>false</propagate_errors> <shareable>false</shareable> <storage_type>lun</storage_type> <wipe_after_delete>false</wipe_after_delete> </disk> The lun_storage id is taken directly from the lun is as seen by the = kernel: ls -l /dev/disk/*/*3600c0ff00026285a4613e55701000000* lrwxrwxrwx 1 root root 10 May 9 15:15 = /dev/disk/by-id/dm-name-3600c0ff00026285a4613e55701000000 -> ../../dm-4 lrwxrwxrwx 1 root root 10 May 9 15:15 = /dev/disk/by-id/dm-uuid-mpath-3600c0ff00026285a4613e55701000000 -> = ../../dm-4 lrwxrwxrwx 1 root root 10 May 17 16:01 = /dev/disk/by-id/scsi-3600c0ff00026285a4613e55701000000 -> ../../sdec In the old sdk3, I was doing it that way: = https://github.com/fbacchella/ovirtcmd/blob/master/ovlib/disks/__init__.py= #L35 = <https://github.com/fbacchella/ovirtcmd/blob/master/ovlib/disks/__init__.p= y#L35> What was called params is now a type.
Le 17 mai 2017 =C3=A0 13:21, Guy Chen <guchen@redhat.com> a =C3=A9crit = : =20 =20 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 ? =20 def add_VM_disk(self): =20 vms_service =3D self.connection.system_service().vms_service() vm =3D vms_service.list(search=3D'name=3Dmyvm')[0] =20 # Locate the service that manages the disk attachments of the = virtual # machine: disk_attachments_service =3D = vms_service.vm_service(vm.id).disk_attachments_service() =20 # 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 =3D disk_attachments_service.add( types.DiskAttachment( disk=3Dtypes.Disk( name=3D'mydisk', description=3D'My disk', format=3Dtypes.DiskFormat.COW, provisioned_size=3D10 * 2 ** 30, ), interface=3Dtypes.DiskInterface.VIRTIO, bootable=3DFalse, active=3DTrue, ), ) =20 =20 =20 _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
--Apple-Mail=_287C8533-0DD4-49B1-824D-8C8E893889AC Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html = charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" = class=3D"">Did you have a look at:<div class=3D""><br = class=3D""></div><div class=3D""><br class=3D""></div><div class=3D""><a = href=3D"http://ovirt.github.io/ovirt-engine-sdk/master/services.m.html#ovi= rtsdk4.services.DisksService" = class=3D"">http://ovirt.github.io/ovirt-engine-sdk/master/services.m.html#= ovirtsdk4.services.DisksService</a></div><div class=3D""><a = href=3D"http://ovirt.github.io/ovirt-engine-sdk/master/types.m.html#ovirts= dk4.types.LogicalUnit" = class=3D"">http://ovirt.github.io/ovirt-engine-sdk/master/types.m.html#ovi= rtsdk4.types.LogicalUnit</a></div><div class=3D""><br = class=3D""></div><div class=3D""><br class=3D""></div><div class=3D"">In = my case a attached LUN is exported as:</div><div class=3D""><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D""><disk = href=3D"/ovirt-engine/api/disks/638676d4-01f3-422c-b14b-0e8f4ba0529d" = id=3D"638676d4-01f3-422c-b14b-0e8f4ba0529d"></span></div><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D""> = <alias>xxx</alias></span></div><div style=3D"margin: 0px; = font-size: 11px; line-height: normal; font-family: Menlo;" = class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures" = class=3D""> = <description></description></span></div><div style=3D"margin: = 0px; font-size: 11px; line-height: normal; font-family: Menlo;" = class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures" = class=3D""> <lun_storage = id=3D"3600c0ff00026285a4613e55701000000"></span></div><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D""> = <logical_units></span></div><div style=3D"margin: 0px; font-size: = 11px; line-height: normal; font-family: Menlo;" class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D""> = <logical_unit = id=3D"3600c0ff00026285a4613e55701000000"></span></div><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D""> = <disk_id>638676d4-01f3-422c-b14b-0e8f4ba0529d</disk_id></span>= </div><div style=3D"margin: 0px; font-size: 11px; line-height: normal; = font-family: Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D""> = <lun_mapping>39</lun_mapping></span></div><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D""> = <paths>0</paths></span></div><div style=3D"margin: 0px; = font-size: 11px; line-height: normal; font-family: Menlo;" = class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures" = class=3D""> <product_id>MSA 2040 = SAS</product_id></span></div><div style=3D"margin: 0px; font-size: = 11px; line-height: normal; font-family: Menlo;" class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D""> = = <serial>SHP_MSA_2040_SAS_00c0ff26285a00004613e55701000000</serial= ></span></div><div style=3D"margin: 0px; font-size: 11px; = line-height: normal; font-family: Menlo;" class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D""> = = <size>536870912000</size></span></div><div style=3D"margin: = 0px; font-size: 11px; line-height: normal; font-family: Menlo;" = class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures" = class=3D""> = <vendor_id>HP</vendor_id></span></div><div style=3D"margin: = 0px; font-size: 11px; line-height: normal; font-family: Menlo;" = class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures" = class=3D""> </logical_unit></span></div><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D""> = </logical_units></span></div><div style=3D"margin: 0px; font-size: = 11px; line-height: normal; font-family: Menlo;" class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D""> = </lun_storage></span></div><div style=3D"margin: 0px; font-size: = 11px; line-height: normal; font-family: Menlo;" class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D""> = <name>3dpse_crawl_tp</name></span></div><div style=3D"margin: = 0px; font-size: 11px; line-height: normal; font-family: Menlo;" = class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures" = class=3D""> = <propagate_errors>false</propagate_errors></span></div><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D""> = <shareable>false</shareable></span></div><div style=3D"margin:= 0px; font-size: 11px; line-height: normal; font-family: Menlo;" = class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures" = class=3D""> = <storage_type>lun</storage_type></span></div><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D""> = <wipe_after_delete>false</wipe_after_delete></span></div><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""></disk></div></div><div class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D""><br = class=3D""></span></div><div class=3D"">The lun_storage id is taken = directly from the lun is as seen by the kernel:</div><div class=3D""><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D"">ls -l = /dev/disk/*/*3600c0ff00026285a4613e55701000000*</span></div><div = style=3D"margin: 0px; font-size: 11px; line-height: normal; font-family: = Menlo;" class=3D""><span style=3D"font-variant-ligatures: = no-common-ligatures" class=3D"">lrwxrwxrwx 1 root root 10 May 9 = 15:15 /dev/disk/by-id/dm-name-3600c0ff00026285a4613e55701000000 -> = ../../dm-4</span></div><div style=3D"margin: 0px; font-size: 11px; = line-height: normal; font-family: Menlo;" class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" = class=3D"">lrwxrwxrwx 1 root root 10 May 9 15:15 = /dev/disk/by-id/dm-uuid-mpath-3600c0ff00026285a4613e55701000000 -> = ../../dm-4</span></div><div style=3D"margin: 0px; font-size: 11px; = line-height: normal; font-family: Menlo;" class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" = class=3D"">lrwxrwxrwx 1 root root 10 May 17 16:01 = /dev/disk/by-id/scsi-3600c0ff00026285a4613e55701000000 -> = ../../sdec</span></div><div style=3D"margin: 0px; font-size: 11px; = line-height: normal; font-family: Menlo;" class=3D""><br = class=3D""></div></div><div class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D"">In the = old sdk3, I was doing it that way:</span></div><div class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D""><br = class=3D""></span></div><div class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D""><a = href=3D"https://github.com/fbacchella/ovirtcmd/blob/master/ovlib/disks/__i= nit__.py#L35" = class=3D"">https://github.com/fbacchella/ovirtcmd/blob/master/ovlib/disks/= __init__.py#L35</a></span></div><div class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D""><br = class=3D""></span></div><div class=3D""><span = style=3D"font-variant-ligatures: no-common-ligatures" class=3D"">What = was called params is now a type.</span></div><div class=3D""><br = class=3D""><div><blockquote type=3D"cite" class=3D""><div class=3D"">Le = 17 mai 2017 =C3=A0 13:21, Guy Chen <<a = href=3D"mailto:guchen@redhat.com" class=3D"">guchen@redhat.com</a>> a = =C3=A9crit :</div><br class=3D"Apple-interchange-newline"><div = class=3D""><div class=3D""><div style=3D"font-family: 'times new roman', = 'new york', times, serif; font-size: 12pt;" class=3D""><div = class=3D""><span style=3D"font-size: 12pt;" class=3D""><br = class=3D""></span></div><div class=3D""><span style=3D"font-size: 12pt;" = class=3D"">I am trying to add direct LUN disk to a VM with python = ovirtsdk4 ( storage domain is iscsi ) .</span></div><div class=3D"">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 class=3D""><br= class=3D""></div><div class=3D""><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;" = class=3D"">def </span><span style=3D"background-color: rgb(255, 255, = 255); font-family: "DejaVu Sans Mono"; font-size: 9.2pt;" = class=3D"">add_VM_disk(</span><span data-mce-style=3D"color: #94558d;" = style=3D"font-family: "DejaVu Sans Mono"; font-size: 9.2pt; = color: rgb(148, 85, 141);" class=3D"">self</span><span = style=3D"background-color: rgb(255, 255, 255); font-family: "DejaVu = Sans Mono"; font-size: 9.2pt;" class=3D"">):</span></div><div = class=3D""><pre style=3D"background-color: #ffffff; font-family: 'DejaVu = Sans Mono'; font-size: 9.2pt;" data-mce-style=3D"background-color: = #ffffff; font-family: 'DejaVu Sans Mono'; font-size: 9.2pt;" = class=3D""><br class=3D""> vms_service =3D <span style=3D"color: = #94558d;" data-mce-style=3D"color: #94558d;" = class=3D"">self</span>.connection.system_service().vms_service()<br = class=3D""> vm =3D vms_service.list(<span style=3D"color: #660099;" = data-mce-style=3D"color: #660099;" class=3D"">search</span>=3D<span = style=3D"color: #008000; font-weight: bold;" data-mce-style=3D"color: = #008000; font-weight: bold;" class=3D"">'name=3Dmyvm'</span>)[<span = style=3D"color: #0000ff;" data-mce-style=3D"color: #0000ff;" = class=3D"">0</span>]<br class=3D""><div class=3D""><br class=3D""></div> = <span style=3D"color: #808080; font-style: italic;" = data-mce-style=3D"color: #808080; font-style: italic;" class=3D""># = Locate the service that manages the disk attachments of the virtual<br = class=3D""></span><span style=3D"color: #808080; font-style: italic;" = data-mce-style=3D"color: #808080; font-style: italic;" class=3D""> # = machine:<br class=3D""></span><span style=3D"color: #808080; font-style: = italic;" data-mce-style=3D"color: #808080; font-style: italic;" = class=3D""> </span>disk_attachments_service =3D = vms_service.vm_service(vm.id).disk_attachments_service()<br = class=3D""><div class=3D""><br class=3D""></div> <span style=3D"color: = #808080; font-style: italic;" data-mce-style=3D"color: #808080; = font-style: italic;" class=3D""># Use the "add" method of the disk = attachments service to add the disk.<br class=3D""></span><span = style=3D"color: #808080; font-style: italic;" data-mce-style=3D"color: = #808080; font-style: italic;" class=3D""> # Note that the size of the = disk, the `provisioned_size` attribute, is<br class=3D""></span><span = style=3D"color: #808080; font-style: italic;" data-mce-style=3D"color: = #808080; font-style: italic;" class=3D""> # specified in bytes, so to = create a disk of 10 GiB the value should<br class=3D""></span><span = style=3D"color: #808080; font-style: italic;" data-mce-style=3D"color: = #808080; font-style: italic;" class=3D""> # be 10 * 2^30.<br = class=3D""></span><span style=3D"color: #808080; font-style: italic;" = data-mce-style=3D"color: #808080; font-style: italic;" class=3D""> = </span><span style=3D"color: #808080;" data-mce-style=3D"color: = #808080;" class=3D"">disk_attachment </span>=3D = disk_attachments_service.add(<br class=3D""> = types.DiskAttachment(<br class=3D""> <span style=3D"color: = #660099;" data-mce-style=3D"color: #660099;" = class=3D"">disk</span>=3Dtypes.Disk(<br class=3D""> <span = style=3D"color: #660099;" data-mce-style=3D"color: #660099;" = class=3D"">name</span>=3D<span style=3D"color: #008000; font-weight: = bold;" data-mce-style=3D"color: #008000; font-weight: bold;" = class=3D"">'mydisk'</span>,<br class=3D""> <span = style=3D"color: #660099;" data-mce-style=3D"color: #660099;" = class=3D"">description</span>=3D<span style=3D"color: #008000; = font-weight: bold;" data-mce-style=3D"color: #008000; font-weight: = bold;" class=3D"">'My disk'</span>,<br class=3D""> <span = style=3D"color: #660099;" data-mce-style=3D"color: #660099;" = class=3D"">format</span>=3Dtypes.DiskFormat.COW,<br class=3D""> = <span style=3D"color: #660099;" data-mce-style=3D"color: #660099;" = class=3D"">provisioned_size</span>=3D<span style=3D"color: #0000ff;" = data-mce-style=3D"color: #0000ff;" class=3D"">10 </span>* <span = style=3D"color: #0000ff;" data-mce-style=3D"color: #0000ff;" class=3D"">2 = </span>** <span style=3D"color: #0000ff;" data-mce-style=3D"color: = #0000ff;" class=3D"">30</span>,<br class=3D""> ),<br = class=3D""> <span style=3D"color: #660099;" = data-mce-style=3D"color: #660099;" = class=3D"">interface</span>=3Dtypes.DiskInterface.VIRTIO,<br class=3D""> = <span style=3D"color: #660099;" data-mce-style=3D"color: = #660099;" class=3D"">bootable</span>=3D<span style=3D"color: #000080; = font-weight: bold;" data-mce-style=3D"color: #000080; font-weight: = bold;" class=3D"">False</span>,<br class=3D""> <span = style=3D"color: #660099;" data-mce-style=3D"color: #660099;" = class=3D"">active</span>=3D<span style=3D"color: #000080; font-weight: = bold;" data-mce-style=3D"color: #000080; font-weight: bold;" = class=3D"">True</span>,<br class=3D""> ),<br class=3D""> = )</pre></div><div class=3D""><br class=3D""></div><div class=3D""><br = class=3D""></div><div class=3D""><br = class=3D""></div></div></div>_____________________________________________= __<br class=3D"">Users mailing list<br class=3D""><a = href=3D"mailto:Users@ovirt.org" class=3D"">Users@ovirt.org</a><br = class=3D"">http://lists.ovirt.org/mailman/listinfo/users<br = class=3D""></div></blockquote></div><br class=3D""></div></body></html>= --Apple-Mail=_287C8533-0DD4-49B1-824D-8C8E893889AC--

I've sent following example to our Python SDK, feel free to try and review: https://gerrit.ovirt.org/#/c/77003/1 Also you may checkout relevant Ansible module, which support this functionality as well: http://docs.ansible.com/ansible/ovirt_disks_module.html On Wed, May 17, 2017 at 1:21 PM, Guy Chen <guchen@redhat.com> wrote:
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, ), )
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

That works, thank you ! Regards, ----------------------------- Guy Chen, RHV Performance O: +972.9.7692152 M: +972.52.8545202 guchen@redhat.com ----- Original Message -----
From: "Ondra Machacek" <omachace@redhat.com> To: "Guy Chen" <guchen@redhat.com> Cc: "users" <users@ovirt.org> Sent: Friday, May 19, 2017 9:22:30 AM Subject: Re: [ovirt-users] add direct LUN disk to a VM with python SDK
I've sent following example to our Python SDK, feel free to try and review:
https://gerrit.ovirt.org/#/c/77003/1
Also you may checkout relevant Ansible module, which support this functionality as well:
http://docs.ansible.com/ansible/ovirt_disks_module.html
On Wed, May 17, 2017 at 1:21 PM, Guy Chen <guchen@redhat.com> wrote:
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, ), )
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (3)
-
Fabrice Bacchella
-
Guy Chen
-
Ondra Machacek