diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 82d97d25f9c..1d2742a68eb 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -1069,11 +1069,13 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag List userTemplates = _templateDao.listByAccountId(accountId); boolean allTemplatesDeleted = true; for (VMTemplateVO template : userTemplates) { - try { - allTemplatesDeleted = _tmpltMgr.delete(callerUserId, template.getId(), null); - } catch (Exception e) { - s_logger.warn("Failed to delete template while removing account: " + template.getName() + " due to: ", e); - allTemplatesDeleted = false; + if (template.getRemoved() == null) { + try { + allTemplatesDeleted = _tmpltMgr.delete(callerUserId, template.getId(), null); + } catch (Exception e) { + s_logger.warn("Failed to delete template while removing account: " + template.getName() + " due to: ", e); + allTemplatesDeleted = false; + } } }