feature: Add `directdownload` request parameter to `createTemplate` API (KVM)
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 1.4k
- Avg merge
- 6d 19h
- Merged PRs (30d)
- 32
Description
### The required feature described as a wish
### Summary
The `createTemplate` API does not accept `directdownload` as a request parameter. This makes it impossible for tools that create templates from a stopped VM's volume (such as HashiCorp Packer) to produce a template with the `directdownload` flag set.
### Current Behaviour
`directdownload` is only accepted as a request parameter by `registerTemplate`. `createTemplate` and `updateTemplate` both omit it from their accepted parameters, though both include it in their response payloads (reflecting the value stored on the `vm_template` record).
There is no supported API path to set `directdownload = true` on a template created via `createTemplate`.
### Expected Behavior
`createTemplate` should accept an optional boolean `directdownload` parameter (KVM only), consistent with how `registerTemplate` handles it, and persist it on the resulting VMTemplateVO record.
### Proposed Change
In CreateTemplateCmd.java, add:
```java
@Parameter(name = ApiConstants.DIRECT_DOWNLOAD, type = CommandType.BOOLEAN,
description = "KVM Only: true if template should be directly downloaded "
+ "to Primary Storage, bypassing Secondary Storage. Default is false.")
private Boolean directDownload;
public Boolean isDirectDownload() {
return directDownload;
}
```
Propagate through `TemplateProfile` and `TemplateManagerImpl.createPrivateTemplate()` - following the identical pattern already used in `RegisterTemplateCmd` and its handling.
References
- `RegisterTemplateCmd.java` - existing implementation to follow
- `CreateTemplateCmd.java` - file to modify
- Downstream: apache/cloudstack-go SDK will need SetDirectdownload() added to CreateTemplateParams once this is merged
- Downstream: hashicorp/packer-plugin-cloudstack#95 - the packer plugin feature request blocked on this change
Contributor guide
Research direction
Start with RegisterTemplateCmd.java as the existing implementation, then inspect CreateTemplateCmd.java and trace the value through TemplateProfile and TemplateManagerImpl.createPrivateTemplate(). The work is done when createTemplate accepts the optional KVM-only boolean, propagates it, and persists it on the resulting VMTemplateVO record.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100