def delete_instance_files(self, instance):
    target = libvirt_utils.get_instance_path(instance)
    target_resize = (target + '_resize')
    target_del = (target + '_del')
    for i in six.moves.range(2):
        try:
            utils.execute('mv', target, target_del)
            break
        except Exception:
            pass
        try:
            utils.execute('mv', target_resize, target_del)
            break
        except Exception:
            pass
    remaining_path = None
    for p in (target, target_resize):
        if os.path.exists(p):
            remaining_path = p
            break
    if ((not remaining_path) and os.path.exists(target_del)):
        LOG.info(_LI('Deleting instance files %s'), target_del, instance=instance)
        remaining_path = target_del
        try:
            shutil.rmtree(target_del)
        except OSError as e:
            LOG.error(_LE('Failed to cleanup directory %(target)s: %(e)s'), {'target': target_del, 'e': e}, instance=instance)
    if (remaining_path and os.path.exists(remaining_path)):
        LOG.info(_LI('Deletion of %s failed'), remaining_path, instance=instance)
        return False
    LOG.info(_LI('Deletion of %s complete'), target_del, instance=instance)
    return True
def delete_instance_files(self, instance):
    target = libvirt_utils.get_instance_path(instance)
    target_resize = (target + '_resize')
    target_del = (target + '_del')
    for i in six.moves.range(2):
        try:
            utils.execute('mv', target, target_del)
            break
        except Exception:
            pass
        try:
            utils.execute('mv', target_resize, target_del)
            break
        except Exception:
            pass
    remaining_path = None
    for p in (target, target_resize):
        if os.path.exists(p):
            remaining_path = p
            break
    if ((not remaining_path) and os.path.exists(target_del)):
        LOG.info(_LI('Deleting instance files %s'), target_del, instance=instance)
        remaining_path = target_del
        try:
            shutil.rmtree(target_del)
        except OSError as e:
            LOG.error(_LE('Failed to cleanup directory %(target)s: %(e)s'), {'target': target_del, 'e': e}, instance=instance)
    if (remaining_path and os.path.exists(remaining_path)):
        LOG.info(_LI('Deletion of %s failed'), remaining_path, instance=instance)
        return False
    LOG.info(_LI('Deletion of %s complete'), target_del, instance=instance)
    return True