From 2eab0ed9ce606558c13a83eeef4e82c2a035094f Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 14 Sep 2012 23:59:07 +0200 Subject: [PATCH] bug #1345: Get size for marketplace URLS from image metadata --- src/datastore_mad/remotes/libfs.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/datastore_mad/remotes/libfs.sh b/src/datastore_mad/remotes/libfs.sh index 0f625ee90d..a4fea5ea2f 100644 --- a/src/datastore_mad/remotes/libfs.sh +++ b/src/datastore_mad/remotes/libfs.sh @@ -91,6 +91,21 @@ EOF function fs_size { case $1 in + http://*/download|https://*/download) + BASE_URL=${1%%/download} + HEADERS=`wget -S --spider --no-check-certificate $BASE_URL 2>&1` + + echo $HEADERS | grep "opennebula_marketplace" > /dev/null 2>&1 + + if [ $? -eq 0 ]; then + #URL is from market place + SIZE=`wget -O - -S --no-check-certificate $BASE_URL 2>&1 | grep size | cut -d: -f2` + else + #Not a marketplace URL + SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2` + fi + error=$? + ;; http://*|https://*) SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2` error=$?