Detail: Delete KVMHA dir contents if found when deleting templates, volumes from Nfs Secondary storage
BUG-ID: CLOUDSTACK-2173 Bugfix-for: 4.2 Signed-off-by: Marcus Sorensen <mar...@betterservers.com> 1366838425 -0600 Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7fa57922 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7fa57922 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7fa57922 Branch: refs/heads/ui-add-remove-nics Commit: 7fa57922a40428d73e80f5f2a48ff67c8cecd148 Parents: d893ba8 Author: Marcus Sorensen <mar...@betterservers.com> Authored: Wed Apr 24 15:20:25 2013 -0600 Committer: Marcus Sorensen <mar...@betterservers.com> Committed: Wed Apr 24 15:20:25 2013 -0600 ---------------------------------------------------------------------- .../resource/NfsSecondaryStorageResource.java | 22 +++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7fa57922/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java ---------------------------------------------------------------------- diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java index 1176d76..638d5ca 100755 --- a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java +++ b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java @@ -1291,6 +1291,17 @@ SecondaryStorageResource { if (!found && f.getName().equals("template.properties")) { found = true; } + + // KVM HA monitor makes a mess in the templates with its heartbeat tests + // Don't let this stop us from cleaning up the template + if (f.isDirectory() && f.getName().equals("KVMHA")) { + s_logger.debug("Deleting KVMHA directory contents from template location"); + File[] haFiles = f.listFiles(); + for (File haFile : haFiles) { + haFile.delete(); + } + } + if (!f.delete()) { return new Answer(cmd, false, "Unable to delete file " + f.getName() + " under Template path " + relativeTemplatePath); @@ -1339,6 +1350,17 @@ SecondaryStorageResource { if (!found && f.getName().equals("volume.properties")) { found = true; } + + // KVM HA monitor makes a mess in the templates with its heartbeat tests + // Don't let this stop us from cleaning up the template + if (f.isDirectory() && f.getName().equals("KVMHA")) { + s_logger.debug("Deleting KVMHA directory contents from template location"); + File[] haFiles = f.listFiles(); + for (File haFile : haFiles) { + haFile.delete(); + } + } + if (!f.delete()) { return new Answer(cmd, false, "Unable to delete file " + f.getName() + " under Volume path " + relativeVolumePath);