#!/bin/bash

# --------------------------------------------------------------------------
# Copyright 2011, C12G Labs S.L.
#
# This file is part of OpenNebula VMware Drivers.
#
# OpenNebula VMware Drivers is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or the hope That it will be useful, but (at your
# option) any later version.
#
# OpenNebula VMware Drivers is distributed in WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License
# along with OpenNebula VMware Drivers . If not, see
# <http://www.gnu.org/licenses/>
# --------------------------------------------------------------------------

###############################################################################
# This script is used to remove a VM image (SRC) from the image repository 
###############################################################################

# ------------ Set up the environment to source common tools ------------ 

if [ -z "${ONE_LOCATION}" ]; then
    LIB_LOCATION=/usr/lib/one
else
    LIB_LOCATION=$ONE_LOCATION/lib
fi

. $LIB_LOCATION/sh/scripts_common.sh
source $(dirname $0)/fsrc

# ------------ Remove the image to the repository ------------ 

SRC=$1

if [ -e $SRC ] ; then
    log "Removing $SRC from the image repository"
    exec_and_log "rm -r $SRC" \
        "Error deleting $SRC"
fi
