shwstppr commented on code in PR #6397:
URL: https://github.com/apache/cloudstack/pull/6397#discussion_r875854675
##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -3130,6 +3130,10 @@ public UserVm rebootVirtualMachine(RebootVMCmd cmd)
throws InsufficientCapacityE
throw new InvalidParameterValueException("Unable to find a virtual
machine with id " + vmId);
}
+ if (!vmInstance.getState().equals(State.Running)) {
+ throw new InvalidParameterValueException("The VM with id " + vmId
+ " is not in Running state");
Review Comment:
@nvazquez do we need to return VM's db ID?
```
(local) 🍄 > reboot virtualmachine id=f8ebcf1d-122f-4206-b0c8-107beb8085ec
{
"accountid": "ee787a1c-d6a4-11ec-9a2d-645d8651f45a",
"cmd": "org.apache.cloudstack.api.command.admin.vm.RebootVMCmdByAdmin",
"completed": "2022-05-18T18:15:34+0530",
"created": "2022-05-18T18:15:34+0530",
"jobid": "9bbee9da-252a-423c-873c-dcae24ebd945",
"jobinstanceid": "f8ebcf1d-122f-4206-b0c8-107beb8085ec",
"jobinstancetype": "VirtualMachine",
"jobprocstatus": 0,
"jobresult": {
"errorcode": 431,
"errortext": "The VM with id 3 is not in Running state"
},
"jobresultcode": 530,
"jobresulttype": "object",
"jobstatus": 2,
"userid": "ee7954bc-d6a4-11ec-9a2d-645d8651f45a"
}
```
```suggestion
if (!State.Running.equals(vmInstance.getState())) {
throw new InvalidParameterValueException(String.format("The VM
%s is not in %s state", StringUtils.firstNonBlank(vmInstance.getDisplayName(),
vmInstance.getName(), vmInstance.getUuid()), State.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]