From 8111b6ced07b80367215869bc0d015823eab670b Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Mar 2026 12:16:49 +0100 Subject: [PATCH 1/5] server: set template type to ROUTING or USER if template type is not specified when upload a template --- .../src/main/java/com/cloud/template/TemplateManagerImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index ff810ef92312..bccc8c13e265 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -2407,6 +2407,8 @@ public TemplateType validateTemplateType(BaseCmd cmd, boolean isAdmin, boolean i throw new InvalidParameterValueException(String.format("Please specify a valid templatetype: %s", org.apache.commons.lang3.StringUtils.join(",", TemplateType.values()))); } + } else if (cmd instanceof GetUploadParamsForTemplateCmd) { + templateType = ((GetUploadParamsForTemplateCmd) cmd).isRoutingType() ? TemplateType.ROUTING : TemplateType.USER; } if (templateType != null) { if (isRoutingType != null && (TemplateType.ROUTING.equals(templateType) != isRoutingType)) { From 9dd06955799d0f1c88ba91deace019a0c620ba0d Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Mar 2026 12:24:59 +0100 Subject: [PATCH 2/5] update PR 12768 --- .../main/java/com/cloud/template/TemplateManagerImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index bccc8c13e265..9cb8d7dc578b 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -2407,8 +2407,6 @@ public TemplateType validateTemplateType(BaseCmd cmd, boolean isAdmin, boolean i throw new InvalidParameterValueException(String.format("Please specify a valid templatetype: %s", org.apache.commons.lang3.StringUtils.join(",", TemplateType.values()))); } - } else if (cmd instanceof GetUploadParamsForTemplateCmd) { - templateType = ((GetUploadParamsForTemplateCmd) cmd).isRoutingType() ? TemplateType.ROUTING : TemplateType.USER; } if (templateType != null) { if (isRoutingType != null && (TemplateType.ROUTING.equals(templateType) != isRoutingType)) { @@ -2418,7 +2416,7 @@ public TemplateType validateTemplateType(BaseCmd cmd, boolean isAdmin, boolean i } else if ((cmd instanceof RegisterVnfTemplateCmd || cmd instanceof UpdateVnfTemplateCmd) && !TemplateType.VNF.equals(templateType)) { throw new InvalidParameterValueException("The template type must be VNF for VNF templates, but the actual type is " + templateType); } - } else if (cmd instanceof RegisterTemplateCmd) { + } else if (cmd instanceof RegisterTemplateCmd || cmd instanceof GetUploadParamsForTemplateCmd) { boolean isRouting = Boolean.TRUE.equals(isRoutingType); templateType = (cmd instanceof RegisterVnfTemplateCmd) ? TemplateType.VNF : (isRouting ? TemplateType.ROUTING : TemplateType.USER); } @@ -2428,6 +2426,8 @@ public TemplateType validateTemplateType(BaseCmd cmd, boolean isAdmin, boolean i throw new InvalidParameterValueException(String.format("Users can not register Template with template type %s.", templateType)); } else if (cmd instanceof UpdateTemplateCmd) { throw new InvalidParameterValueException(String.format("Users can not update Template to template type %s.", templateType)); + } else if (cmd instanceof GetUploadParamsForTemplateCmd) { + throw new InvalidParameterValueException(String.format("Users can not upload Template to template type %s.", templateType)); } } return templateType; From e376b7d0abaa07f6784ed673f64536d62165fe34 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Mar 2026 12:39:07 +0100 Subject: [PATCH 3/5] add sql change --- .../src/main/resources/META-INF/db/schema-42200to42210.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql index a8a3d3f7bd4f..2b78199f39e3 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql @@ -33,3 +33,6 @@ UPDATE `cloud`.`alert` SET type = 34 WHERE name = 'ALERT.VR.PRIVATE.IFACE.MTU'; -- Update configuration 'kvm.ssh.to.agent' description and is_dynamic fields UPDATE `cloud`.`configuration` SET description = 'True if the management server will restart the agent service via SSH into the KVM hosts after or during maintenance operations', is_dynamic = 1 WHERE name = 'kvm.ssh.to.agent'; + +-- Set default value for vm_template.type to "USER" and update existing records with NULL type to "USER" +UPDATE `cloud`.`vm_template` SET `type` = 'USER' WHERE `type` IS NULL; From de7290b38a9c111fb997e73b50b52b4195a623e8 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Mar 2026 13:48:06 +0100 Subject: [PATCH 4/5] Update engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../src/main/resources/META-INF/db/schema-42200to42210.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql index 2b78199f39e3..b18cb31676f4 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql @@ -34,5 +34,5 @@ UPDATE `cloud`.`alert` SET type = 34 WHERE name = 'ALERT.VR.PRIVATE.IFACE.MTU'; -- Update configuration 'kvm.ssh.to.agent' description and is_dynamic fields UPDATE `cloud`.`configuration` SET description = 'True if the management server will restart the agent service via SSH into the KVM hosts after or during maintenance operations', is_dynamic = 1 WHERE name = 'kvm.ssh.to.agent'; --- Set default value for vm_template.type to "USER" and update existing records with NULL type to "USER" +-- Update existing vm_template records with NULL type to "USER" UPDATE `cloud`.`vm_template` SET `type` = 'USER' WHERE `type` IS NULL; From e01730a41c0a2073fcdc09f1574464c8eac7b339 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 9 Mar 2026 13:48:29 +0100 Subject: [PATCH 5/5] Update server/src/main/java/com/cloud/template/TemplateManagerImpl.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../src/main/java/com/cloud/template/TemplateManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 9cb8d7dc578b..a2cb82a0a6be 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -2427,7 +2427,7 @@ public TemplateType validateTemplateType(BaseCmd cmd, boolean isAdmin, boolean i } else if (cmd instanceof UpdateTemplateCmd) { throw new InvalidParameterValueException(String.format("Users can not update Template to template type %s.", templateType)); } else if (cmd instanceof GetUploadParamsForTemplateCmd) { - throw new InvalidParameterValueException(String.format("Users can not upload Template to template type %s.", templateType)); + throw new InvalidParameterValueException(String.format("Users can not request upload parameters for Template with template type %s.", templateType)); } } return templateType;