sureshanaparti commented on a change in pull request #5029:
URL: https://github.com/apache/cloudstack/pull/5029#discussion_r635144280
##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -6194,22 +6194,16 @@ public VirtualMachine
migrateVirtualMachineWithVolume(Long vmId, Host destinatio
HypervisorCapabilitiesVO capabilities =
_hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(srcHost.getHypervisorType(),
srcHost.getHypervisorVersion());
- if (capabilities == null &&
HypervisorType.KVM.equals(srcHost.getHypervisorType())) {
- List<HypervisorCapabilitiesVO> lstHypervisorCapabilities =
_hypervisorCapabilitiesDao.listAllByHypervisorType(HypervisorType.KVM);
-
- if (lstHypervisorCapabilities != null) {
- for (HypervisorCapabilitiesVO hypervisorCapabilities :
lstHypervisorCapabilities) {
- if (hypervisorCapabilities.isStorageMotionSupported()) {
- capabilities = hypervisorCapabilities;
-
- break;
- }
- }
+ if (capabilities == null) {
+ if (!HypervisorType.KVM.equals(srcHost.getHypervisorType())) {
+ throw new CloudRuntimeException(String.format("Cannot migrate
VM with storage, as the capabilities are not found for the hypervisor %s with
version %s", srcHost.getHypervisorType(), srcHost.getHypervisorVersion()));
}
- }
+ List<HypervisorCapabilitiesVO> lstHypervisorCapabilities =
_hypervisorCapabilitiesDao.listAllByHypervisorType(HypervisorType.KVM);
- if (!capabilities.isStorageMotionSupported()) {
- throw new CloudRuntimeException("Migration with storage isn't
supported on hypervisor " + srcHost.getHypervisorType() + " of version " +
srcHost.getHypervisorVersion());
+ capabilities =
lstHypervisorCapabilities.stream().filter(hvCapabilities ->
hvCapabilities.isStorageMotionSupported()).findAny()
+ .orElseThrow(() -> new
CloudRuntimeException(String.format("Migration with storage isn't supported on
hypervisor %s of version %s", srcHost.getHypervisorType(),
srcHost.getHypervisorVersion())));
Review comment:
@slavkap if no capabilities found here, throw the same exception as
above.
```suggestion
.orElseThrow(() -> new
CloudRuntimeException(String.format("Cannot migrate VM with storage, as the
capabilities are not found for the hypervisor %s with version %s",
srcHost.getHypervisorType(), srcHost.getHypervisorVersion())));
```
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]