mirror of https://github.com/apache/cloudstack.git
bug 7041: fix npe in delete template from storage pool, if the template already marked as removed
status 7041: resolved fixed
This commit is contained in:
parent
e2aa4738ec
commit
433c28fb16
|
|
@ -80,8 +80,8 @@ public class Storage {
|
|||
}
|
||||
|
||||
public static enum TemplateType {
|
||||
SYSTEM,
|
||||
BUILTIN
|
||||
SYSTEM, /*routing, system vm template*/
|
||||
BUILTIN /*buildin template*/
|
||||
}
|
||||
|
||||
public static enum StoragePoolType {
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ import com.cloud.storage.SnapshotPolicyVO;
|
|||
import com.cloud.storage.SnapshotVO;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolHostVO;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
|
|
@ -3723,7 +3724,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
for(VolumeVO v:allVolumes)
|
||||
{
|
||||
VMTemplateVO template = _templateDao.findById(v.getTemplateId());
|
||||
if(template!=null && template.getUniqueName().startsWith("routing"))
|
||||
if(template!=null && (template.getTemplateType() == TemplateType.SYSTEM))
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
|
|
|
|||
|
|
@ -953,10 +953,10 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
List<VMTemplateStoragePoolVO> allTemplatesInPool = _tmpltPoolDao.listByPoolId(pool.getId());
|
||||
|
||||
for (VMTemplateStoragePoolVO templatePoolVO : allTemplatesInPool) {
|
||||
VMTemplateVO template = _tmpltDao.findById(templatePoolVO.getTemplateId());
|
||||
|
||||
VMTemplateVO template = _tmpltDao.findByIdIncludingRemoved(templatePoolVO.getTemplateId());
|
||||
|
||||
// If this is a routing template, consider it in use
|
||||
if (template.getUniqueName().equals("routing")) {
|
||||
if (template.getTemplateType() == TemplateType.SYSTEM) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -976,7 +976,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
@Override
|
||||
public void evictTemplateFromStoragePool(VMTemplateStoragePoolVO templatePoolVO) {
|
||||
StoragePoolVO pool = _poolDao.findById(templatePoolVO.getPoolId());
|
||||
VMTemplateVO template = _tmpltDao.findById(templatePoolVO.getTemplateId());
|
||||
VMTemplateVO template = _tmpltDao.findByIdIncludingRemoved(templatePoolVO.getTemplateId());
|
||||
|
||||
long hostId;
|
||||
List<StoragePoolHostVO> poolHostVOs = _poolHostDao.listByPoolId(pool.getId());
|
||||
|
|
@ -1096,7 +1096,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
|
||||
@Override
|
||||
public boolean templateIsDeleteable(VMTemplateHostVO templateHostRef) {
|
||||
VMTemplateVO template = _tmpltDao.findById(templateHostRef.getTemplateId());
|
||||
VMTemplateVO template = _tmpltDao.findByIdIncludingRemoved(templateHostRef.getTemplateId());
|
||||
long templateId = template.getId();
|
||||
HostVO secondaryStorageHost = _hostDao.findById(templateHostRef.getHostId());
|
||||
long zoneId = secondaryStorageHost.getDataCenterId();
|
||||
|
|
@ -1284,7 +1284,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||
throw new InvalidParameterValueException("Please specify a valid template.");
|
||||
}
|
||||
|
||||
if (template.getUniqueName().equals("routing")) {
|
||||
if (template.getTemplateType() == TemplateType.SYSTEM) {
|
||||
throw new InvalidParameterValueException("The DomR template cannot be deleted.");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue