Skip to content

Commit 7874918

Browse files
authored
server: Look for active templates for VR deployment (#4047)
If the template from which VR is created got deleted, the state is set to inactive and removed to null. Since the template is already deleted, the VR can't be created using this template again. If someone restarts network with cleanup then it will try to deploy the vr from the old non existing template again. So search only for active template which are not yet deleted.
1 parent fef0e66 commit 7874918

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
376376
tmpltTypeHyperSearch2.and("templateType", tmpltTypeHyperSearch2.entity().getTemplateType(), SearchCriteria.Op.EQ);
377377
tmpltTypeHyperSearch2.and("hypervisorType", tmpltTypeHyperSearch2.entity().getHypervisorType(), SearchCriteria.Op.EQ);
378378
tmpltTypeHyperSearch2.and("templateName", tmpltTypeHyperSearch2.entity().getName(), SearchCriteria.Op.EQ);
379+
tmpltTypeHyperSearch2.and("state", tmpltTypeHyperSearch2.entity().getState(), SearchCriteria.Op.EQ);
379380

380381
tmpltTypeSearch = createSearchBuilder();
381382
tmpltTypeSearch.and("state", tmpltTypeSearch.entity().getState(), SearchCriteria.Op.EQ);
@@ -897,6 +898,7 @@ public VMTemplateVO findRoutingTemplate(HypervisorType hType, String templateNam
897898
SearchCriteria<VMTemplateVO> sc = tmpltTypeHyperSearch2.create();
898899
sc.setParameters("templateType", TemplateType.ROUTING);
899900
sc.setParameters("hypervisorType", hType);
901+
sc.setParameters("state", VirtualMachineTemplate.State.Active.toString());
900902
if (templateName != null) {
901903
sc.setParameters("templateName", templateName);
902904
}
@@ -911,6 +913,7 @@ public VMTemplateVO findRoutingTemplate(HypervisorType hType, String templateNam
911913
sc = tmpltTypeHyperSearch2.create();
912914
sc.setParameters("templateType", TemplateType.SYSTEM);
913915
sc.setParameters("hypervisorType", hType);
916+
sc.setParameters("state", VirtualMachineTemplate.State.Active.toString());
914917
if (templateName != null) {
915918
sc.setParameters("templateName", templateName);
916919
}

0 commit comments

Comments
 (0)