CLOUDSTACK-5607: Don't delete the template if its stored in other zones.

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5bfef62a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5bfef62a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5bfef62a

Branch: refs/heads/master
Commit: 5bfef62ab07e34cdfe68c28574e0b078a2d727e2
Parents: 8583b70
Author: edison <[email protected]>
Authored: Wed Jan 8 15:04:05 2014 -0800
Committer: Anthony Xu <[email protected]>
Committed: Fri Mar 28 16:22:57 2014 -0700

----------------------------------------------------------------------
 server/src/com/cloud/template/HypervisorTemplateAdapter.java | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5bfef62a/server/src/com/cloud/template/HypervisorTemplateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/HypervisorTemplateAdapter.java 
b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
index 9d52b39..51dedf7 100755
--- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java
+++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
@@ -399,6 +399,11 @@ public class HypervisorTemplateAdapter extends 
TemplateAdapterBase {
             }
         }
         if (success) {
+            if ((imageStores.size() > 1) && (profile.getZoneId() != null)) {
+                //if template is stored in more than one image stores, and the 
zone id is not null, then don't delete other templates.
+                return success;
+            }
+
             // delete all cache entries for this template
             List<TemplateInfo> cacheTmpls = 
imageFactory.listTemplateOnCache(template.getId());
             for (TemplateInfo tmplOnCache : cacheTmpls) {

Reply via email to