prashanthr2 opened a new pull request, #13414:
URL: https://github.com/apache/cloudstack/pull/13414
## Description
Adds support for specifying per-NIC MAC addresses when importing a VM into
CloudStack via `importUnmanagedInstance` and `importVM` APIs.
## Problem
Both APIs always used the MAC address reported by the hypervisor. The only
MAC control was the `forced` boolean — which either rejected a conflict or
silently generated a new MAC. There was no way to supply a specific MAC at
import time, which is needed for migration scenarios requiring MAC preservation.
## Solution
New MAP parameter `nicmacaddresslist` following the same pattern as
`nicnetworklist` and `nicipaddresslist`:
\`\`\`
nicmacaddresslist[0].nic=nic1&nicmacaddresslist[0].mac=aa:bb:cc:dd:ee:ff
nicmacaddresslist[1].nic=nic2&nicmacaddresslist[1].mac=aa:bb:cc:dd:ee:02
\`\`\`
NICs not listed keep their hypervisor-reported MAC — fully backward
compatible.
## Changes
- `ApiConstants`: add `NIC_MAC_ADDRESS_LIST = "nicmacaddresslist"`
- `VmDetailConstants`: add `NIC_MAC_ADDRESS = "macAddress"`
- `ImportUnmanagedInstanceCmd`: new `@Parameter nicmacaddresslist` with
`getNicMacAddressList()` — `isValidMac` + `isUnicastMac` +
`standardizeMacAddress` validation
- `UnmanagedVMsManagerImpl`:
- `mergeNicMacAddresses()`: merges caller MACs into the `IpAddresses` map
- `baseImportInstance()` + `importVm()`: call `mergeNicMacAddresses()`
- `importNic()`: prefers caller-supplied MAC over hypervisor-reported MAC
- `importNic()`: `private` → `protected` for testability
## Tests
- `ImportUnmanagedInstanceCmdTest` (new): 9 tests — MAC format, unicast,
empty/null validation
- `UnmanagedVMsManagerImplTest`: 8 new tests — `mergeNicMacAddresses()` edge
cases + `importNic()` MAC selection
--
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]