Skip to content

Commit bf83efc

Browse files
committed
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.
1 parent 0e695ec commit bf83efc

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,15 @@ protected Answer deleteVolume(final DeleteCommand cmd) {
17751775
parent += File.separator;
17761776
}
17771777
String absoluteVolumePath = parent + relativeVolumePath;
1778-
File tmpltParent = new File(absoluteVolumePath).getParentFile();
1778+
File volPath = new File(absoluteVolumePath);
1779+
File tmpltParent = null;
1780+
if (volPath.exists() && volPath.isDirectory()) {
1781+
// for vmware, absoluteVolumePath represents a directory where volume files are located.
1782+
tmpltParent = volPath;
1783+
} else{
1784+
// for other hypervisors, the volume .vhd or .qcow2 file path is passed
1785+
tmpltParent = new File(absoluteVolumePath).getParentFile();
1786+
}
17791787
String details = null;
17801788
if (!tmpltParent.exists()) {
17811789
details = "volume parent directory " + tmpltParent.getName() + " doesn't exist";
@@ -1806,7 +1814,7 @@ protected Answer deleteVolume(final DeleteCommand cmd) {
18061814

18071815
if (!f.delete()) {
18081816
return new Answer(cmd, false, "Unable to delete file " + f.getName() + " under Volume path "
1809-
+ relativeVolumePath);
1817+
+ tmpltParent.getPath());
18101818
}
18111819
}
18121820
if (!found) {
@@ -1816,7 +1824,7 @@ protected Answer deleteVolume(final DeleteCommand cmd) {
18161824
}
18171825
if (!tmpltParent.delete()) {
18181826
details = "Unable to delete directory " + tmpltParent.getName() + " under Volume path "
1819-
+ relativeVolumePath;
1827+
+ tmpltParent.getPath();
18201828
s_logger.debug(details);
18211829
return new Answer(cmd, false, details);
18221830
}

0 commit comments

Comments
 (0)