mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
set size in createtmplt.sh and remove unused properties
This commit is contained in:
parent
daf569e844
commit
5e80d9b31f
@ -3,7 +3,7 @@
|
|||||||
# createtmplt.sh -- install a template
|
# createtmplt.sh -- install a template
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf "Usage: %s: -t <template-fs> -n <templatename> -f <root disk file> -s <size in Gigabytes> -c <md5 cksum> -d <descr> -h [-u]\n" $(basename $0) >&2
|
printf "Usage: %s: -t <template-fs> -n <templatename> -f <root disk file> -c <md5 cksum> -d <descr> -h [-u]\n" $(basename $0) >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ uncompress() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm $1
|
rm -f $1
|
||||||
printf $tmpfile
|
printf $tmpfile
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -77,16 +77,10 @@ create_from_file() {
|
|||||||
local tmpltfs=$1
|
local tmpltfs=$1
|
||||||
local tmpltimg=$2
|
local tmpltimg=$2
|
||||||
local tmpltname=$3
|
local tmpltname=$3
|
||||||
local volsize=$4
|
|
||||||
local cleanup=$5
|
|
||||||
|
|
||||||
#copy the file to the disk
|
#copy the file to the disk
|
||||||
mv $tmpltimg /$tmpltfs/$tmpltname
|
mv $tmpltimg /$tmpltfs/$tmpltname
|
||||||
|
|
||||||
# if [ "$cleanup" == "true" ]
|
|
||||||
# then
|
|
||||||
# rm -f $tmpltimg
|
|
||||||
# fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tflag=
|
tflag=
|
||||||
@ -112,7 +106,6 @@ do
|
|||||||
tmpltimg="$OPTARG"
|
tmpltimg="$OPTARG"
|
||||||
;;
|
;;
|
||||||
s) sflag=1
|
s) sflag=1
|
||||||
volsize="$OPTARG"
|
|
||||||
;;
|
;;
|
||||||
c) cflag=1
|
c) cflag=1
|
||||||
cksum="$OPTARG"
|
cksum="$OPTARG"
|
||||||
@ -170,27 +163,9 @@ then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# need the 'G' suffix on volume size
|
imgsize=$(ls -l $tmpltimg2| awk -F" " '{print $5}')
|
||||||
if [ ${volsize:(-1)} != G ]
|
|
||||||
then
|
|
||||||
volsize=${volsize}G
|
|
||||||
fi
|
|
||||||
|
|
||||||
#determine source file size -- it needs to be less than or equal to volsize
|
create_from_file $tmpltfs $tmpltimg2 $tmpltname
|
||||||
imgsize=$(ls -lh $tmpltimg2| awk -F" " '{print $5}')
|
|
||||||
if [ ${imgsize:(-1)} == G ]
|
|
||||||
then
|
|
||||||
imgsize=${imgsize%G} #strip out the G
|
|
||||||
imgsize=${imgsize%.*} #...and any decimal part
|
|
||||||
let imgsize=imgsize+1 # add 1 to compensate for decimal part
|
|
||||||
volsizetmp=${volsize%G}
|
|
||||||
if [ $volsizetmp -lt $imgsize ]
|
|
||||||
then
|
|
||||||
volsize=${imgsize}G
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
create_from_file $tmpltfs $tmpltimg2 $tmpltname $volsize $cleanup
|
|
||||||
|
|
||||||
touch /$tmpltfs/template.properties
|
touch /$tmpltfs/template.properties
|
||||||
rollback_if_needed $tmpltfs $? "Failed to create template.properties file"
|
rollback_if_needed $tmpltfs $? "Failed to create template.properties file"
|
||||||
@ -198,13 +173,10 @@ echo -n "" > /$tmpltfs/template.properties
|
|||||||
|
|
||||||
today=$(date '+%m_%d_%Y')
|
today=$(date '+%m_%d_%Y')
|
||||||
echo "filename=$tmpltname" > /$tmpltfs/template.properties
|
echo "filename=$tmpltname" > /$tmpltfs/template.properties
|
||||||
echo "snapshot.name=$today" >> /$tmpltfs/template.properties
|
|
||||||
echo "description=$descr" >> /$tmpltfs/template.properties
|
echo "description=$descr" >> /$tmpltfs/template.properties
|
||||||
echo "name=$tmpltname" >> /$tmpltfs/template.properties
|
|
||||||
echo "checksum=$cksum" >> /$tmpltfs/template.properties
|
echo "checksum=$cksum" >> /$tmpltfs/template.properties
|
||||||
echo "hvm=$hvm" >> /$tmpltfs/template.properties
|
echo "hvm=$hvm" >> /$tmpltfs/template.properties
|
||||||
echo "volume.size=$volsize" >> /$tmpltfs/template.properties
|
echo "size=$imgsize" >> /$tmpltfs/template.properties
|
||||||
|
|
||||||
|
|
||||||
if [ "$cleanup" == "true" ]
|
if [ "$cleanup" == "true" ]
|
||||||
then
|
then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user