Revision d71f59e9 snf-image-host/common.sh.in

b/snf-image-host/common.sh.in
27 27
PROGRESS_MONITOR="snf-progress-monitor"
28 28

  
29 29
progress_monitor_support="@progress_monitor_support@"
30
pithos_backend_support="@pithos_backend_support@"
31
network_backend_support="@network_backend_support@"
30 32

  
31 33
CLEANUP=( )
32 34

  
......
181 183
    umount "$target"
182 184
}
183 185

  
186
get_backend_type() {
187
    local id=$1
188

  
189
    if [[ "$id" =~ ^pithos: ]]; then
190
        if [ "$pithos_backend_support" = "yes" ]; then
191
            echo "pithos"
192
        else
193
            log_error "Retrieving images from pithos is not supported"
194
            exit 1
195
        fi
196
    elif [[ "$id" =~ ^(http|ftp)s?: ]]; then
197
        if [ "$network_backend_support" = "yes" ]; then
198
            echo "network";
199
        else
200
            log_error "Retrieving images from the network is not supported."
201
            exit 1
202
        fi
203
    else
204
        echo "local";
205
    fi
206
}
207

  
184 208
# this one is only to be called by create
185 209
ganeti_os_main() {
186 210
    if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
......
192 216
        get_api10_arguments
193 217
    elif [ "$OS_API_VERSION" = "20" ]; then
194 218
        get_api20_arguments
195
        IMAGE_NAME=$IMG_ID
196
        IMAGE_TYPE=$IMG_FORMAT
219
        IMAGE_NAME="$IMG_ID"
220
        IMAGE_TYPE="$IMG_FORMAT"
221
        BACKEND_TYPE=$(get_backend_type $IMG_ID)
197 222
    else
198 223
        log_error "Unknown OS API VERSION $OS_API_VERSION"
199 224
        exit 1
......
279 304
: ${HELPER_CACHE_FILE:="@HELPER_DIR@/cache.tar"}
280 305
: ${HELPER_EXTRA_PKGS:="linux-image-amd64,e2fsprogs,ntfs-3g,ntfsprogs,xmlstarlet,python,parted,reglookup,chntpw"}
281 306
: ${HELPER_MIRROR:=""}
282

  
307
: ${PITHOS_DB:="sqlite:////@localstatedir@/lib/pithos/backend.db"}
308
: ${PITHOS_DATA:="@localstatedir@/lib/pithos/"}
283 309

  
284 310
SCRIPT_NAME=$(basename $0)
285 311

  

Also available in: Unified diff