From 353bc396e3b189a2f67947f798191e44ccad5849 Mon Sep 17 00:00:00 2001 From: Nitin Mehta Date: Tue, 13 Dec 2011 14:42:08 +0530 Subject: [PATCH] bug 11838: Create Private Template from Snapshot - Lift the restriction of creating duplicate names keeping it consistent with register template Reviewed by : Kishan. --- server/src/com/cloud/storage/dao/VMTemplateDao.java | 10 +--------- .../src/com/cloud/storage/dao/VMTemplateDaoImpl.java | 8 -------- server/src/com/cloud/vm/UserVmManagerImpl.java | 5 ----- 3 files changed, 1 insertion(+), 22 deletions(-) mode change 100644 => 100755 server/src/com/cloud/storage/dao/VMTemplateDao.java diff --git a/server/src/com/cloud/storage/dao/VMTemplateDao.java b/server/src/com/cloud/storage/dao/VMTemplateDao.java old mode 100644 new mode 100755 index fcfdad41182..fda153a765f --- a/server/src/com/cloud/storage/dao/VMTemplateDao.java +++ b/server/src/com/cloud/storage/dao/VMTemplateDao.java @@ -39,15 +39,7 @@ public interface VMTemplateDao extends GenericDao { //finds by the column "unique_name" public VMTemplateVO findByName(String templateName); //finds by the column "name" - public VMTemplateVO findByTemplateName(String templateName); - - /** - * Find a template by name for a specific account. - * @param templateName the name to search for - * @param accountId the account to use for filtering the search results - * @return the template with the given name for the given account if it exists, null otherwise - */ - public VMTemplateVO findByTemplateNameAccountId(String templateName, Long accountId); + public VMTemplateVO findByTemplateName(String templateName); //public void update(VMTemplateVO template); diff --git a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java index 1872cea90aa..c836657f771 100755 --- a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java +++ b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java @@ -131,14 +131,6 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem return findOneIncludingRemovedBy(sc); } - @Override - public VMTemplateVO findByTemplateNameAccountId(String templateName, Long accountId) { - SearchCriteria sc = NameAccountIdSearch.create(); - sc.setParameters("name", templateName); - sc.setParameters("accountId", accountId); - return findOneBy(sc); - } - @Override public List publicIsoSearch(Boolean bootable, boolean listRemoved){ SearchCriteria sc = PublicIsoSearch.create(); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 09cb47fa731..d99107f604c 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1388,11 +1388,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager hyperType = snapshot.getHypervisorType(); } - VMTemplateVO existingTemplate = _templateDao.findByTemplateNameAccountId(name, accountId); - if (existingTemplate != null) { - throw new InvalidParameterValueException("Failed to create private template " + name + ", a template with that name already exists."); - } - AccountVO ownerAccount = _accountDao.findById(accountId); _resourceLimitMgr.checkResourceLimit(ownerAccount, ResourceType.template);