abh1sar commented on code in PR #8875:
URL: https://github.com/apache/cloudstack/pull/8875#discussion_r1608498589
##########
server/src/main/java/com/cloud/api/query/QueryManagerImpl.java:
##########
@@ -1147,6 +1155,41 @@ public ListResponse<UserVmResponse>
searchForUserVMs(ListVMsCmd cmd) {
return response;
}
+ @Override
+ public ListResponse<VirtualMachineResponse>
findAffectedVmsForStorageScopeChange(FindAffectedVmsForStorageScopeChangeCmd
cmd) {
+ Long poolId = cmd.getStorageId();
+ StoragePoolVO pool = storagePoolDao.findById(poolId);
+ if (pool == null) {
+ throw new IllegalArgumentException("Unable to find storage pool
with ID: " + poolId);
+ }
+ if (!pool.getStatus().equals(StoragePoolStatus.Disabled)) {
+ throw new InvalidParameterValueException("Scope change of Storage
pool is only allowed in Disabled state");
+ }
+ ListResponse<VirtualMachineResponse> response = new ListResponse<>();
+ if (pool.getScope() != ScopeType.ZONE) {
+ response.setResponses(null, 0);
+ return response;
+ }
+
+ Pair<List<VMInstanceVO>, Integer> vms =
_vmInstanceDao.listByVmsNotInClusterUsingPool(cmd.getClusterIdForScopeChange(),
poolId);
+ List<VirtualMachineResponse> responsesList = new ArrayList<>();
+ for (VMInstanceVO vm : vms.first()) {
+ VirtualMachineResponse resp = new VirtualMachineResponse();
+
resp.setObjectName(VirtualMachine.class.getSimpleName().toLowerCase());
+ resp.setId(vm.getUuid());
+ resp.setVmType(vm.getType().toString());
+ HostVO host = hostDao.findById(vm.getHostId());
+ resp.setHostId(host.getUuid());
Review Comment:
Have added the check but just curious if there could be any special
condition when the vm_instance won't contain the host_id?
--
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]