mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4210
delete templateVO entry when there is no image store having this template
This commit is contained in:
parent
822991a0e9
commit
e547b9f4cc
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue