diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 69b4ccad975..7d89d52a8e8 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -1084,11 +1084,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; + } } }