fix delete snapshot

This commit is contained in:
edison 2010-09-07 16:42:58 -07:00
parent 3eb8ae42ee
commit ba0493e2f0
3 changed files with 28 additions and 8 deletions

View File

@ -1311,7 +1311,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
try {
StoragePool secondaryStoragePool = getNfsSPbyURI(_conn, new URI(secondaryStoragePoolURL));
String ssPmountPath = _mountPoint + File.separator + secondaryStoragePool.getUUIDString();
snapshotDestPath = ssPmountPath + File.separator + dcId + File.separator + "snapshots" + File.separator + accountId + File.separator + volumeId;
snapshotDestPath = ssPmountPath + File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId;
Script command = new Script(_manageSnapshotPath, _timeout, s_logger);
command.add("-b", snapshotPath);
command.add("-n", snapshotName);
@ -1367,7 +1367,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
try {
StoragePool secondaryStoragePool = getNfsSPbyURI(_conn, new URI(cmd.getSecondaryStoragePoolURL()));
String ssPmountPath = _mountPoint + File.separator + secondaryStoragePool.getUUIDString();
String snapshotDestPath = ssPmountPath + File.separator + dcId + File.separator + "snapshots" + File.separator + accountId + File.separator + volumeId;
String snapshotDestPath = ssPmountPath + File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId;
final Script command = new Script(_manageSnapshotPath, _timeout, s_logger);
command.add("-d", snapshotDestPath);
@ -1389,11 +1389,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
try {
StoragePool secondaryStoragePool = getNfsSPbyURI(_conn, new URI(cmd.getSecondaryStoragePoolURL()));
String ssPmountPath = _mountPoint + File.separator + secondaryStoragePool.getUUIDString();
String snapshotDestPath = ssPmountPath + File.separator + dcId + File.separator + "snapshots" + File.separator + accountId + File.separator + volumeId;
String snapshotDestPath = ssPmountPath + File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId;
final Script command = new Script(_manageSnapshotPath, _timeout, s_logger);
command.add("-d", snapshotDestPath);
command.add("-n", cmd.getSnapshotName());
command.add("-f");
command.execute();
} catch (LibvirtException e) {
return new Answer(cmd, false, e.toString());

View File

@ -78,7 +78,7 @@ create_from_file() {
then
rm -f $tmpltimg
fi
chmod +r /$tmpltfs/$tmpltname
chmod a+r /$tmpltfs/$tmpltname
}
create_from_snapshot() {
@ -94,7 +94,7 @@ create_from_snapshot() {
exit 2
fi
chmod +r /$tmpltfs/$tmpltname
chmod a+r /$tmpltfs/$tmpltname
}
tflag=
@ -168,7 +168,7 @@ else
fi
touch /$tmpltfs/template.properties
chmod +r /$tmpltfs/template.properties
chmod a+r /$tmpltfs/template.properties
echo -n "" > /$tmpltfs/template.properties
today=$(date '+%m_%d_%Y')

View File

@ -43,8 +43,24 @@ create_snapshot() {
destroy_snapshot() {
local disk=$1
local snapshotname=$2
local deleteDir=$3
local failed=0
if [ -d $disk ]
then
if [ -f $disk/$snapshotname ]
then
rm -rf $disk/$snapshotname >& /dev/null
fi
if [ "$deleteDir" == "1" ]
then
rm -rf %disk >& /dev/null
fi
return $failed
fi
if [ ! -f $disk ]
then
failed=1
@ -119,8 +135,9 @@ nflag=
pathval=
snapshot=
tmplName=
deleteDir=
while getopts 'c:d:r:n:b:p:t:' OPTION
while getopts 'c:d:r:n:b:p:t:f' OPTION
do
case $OPTION in
c) cflag=1
@ -142,6 +159,8 @@ do
;;
t) tmplName="$OPTARG"
;;
f) deleteDir=1
;;
?) usage
;;
esac
@ -154,7 +173,7 @@ then
exit $?
elif [ "$dflag" == "1" ]
then
destroy_snapshot $pathval $snapshot
destroy_snapshot $pathval $snapshot $deleteDir
exit $?
elif [ "$bflag" == "1" ]
then