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.
bug 7433: resolved fixed
This commit is contained in:
parent
0813580c59
commit
0dbed1ae09
|
|
@ -73,7 +73,7 @@ public class VMTemplateZoneDaoImpl extends GenericDaoBase<VMTemplateZoneVO, Long
|
|||
SearchCriteria sc = ZoneTemplateSearch.create();
|
||||
sc.setParameters("zone_id", zoneId);
|
||||
sc.setParameters("template_id", templateId);
|
||||
return findOneBy(sc);
|
||||
return findOneActiveBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public class ListTemplatesCmd extends BaseCmd {
|
|||
List<VMTemplateHostVO> templateHostRefsForTemplate = getManagementServer().listTemplateHostBy(template.getId(), zoneId);
|
||||
|
||||
for (VMTemplateHostVO templateHostRef : templateHostRefsForTemplate) {
|
||||
if (onlyReady && templateHostRef.getDownloadState() != Status.DOWNLOADED) {
|
||||
if ((onlyReady && templateHostRef.getDownloadState() != Status.DOWNLOADED) || templateHostRef.getDestroyed()){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ import com.cloud.storage.dao.SnapshotDao;
|
|||
import com.cloud.storage.dao.SnapshotPolicyDao;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao.TemplateFilter;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
|
|
@ -312,6 +313,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
private final DiskOfferingDao _diskOfferingDao;
|
||||
private final VMTemplateDao _templateDao;
|
||||
private final VMTemplateHostDao _templateHostDao;
|
||||
private final VMTemplateZoneDao _templateZoneDao;
|
||||
private final LaunchPermissionDao _launchPermissionDao;
|
||||
private final PricingDao _pricingDao;
|
||||
private final DomainDao _domainDao;
|
||||
|
|
@ -410,6 +412,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
_diskOfferingDao = locator.getDao(DiskOfferingDao.class);
|
||||
_templateDao = locator.getDao(VMTemplateDao.class);
|
||||
_templateHostDao = locator.getDao(VMTemplateHostDao.class);
|
||||
_templateZoneDao = locator.getDao(VMTemplateZoneDao.class);
|
||||
_launchPermissionDao = locator.getDao(LaunchPermissionDao.class);
|
||||
_pricingDao = locator.getDao(PricingDao.class);
|
||||
_domainDao = locator.getDao(DomainDao.class);
|
||||
|
|
@ -2462,6 +2465,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
// Make sure a valid template ID was specified
|
||||
if (template == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid template or ISO ID.");
|
||||
}if (_templateZoneDao.findByZoneTemplate(dataCenterId, templateId) != null){
|
||||
throw new InvalidParameterValueException("The template " +templateId+ " is not available for use");
|
||||
}
|
||||
|
||||
boolean isIso = Storage.ImageFormat.ISO.equals(template.getFormat());
|
||||
|
|
|
|||
Loading…
Reference in New Issue