rajujith opened a new pull request, #14435:
URL: https://github.com/apache/cloudstack/pull/14435

   ### Description
   
   This PR makes the `clusterid` parameter of the `importVm` API optional.
   
   `ImportVmCmd` extends `ImportUnmanagedInstanceCmd` and inherits `clusterid` 
with `required = true`, so every `importVm` call must pass a valid cluster 
UUID. However, for `importsource=external`, `local` and `shared` 
(`importKvmInstance()`), the value is never read:
   
   - For `local` / `shared` disk imports, the deployment plan is built from the 
storage pool's pod and cluster (and `hostid` for local storage), not from 
`clusterid`.
   - For `external`, the instance is fetched from the remote host given by 
`host`.
   
   Only `importsource=vmware` and `unmanaged` (`baseImportInstance()`) use the 
cluster. Those paths already reject a missing cluster in `basicAccessChecks()`. 
This PR keeps that check and changes its message to name the `clusterid` 
parameter.
   
   `importUnmanagedInstance` shares the same parameter field, so the API doc 
now lists `clusterid` as optional there too. The server still rejects a call 
without it, with an `InvalidParameterValueException` instead of the generic 
missing-parameter error, and the parameter description says when it is required.
   
   Before this change, for example:
   
   ```
   
command=importVm&importsource=shared&hypervisor=kvm&diskpath=...&storageid=...&networkid=...&zoneid=...
   -> 431: Unable to execute API command importvm due to missing parameter 
clusterid
   ```
   
   After this change the call succeeds without `clusterid`. Requests that pass 
it are unaffected, so the UI (which always sends it) keeps working.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] Build/CI
   - [ ] Test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [x] Minor
   - [ ] Trivial
   
   ### How Has This Been Tested?
   
   Unit tests in `UnmanagedVMsManagerImplTest` (95 tests, all passing):
   - `importFromLocalDisk` / `importFromsharedStorage` now also check that 
`getClusterId()` is never called on the import path.
   - New `testImportVmFromVmwareMissingClusterId` and 
`testImportVmFromUnmanagedMissingClusterId` check that VMware and unmanaged 
imports without `clusterid` still fail with `InvalidParameterValueException`.
   
   #### How did you try to break this feature and the system with this change?
   
   Checked every caller of `getClusterId()` on the import commands: only 
`baseImportInstance()` (VMware/unmanaged) and `listUnmanagedInstances` read it, 
and both already check for null.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to