[ovirt-users] add direct LUN disk to a VM with python SDK
Fabrice Bacchella
fabrice.bacchella at orange.fr
Wed May 17 14:55:04 UTC 2017
Did you have a look at:
http://ovirt.github.io/ovirt-engine-sdk/master/services.m.html#ovirtsdk4.services.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.types.LogicalUnit <http://ovirt.github.io/ovirt-engine-sdk/master/types.m.html#ovirtsdk4.types.LogicalUnit>
In my case a attached LUN is exported as:
<disk href="/ovirt-engine/api/disks/638676d4-01f3-422c-b14b-0e8f4ba0529d" id="638676d4-01f3-422c-b14b-0e8f4ba0529d">
<alias>xxx</alias>
<description></description>
<lun_storage id="3600c0ff00026285a4613e55701000000">
<logical_units>
<logical_unit id="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__.py#L35>
What was called params is now a type.
> Le 17 mai 2017 à 13:21, Guy Chen <guchen at redhat.com> a écrit :
>
>
> 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 at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20170517/d6da7bb0/attachment.html>
More information about the Users
mailing list