mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-04 00:02:37 +01:00
fix delete snapshot
This commit is contained in:
parent
3eb8ae42ee
commit
ba0493e2f0
@ -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());
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user