def stubout_fetch_disk_image(stubs, raise_failure=False):
 def _fake_fetch_disk_image(context, session, instance, name_label, image, image_type):
  if raise_failure:
   raise XenAPI.Failure('Test Exception raised by fake fetch_image_glance_disk')
  elif (image_type == vm_utils.ImageType.KERNEL):
   filename = 'kernel'
  elif (image_type == vm_utils.ImageType.RAMDISK):
   filename = 'ramdisk'
  else:
   filename = 'unknown'
  vdi_type = vm_utils.ImageType.to_string(image_type)
  return {vdi_type: dict(uuid=None, file=filename)}
 stubs.Set(vm_utils, '_fetch_disk_image', _fake_fetch_disk_image)

def stubout_fetch_disk_image ( stubs , raise_failure = False ) : def _fake_fetch_disk_image ( context , session , instance , name_label , image , image_type ) : if raise_failure : raise XenAPI . Failure ( 'Test Exception raised by fake fetch_image_glance_disk' ) elif ( image_type == vm_utils . ImageType . KERNEL ) : filename = 'kernel' elif ( image_type == vm_utils . ImageType . RAMDISK ) : filename = 'ramdisk' else : filename = 'unknown' vdi_type = vm_utils . ImageType . to_string ( image_type ) return { vdi_type : dict ( uuid = None , file = filename ) } stubs . Set ( vm_utils , '_fetch_disk_image' , _fake_fetch_disk_image )
simulates a failure in fetch image_glance_disk .