def find_vbd_by_number(session, vm_ref, number):
 vbd_refs = session.call_xenapi('VM.get_VBDs', vm_ref)
 if vbd_refs:
  for vbd_ref in vbd_refs:
   try:
    vbd_rec = session.call_xenapi('VBD.get_record', vbd_ref)
    if (vbd_rec['userdevice'] == str(number)):
     return vbd_ref
   except session.XenAPI.Failure as exc:
    LOG.exception(exc)
 raise volume_utils.StorageError((_('VBD not found in instance %s') % vm_ref))

def find_vbd_by_number ( session , vm_ref , number ) : vbd_refs = session . call_xenapi ( 'VM.get_VBDs' , vm_ref ) if vbd_refs : for vbd_ref in vbd_refs : try : vbd_rec = session . call_xenapi ( 'VBD.get_record' , vbd_ref ) if ( vbd_rec [ 'userdevice' ] == str ( number ) ) : return vbd_ref except session . XenAPI . Failure as exc : LOG . exception ( exc ) raise volume_utils . StorageError ( ( _ ( 'VBD not found in instance %s' ) % vm_ref ) )
get the vbd reference from the device number .