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..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 @@ -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'; + +-- 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 ff810ef92312..a2cb82a0a6be 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 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); } @@ -2426,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 request upload parameters for Template with template type %s.", templateType)); } } return templateType;