#NEWLINE# def create_vbd( session , vm_ref , vdi_ref , userdevice , vbd_type = 'disk' , read_only = False , bootable = False , osvol = False , empty = False , unpluggable = True ) : #NEWLINE# #INDENT# 'Create a VBD record and returns its reference.' #NEWLINE# vbd_rec = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# vbd_rec [ 'VM' ] = vm_ref #NEWLINE# if ( vdi_ref is None ) : #NEWLINE# #INDENT# vdi_ref = 'OpaqueRef:NULL' #NEWLINE# #UNINDENT# vbd_rec [ 'VDI' ] = vdi_ref #NEWLINE# vbd_rec [ 'userdevice' ] = str ( osvol ) #NEWLINE# vbd_rec [ 'bootable' ] = bootable #NEWLINE# vbd_rec [ 'mode' ] = ( ( read_only and 'RO' ) or 'RW' ) #NEWLINE# vbd_rec [ 'type' ] = vbd_type #NEWLINE# vbd_rec [ 'unpluggable' ] = unpluggable #NEWLINE# vbd_rec [ 'empty' ] = empty #NEWLINE# vbd_rec [ 'other_config' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# vbd_rec [ 'qos_algorithm_type' ] = '' #NEWLINE# vbd_rec [ 'qos_algorithm_params' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# vbd_rec [ 'qos_supported_algorithms' ] = [ ] #NEWLINE# LOG . debug ( 'Creating %(vbd_type)s-type VBD for VM %(vm_ref)s, VDI %(vdi_ref)s ... ' , { #NEWLINE# #INDENT# 'vbd_type' : vbd_type , #NEWLINE# 'vm_ref' : vm_ref , #NEWLINE# 'vdi_ref' : vdi_ref , #NEWLINE# #UNINDENT# } ) #NEWLINE# vbd_ref = session . call_xenapi ( 'VBD.create' , vbd_rec ) #NEWLINE# LOG . debug ( 'Created VBD %(vbd_ref)s for VM %(vm_ref)s, VDI %(vdi_ref)s.' , { #NEWLINE# #INDENT# 'vbd_ref' : vbd_ref , #NEWLINE# 'vm_ref' : vm_ref , #NEWLINE# 'vdi_ref' : vdi_ref , #NEWLINE# #UNINDENT# } ) #NEWLINE# if osvol : #NEWLINE# #INDENT# session . call_xenapi ( 'VBD.add_to_other_config' , vbd_ref , 'osvol' , 'True' ) #NEWLINE# #UNINDENT# return vbd_ref