BryanMLima commented on code in PR #6491:
URL: https://github.com/apache/cloudstack/pull/6491#discussion_r914124623


##########
api/src/main/java/org/apache/cloudstack/api/command/admin/vm/MigrateVirtualMachineWithVolumeCmd.java:
##########
@@ -152,20 +153,17 @@ public ApiCommandResourceType getApiResourceType() {
     @Override
     public void execute() {
         if (hostId == null && MapUtils.isEmpty(migrateVolumeTo)) {
-            throw new InvalidParameterValueException(String.format("Either %s 
or %s  must be passed for migrating the VM", ApiConstants.HOST_ID, 
ApiConstants.MIGRATE_TO));
-        }
-
-        UserVm userVm = _userVmService.getUserVm(getVirtualMachineId());
-        if (userVm == null) {
-            throw new InvalidParameterValueException("Unable to find the VM by 
id=" + getVirtualMachineId());
+            throw new InvalidParameterValueException(String.format("Either %s 
or %s  must be passed for migrating the VM.", ApiConstants.HOST_ID, 
ApiConstants.MIGRATE_TO));
         }
 
+        VirtualMachine userVm = _userVmService.getVm(getVirtualMachineId());

Review Comment:
   As I was adjusting the error messages, I could not verify this one. 
Furthermore, I verified that the method 
`ParamProcessWorker#translateUuidToInternalId` already makes this verification. 
If the user puts an nonexistent UUID, or and UUID from another entity, the 
`translateUuidToInternalId` method already throws an exception, for these 
reasons I removed this `null` check.



-- 
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