weizhouapache commented on code in PR #8875:
URL: https://github.com/apache/cloudstack/pull/8875#discussion_r1608519272
##########
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:
if the vm state is State.Starting, State.Running, State.Stopping,
State.Migrating, State.Restoring,
the host_id should not be null, and host should not be removed
but... I do not know if there is any edge cases (or by manual db changes,
etc)
--
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]