mirror of https://github.com/apache/cloudstack.git
bug 7433: In case of multiple zones deleting a tempate from a zone doesn't prevent a user from selecting it to deploy the VM in the same zone. It was still visible in the listTemplates. Made change to check for template_zone_ref and template_host_ref removed and destroyed columns. During deployVM disallow a vm to be deployed from a template that has been removed in the zone.
This commit is contained in:
parent
fe267c2cb2
commit
47882e9809
|
|
@ -376,12 +376,14 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
}
|
||||
|
||||
if (onlyReady){
|
||||
sql += " AND thr.download_state = '" +Status.DOWNLOADED.toString() + "'";
|
||||
sql += " AND thr.download_state = '" +Status.DOWNLOADED.toString() + "'" + " AND thr.destroyed=0 ";
|
||||
if (zoneId != null){
|
||||
sql += " AND h.data_center_id = " +zoneId;
|
||||
}
|
||||
}else if (zoneId != null){
|
||||
sql += " AND tzr.zone_id = " +zoneId;
|
||||
sql += " AND tzr.zone_id = " +zoneId+ " AND tzr.removed is null" ;
|
||||
}else{
|
||||
sql += " AND tzr.removed is null ";
|
||||
}
|
||||
if (!showDomr){
|
||||
sql += " AND t.type != '" +Storage.TemplateType.SYSTEM.toString() + "'";
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class VMTemplateZoneDaoImpl extends GenericDaoBase<VMTemplateZoneVO, Long
|
|||
SearchCriteria<VMTemplateZoneVO> sc = ZoneTemplateSearch.create();
|
||||
sc.setParameters("zone_id", zoneId);
|
||||
sc.setParameters("template_id", templateId);
|
||||
return listIncludingRemovedBy(sc);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ import com.cloud.storage.DiskOfferingVO;
|
|||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.SnapshotVO;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.VMTemplateZoneVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.Storage.StorageResourceType;
|
||||
|
|
@ -149,6 +150,7 @@ import com.cloud.storage.dao.SnapshotDao;
|
|||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
|
|
@ -205,6 +207,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
@Inject protected UserStatisticsDao _userStatsDao = null;
|
||||
@Inject protected VMTemplateDao _templateDao = null;
|
||||
@Inject protected VMTemplateHostDao _templateHostDao = null;
|
||||
@Inject protected VMTemplateZoneDao _templateZoneDao = null;
|
||||
@Inject protected DomainDao _domainDao = null;
|
||||
@Inject protected ResourceLimitDao _limitDao = null;
|
||||
@Inject protected UserVmDao _vmDao = null;
|
||||
|
|
@ -2028,7 +2031,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
if (template.getTemplateType().equals(TemplateType.SYSTEM)) {
|
||||
throw new InvalidParameterValueException("Unable to use system template " + template.getId() + " to deploy a user vm");
|
||||
}
|
||||
|
||||
List<VMTemplateZoneVO> listZoneTemplate = _templateZoneDao.listByZoneTemplate(zone.getId(),template.getId());
|
||||
if (listZoneTemplate==null || listZoneTemplate.isEmpty()){
|
||||
throw new InvalidParameterValueException("The template " +template.getId()+ " is not available for use");
|
||||
}
|
||||
boolean isIso = Storage.ImageFormat.ISO == template.getFormat();
|
||||
if (isIso && !template.isBootable()) {
|
||||
throw new InvalidParameterValueException("Installing from ISO requires an ISO that is bootable: " + template.getId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue