def remove_old_snapshots(session, instance, vm_ref):
 LOG.debug('Starting remove_old_snapshots for VM', instance=instance)
 (vm_vdi_ref, vm_vdi_rec) = get_vdi_for_vm_safely(session, vm_ref)
 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)

def remove_old_snapshots ( session , instance , vm_ref ) : LOG . debug ( 'Starting remove_old_snapshots for VM' , instance = instance ) ( vm_vdi_ref , vm_vdi_rec ) = get_vdi_for_vm_safely ( session , vm_ref ) 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 )
see if there is an snapshot present that should be removed .