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


##########
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());
         if (!VirtualMachine.State.Running.equals(userVm.getState()) && hostId 
!= null) {
-            throw new InvalidParameterValueException(String.format("VM ID: %s 
is not in Running state to migrate it to new host", userVm.getUuid()));
+            throw new InvalidParameterValueException(String.format("VM [%s] is 
not in the Running state to migrate it to the new host.", userVm));

Review Comment:
   As far as I know, `VirtualMachine.toString()` will end up executing the 
[VMInstanceVO.toString()](https://github.com/apache/cloudstack/blob/ea9124e49c6849828519402b9053557d0ff056a9/engine/schema/src/main/java/com/cloud/vm/VMInstanceVO.java#L504).
 Which would have a redundant "VM" in the log message.
   
   Can you please double-check and, if I am correct, change:
   - from
   `VM [VM instance {id: "123", name: "i-2-123-VM", uuid: 
"6c7d6c7d-6c7d-35fe-84d7-69b044600ffe", type="User"}] is not in Running ...`
   - to
   `VM instance {id: "123", name: "i-2-123-VM", uuid: 
"6c7d6c7d-6c7d-35fe-84d7-69b044600ffe", type="User"} is not in .Running ...`



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