@@ -953,10 +953,10 @@ public List<VMTemplateStoragePoolVO> getUnusedTemplatesInPool(StoragePoolVO pool
953953 List <VMTemplateStoragePoolVO > allTemplatesInPool = _tmpltPoolDao .listByPoolId (pool .getId ());
954954
955955 for (VMTemplateStoragePoolVO templatePoolVO : allTemplatesInPool ) {
956- VMTemplateVO template = _tmpltDao .findById (templatePoolVO .getTemplateId ());
957-
956+ VMTemplateVO template = _tmpltDao .findByIdIncludingRemoved (templatePoolVO .getTemplateId ());
957+
958958 // If this is a routing template, consider it in use
959- if (template .getUniqueName (). equals ( "routing" ) ) {
959+ if (template .getTemplateType () == TemplateType . SYSTEM ) {
960960 continue ;
961961 }
962962
@@ -976,7 +976,7 @@ public List<VMTemplateStoragePoolVO> getUnusedTemplatesInPool(StoragePoolVO pool
976976 @ Override
977977 public void evictTemplateFromStoragePool (VMTemplateStoragePoolVO templatePoolVO ) {
978978 StoragePoolVO pool = _poolDao .findById (templatePoolVO .getPoolId ());
979- VMTemplateVO template = _tmpltDao .findById (templatePoolVO .getTemplateId ());
979+ VMTemplateVO template = _tmpltDao .findByIdIncludingRemoved (templatePoolVO .getTemplateId ());
980980
981981 long hostId ;
982982 List <StoragePoolHostVO > poolHostVOs = _poolHostDao .listByPoolId (pool .getId ());
@@ -1096,7 +1096,7 @@ public Long createInZone(long zoneId, long userId, String displayText,
10961096
10971097 @ Override
10981098 public boolean templateIsDeleteable (VMTemplateHostVO templateHostRef ) {
1099- VMTemplateVO template = _tmpltDao .findById (templateHostRef .getTemplateId ());
1099+ VMTemplateVO template = _tmpltDao .findByIdIncludingRemoved (templateHostRef .getTemplateId ());
11001100 long templateId = template .getId ();
11011101 HostVO secondaryStorageHost = _hostDao .findById (templateHostRef .getHostId ());
11021102 long zoneId = secondaryStorageHost .getDataCenterId ();
@@ -1284,7 +1284,7 @@ public boolean deleteTemplate(DeleteTemplateCmd cmd) {
12841284 throw new InvalidParameterValueException ("Please specify a valid template." );
12851285 }
12861286
1287- if (template .getUniqueName (). equals ( "routing" ) ) {
1287+ if (template .getTemplateType () == TemplateType . SYSTEM ) {
12881288 throw new InvalidParameterValueException ("The DomR template cannot be deleted." );
12891289 }
12901290
0 commit comments