CLOUDSTACK-4190:[Object_store_refactor] volume should be deleted from

staging storage after successfule volume migration, specially handle
DeleteVolume command for Vmware volume structure in secondary storage.
This commit is contained in:
Min Chen 2013-09-06 14:33:34 -07:00
parent 0e695ec7e0
commit bf83efcf4b
1 changed files with 11 additions and 3 deletions

View File

@ -1775,7 +1775,15 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
parent += File.separator;
}
String absoluteVolumePath = parent + relativeVolumePath;
File tmpltParent = new File(absoluteVolumePath).getParentFile();
File volPath = new File(absoluteVolumePath);
File tmpltParent = null;
if (volPath.exists() && volPath.isDirectory()) {
// for vmware, absoluteVolumePath represents a directory where volume files are located.
tmpltParent = volPath;
} else{
// for other hypervisors, the volume .vhd or .qcow2 file path is passed
tmpltParent = new File(absoluteVolumePath).getParentFile();
}
String details = null;
if (!tmpltParent.exists()) {
details = "volume parent directory " + tmpltParent.getName() + " doesn't exist";
@ -1806,7 +1814,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
if (!f.delete()) {
return new Answer(cmd, false, "Unable to delete file " + f.getName() + " under Volume path "
+ relativeVolumePath);
+ tmpltParent.getPath());
}
}
if (!found) {
@ -1816,7 +1824,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
}
if (!tmpltParent.delete()) {
details = "Unable to delete directory " + tmpltParent.getName() + " under Volume path "
+ relativeVolumePath;
+ tmpltParent.getPath();
s_logger.debug(details);
return new Answer(cmd, false, details);
}