def _snapshot_attached_here_impl(session, instance, vm_ref, label, userdevice, post_snapshot_callback):
 LOG.debug('Starting snapshot for VM', instance=instance)
 (vm_vdi_ref, vm_vdi_rec) = get_vdi_for_vm_safely(session, vm_ref, userdevice)
 chain = _walk_vdi_chain(session, vm_vdi_rec['uuid'])
 vdi_uuid_chain = [vdi_rec['uuid'] for vdi_rec in chain]
 sr_ref = vm_vdi_rec['SR']
 _delete_snapshots_in_vdi_chain(session, instance, vdi_uuid_chain, sr_ref)
 snapshot_ref = _vdi_snapshot(session, vm_vdi_ref)
 if (post_snapshot_callback is not None):
  post_snapshot_callback(task_state=task_states.IMAGE_PENDING_UPLOAD)
 try:
  _wait_for_vhd_coalesce(session, instance, sr_ref, vm_vdi_ref, vdi_uuid_chain)
  snapshot_uuid = _vdi_get_uuid(session, snapshot_ref)
  chain = _walk_vdi_chain(session, snapshot_uuid)
  vdi_uuids = [vdi_rec['uuid'] for vdi_rec in chain]
  (yield vdi_uuids)
 finally:
  safe_destroy_vdis(session, [snapshot_ref])

def _snapshot_attached_here_impl ( session , instance , vm_ref , label , userdevice , post_snapshot_callback ) : LOG . debug ( 'Starting snapshot for VM' , instance = instance ) ( vm_vdi_ref , vm_vdi_rec ) = get_vdi_for_vm_safely ( session , vm_ref , userdevice ) chain = _walk_vdi_chain ( session , vm_vdi_rec [ 'uuid' ] ) vdi_uuid_chain = [ vdi_rec [ 'uuid' ] for vdi_rec in chain ] sr_ref = vm_vdi_rec [ 'SR' ] _delete_snapshots_in_vdi_chain ( session , instance , vdi_uuid_chain , sr_ref ) snapshot_ref = _vdi_snapshot ( session , vm_vdi_ref ) if ( post_snapshot_callback is not None ) : post_snapshot_callback ( task_state = task_states . IMAGE_PENDING_UPLOAD ) try : _wait_for_vhd_coalesce ( session , instance , sr_ref , vm_vdi_ref , vdi_uuid_chain ) snapshot_uuid = _vdi_get_uuid ( session , snapshot_ref ) chain = _walk_vdi_chain ( session , snapshot_uuid ) vdi_uuids = [ vdi_rec [ 'uuid' ] for vdi_rec in chain ] ( yield vdi_uuids ) finally : safe_destroy_vdis ( session , [ snapshot_ref ] )
snapshot the root disk only .