This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.22 by this push:
new 470812100ea server: set template type to ROUTING or USER if template
type is not specified when upload a template (#12768)
470812100ea is described below
commit 470812100ea6e9b5790bbc3a9f747d7d733ee36d
Author: Wei Zhou <[email protected]>
AuthorDate: Thu Apr 2 06:04:28 2026 +0200
server: set template type to ROUTING or USER if template type is not
specified when upload a template (#12768)
---
engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql | 3 +++
server/src/main/java/com/cloud/template/TemplateManagerImpl.java | 4 +++-
2 files changed, 6 insertions(+), 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 2326a855f32..369159e4836 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
@@ -35,3 +35,6 @@ UPDATE `cloud`.`alert` SET type = 34 WHERE name =
'ALERT.VR.PRIVATE.IFACE.MTU';
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';
UPDATE `cloud`.`vm_template` SET guest_os_id = 99 WHERE name =
'kvm-default-vm-import-dummy-template';
+
+-- Update existing vm_template records with NULL type to "USER"
+UPDATE `cloud`.`vm_template` SET `type` = 'USER' WHERE `type` IS NULL;
diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
index ff810ef9231..a2cb82a0a6b 100755
--- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
@@ -2416,7 +2416,7 @@ public class TemplateManagerImpl extends ManagerBase
implements TemplateManager,
} 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);
}
@@ -2426,6 +2426,8 @@ public class TemplateManagerImpl extends ManagerBase
implements TemplateManager,
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 request upload parameters for Template with template type %s.",
templateType));
}
}
return templateType;