You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by an...@apache.org on 2013/08/09 21:11:49 UTC
git commit: updated refs/heads/master to 36d7b49
Updated Branches:
refs/heads/master 5c36766ad -> 36d7b49d5
CLOUDSTACK-4210
delete templateVO entry when there is no image store having this template
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/36d7b49d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/36d7b49d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/36d7b49d
Branch: refs/heads/master
Commit: 36d7b49d5faf3c1dc2d8936ab125a593b8910078
Parents: 5c36766
Author: Anthony Xu <an...@citrix.com>
Authored: Fri Aug 9 12:02:17 2013 -0700
Committer: Anthony Xu <an...@citrix.com>
Committed: Fri Aug 9 12:08:00 2013 -0700
----------------------------------------------------------------------
.../template/HypervisorTemplateAdapter.java | 22 ++++++++++++--------
1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36d7b49d/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 de0ed7e..7ec7114 100755
--- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java
+++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
@@ -329,15 +329,19 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
}
}
if (success) {
- s_logger.info("Delete template from template table");
- // remove template from vm_templates table
- if (_tmpltDao.remove(template.getId())) {
- // Decrement the number of templates and total secondary storage
- // space used by the account
- Account account = _accountDao.findByIdIncludingRemoved(template.getAccountId());
- _resourceLimitMgr.decrementResourceCount(template.getAccountId(), ResourceType.template);
- _resourceLimitMgr.recalculateResourceCount(template.getAccountId(), account.getDomainId(),
- ResourceType.secondary_storage.getOrdinal());
+
+ // find all eligible image stores for this template
+ List<DataStore> iStores = this.templateMgr.getImageStoreByTemplate(template.getId(), null);
+ if (iStores == null || iStores.size() == 0) {
+ // remove template from vm_templates table
+ if (_tmpltDao.remove(template.getId())) {
+ // Decrement the number of templates and total secondary storage
+ // space used by the account
+ Account account = _accountDao.findByIdIncludingRemoved(template.getAccountId());
+ _resourceLimitMgr.decrementResourceCount(template.getAccountId(), ResourceType.template);
+ _resourceLimitMgr.recalculateResourceCount(template.getAccountId(), account.getDomainId(),
+ ResourceType.secondary_storage.getOrdinal());
+ }
}
}
return success;