[ovirt-users] add direct LUN disk to a VM with python SDK

Guy Chen guchen at redhat.com
Wed May 17 11:21:54 UTC 2017


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 , 
), 
) 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20170517/225f681b/attachment.html>


More information about the Users mailing list