bug 11838: Create Private Template from Snapshot - Lift the restriction of creating duplicate names keeping it consistent with register template

Reviewed by : Kishan.
This commit is contained in:
Nitin Mehta 2011-12-13 14:42:08 +05:30
parent b2b8ce1758
commit 353bc396e3
3 changed files with 1 additions and 22 deletions

10
server/src/com/cloud/storage/dao/VMTemplateDao.java Normal file → Executable file
View File

@ -39,15 +39,7 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long> {
//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);

View File

@ -131,14 +131,6 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
return findOneIncludingRemovedBy(sc);
}
@Override
public VMTemplateVO findByTemplateNameAccountId(String templateName, Long accountId) {
SearchCriteria<VMTemplateVO> sc = NameAccountIdSearch.create();
sc.setParameters("name", templateName);
sc.setParameters("accountId", accountId);
return findOneBy(sc);
}
@Override
public List<VMTemplateVO> publicIsoSearch(Boolean bootable, boolean listRemoved){
SearchCriteria<VMTemplateVO> sc = PublicIsoSearch.create();

View File

@ -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);