From 10a58531f49cbc307773431101d233e021a08688 Mon Sep 17 00:00:00 2001 From: Rakesh Venkatesh Date: Tue, 28 Apr 2020 17:01:49 +0200 Subject: [PATCH] Look for active templates for VR deployment 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. --- .../src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java b/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java index 6773c205aa37..c42e93e2c14e 100644 --- a/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java @@ -363,6 +363,7 @@ public boolean configure(String name, Map params) throws Configu tmpltTypeHyperSearch2.and("templateType", tmpltTypeHyperSearch2.entity().getTemplateType(), SearchCriteria.Op.EQ); tmpltTypeHyperSearch2.and("hypervisorType", tmpltTypeHyperSearch2.entity().getHypervisorType(), SearchCriteria.Op.EQ); tmpltTypeHyperSearch2.and("templateName", tmpltTypeHyperSearch2.entity().getName(), SearchCriteria.Op.EQ); + tmpltTypeHyperSearch2.and("state", tmpltTypeHyperSearch2.entity().getState(), SearchCriteria.Op.EQ); tmpltTypeSearch = createSearchBuilder(); tmpltTypeSearch.and("state", tmpltTypeSearch.entity().getState(), SearchCriteria.Op.EQ); @@ -884,6 +885,7 @@ public VMTemplateVO findRoutingTemplate(HypervisorType hType, String templateNam SearchCriteria sc = tmpltTypeHyperSearch2.create(); sc.setParameters("templateType", TemplateType.ROUTING); sc.setParameters("hypervisorType", hType); + sc.setParameters("state", VirtualMachineTemplate.State.Active.toString()); if (templateName != null) { sc.setParameters("templateName", templateName); } @@ -898,6 +900,7 @@ public VMTemplateVO findRoutingTemplate(HypervisorType hType, String templateNam sc = tmpltTypeHyperSearch2.create(); sc.setParameters("templateType", TemplateType.SYSTEM); sc.setParameters("hypervisorType", hType); + sc.setParameters("state", VirtualMachineTemplate.State.Active.toString()); if (templateName != null) { sc.setParameters("templateName", templateName); }