def create_vbd(session, vm_ref, vdi_ref, userdevice, vbd_type='disk', read_only=False, bootable=False, osvol=False):
 vbd_rec = {}
 vbd_rec['VM'] = vm_ref
 vbd_rec['VDI'] = vdi_ref
 vbd_rec['userdevice'] = str(userdevice)
 vbd_rec['bootable'] = bootable
 vbd_rec['mode'] = ((read_only and 'RO') or 'RW')
 vbd_rec['type'] = vbd_type
 vbd_rec['unpluggable'] = True
 vbd_rec['empty'] = False
 vbd_rec['other_config'] = {}
 vbd_rec['qos_algorithm_type'] = ''
 vbd_rec['qos_algorithm_params'] = {}
 vbd_rec['qos_supported_algorithms'] = []
 LOG.debug(_('Creating %(vbd_type)s-type VBD for VM %(vm_ref)s, VDI %(vdi_ref)s ... '), locals())
 vbd_ref = session.call_xenapi('VBD.create', vbd_rec)
 LOG.debug(_('Created VBD %(vbd_ref)s for VM %(vm_ref)s, VDI %(vdi_ref)s.'), locals())
 if osvol:
  session.call_xenapi('VBD.add_to_other_config', vbd_ref, 'osvol', 'True')
 return vbd_ref

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