def _delete_instance_files(self, instance):
    context = nova_context.get_admin_context(read_deleted='yes')
    inst_obj = objects.Instance.get_by_uuid(context, instance['uuid'])
    attempts = int(inst_obj.system_metadata.get('clean_attempts', '0'))
    success = self.delete_instance_files(inst_obj)
    inst_obj.system_metadata['clean_attempts'] = str((attempts + 1))
    if success:
        inst_obj.cleaned = True
    inst_obj.save(context)
def _delete_instance_files(self, instance):
    context = nova_context.get_admin_context(read_deleted='yes')
    inst_obj = objects.Instance.get_by_uuid(context, instance['uuid'])
    attempts = int(inst_obj.system_metadata.get('clean_attempts', '0'))
    success = self.delete_instance_files(inst_obj)
    inst_obj.system_metadata['clean_attempts'] = str((attempts + 1))
    if success:
        inst_obj.cleaned = True
    inst_obj.save(context)