server: set template type to ROUTING or USER if template type is not specified when upload a template (#12768)

This commit is contained in:
Wei Zhou 2026-04-02 06:04:28 +02:00 committed by GitHub
parent e10c066cc1
commit 470812100e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -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;

View File

@ -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;