mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Bug 11931: Add quotes to snapshot name and volume name. Fixed create template from snapshot also by adding quotes
Status 11931: resolved fixed Reviewed-By: Nitin Conflicts: scripts/storage/qcow2/createtmplt.sh
This commit is contained in:
parent
cbc47b9021
commit
606902ff09
@ -97,28 +97,28 @@ uncompress() {
|
|||||||
|
|
||||||
create_from_file() {
|
create_from_file() {
|
||||||
local tmpltfs=$1
|
local tmpltfs=$1
|
||||||
local tmpltimg=$2
|
local tmpltimg="$2"
|
||||||
local tmpltname=$3
|
local tmpltname=$3
|
||||||
if [ -b $tmpltimg ]; then
|
if [ -b $tmpltimg ]; then
|
||||||
$qemu-img convert -f raw -O qcow2 $tmpltimg /$tmpltfs/$tmpltname
|
$qemu-img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname
|
||||||
else
|
else
|
||||||
$qemu_img convert -f qcow2 -O qcow2 $tmpltimg /$tmpltfs/$tmpltname >& /dev/null
|
$qemu_img convert -f qcow2 -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname >& /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$cleanup" == "true" ]
|
if [ "$cleanup" == "true" ]
|
||||||
then
|
then
|
||||||
rm -f $tmpltimg
|
rm -f "$tmpltimg"
|
||||||
fi
|
fi
|
||||||
chmod a+r /$tmpltfs/$tmpltname
|
chmod a+r /$tmpltfs/$tmpltname
|
||||||
}
|
}
|
||||||
|
|
||||||
create_from_snapshot() {
|
create_from_snapshot() {
|
||||||
local tmpltImg=$1
|
local tmpltImg="$1"
|
||||||
local snapshotName=$2
|
local snapshotName="$2"
|
||||||
local tmpltfs=$3
|
local tmpltfs=$3
|
||||||
local tmpltname=$4
|
local tmpltname=$4
|
||||||
|
|
||||||
$qemu_img convert -f qcow2 -O qcow2 -s $snapshotName $tmpltImg /$tmpltfs/$tmpltname >& /dev/null
|
$qemu_img convert -f qcow2 -O qcow2 -s "$snapshotName" "$tmpltImg" /$tmpltfs/$tmpltname >& /dev/null
|
||||||
if [ $? -gt 0 ]
|
if [ $? -gt 0 ]
|
||||||
then
|
then
|
||||||
printf "Failed to create template /$tmplfs/$tmpltname from snapshot $snapshotName on disk $tmpltImg "
|
printf "Failed to create template /$tmplfs/$tmpltname from snapshot $snapshotName on disk $tmpltImg "
|
||||||
@ -185,7 +185,7 @@ then
|
|||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmpltimg=$(uncompress $tmpltimg)
|
tmpltimg=$(uncompress "$tmpltimg")
|
||||||
if [ $? -ne 0 ]
|
if [ $? -ne 0 ]
|
||||||
then
|
then
|
||||||
printf "failed to uncompress $tmpltimg\n"
|
printf "failed to uncompress $tmpltimg\n"
|
||||||
@ -193,9 +193,9 @@ fi
|
|||||||
|
|
||||||
if [ "$sflag" == "1" ]
|
if [ "$sflag" == "1" ]
|
||||||
then
|
then
|
||||||
create_from_snapshot $tmpltimg $snapshotName $tmpltfs $tmpltname
|
create_from_snapshot "$tmpltimg" "$snapshotName" $tmpltfs $tmpltname
|
||||||
else
|
else
|
||||||
create_from_file $tmpltfs $tmpltimg $tmpltname
|
create_from_file $tmpltfs "$tmpltimg" $tmpltname
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch /$tmpltfs/template.properties
|
touch /$tmpltfs/template.properties
|
||||||
@ -209,7 +209,7 @@ echo "description=$descr" >> /$tmpltfs/template.properties
|
|||||||
|
|
||||||
if [ "$cleanup" == "true" ]
|
if [ "$cleanup" == "true" ]
|
||||||
then
|
then
|
||||||
rm -f $tmpltimg
|
rm -f "$tmpltimg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@ -43,7 +43,7 @@ fi
|
|||||||
|
|
||||||
create_snapshot() {
|
create_snapshot() {
|
||||||
local disk=$1
|
local disk=$1
|
||||||
local snapshotname=$2
|
local snapshotname="$2"
|
||||||
local failed=0
|
local failed=0
|
||||||
|
|
||||||
if [ -b "${disk}" ] && lvm lvs "${disk}" >/dev/null 2>&1; then
|
if [ -b "${disk}" ] && lvm lvs "${disk}" >/dev/null 2>&1; then
|
||||||
@ -160,7 +160,7 @@ destroy_snapshot() {
|
|||||||
|
|
||||||
rollback_snapshot() {
|
rollback_snapshot() {
|
||||||
local disk=$1
|
local disk=$1
|
||||||
local snapshotname=$2
|
local snapshotname="$2"
|
||||||
local failed=0
|
local failed=0
|
||||||
|
|
||||||
$qemu_img snapshot -a $snapshotname $disk
|
$qemu_img snapshot -a $snapshotname $disk
|
||||||
@ -266,11 +266,11 @@ done
|
|||||||
|
|
||||||
if [ "$cflag" == "1" ]
|
if [ "$cflag" == "1" ]
|
||||||
then
|
then
|
||||||
create_snapshot $pathval $snapshot
|
create_snapshot $pathval "$snapshot"
|
||||||
exit $?
|
exit $?
|
||||||
elif [ "$dflag" == "1" ]
|
elif [ "$dflag" == "1" ]
|
||||||
then
|
then
|
||||||
destroy_snapshot $pathval $snapshot $deleteDir
|
destroy_snapshot $pathval "$snapshot" $deleteDir
|
||||||
exit $?
|
exit $?
|
||||||
elif [ "$bflag" == "1" ]
|
elif [ "$bflag" == "1" ]
|
||||||
then
|
then
|
||||||
@ -278,7 +278,7 @@ then
|
|||||||
exit $?
|
exit $?
|
||||||
elif [ "$rflag" == "1" ]
|
elif [ "$rflag" == "1" ]
|
||||||
then
|
then
|
||||||
rollback_snapshot $pathval $snapshot $destPath
|
rollback_snapshot $pathval "$snapshot" $destPath
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user