Merge branch '4.16'

This commit is contained in:
nvazquez 2022-05-20 11:39:07 -03:00
commit 8ae977c233
No known key found for this signature in database
GPG Key ID: 656E1BCC8CB54F84
3 changed files with 14 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import javax.persistence.Table;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.uservm.UserVm;
import org.apache.commons.lang3.StringUtils;
@Entity
@Table(name = "user_vm")
@ -141,4 +142,8 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
public String getName() {
return instanceName;
}
public String getDisplayNameOrHostName() {
return StringUtils.isNotBlank(displayName) ? displayName : getHostName();
}
}

View File

@ -128,7 +128,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
userVmResponse.setName(userVm.getName());
if (userVm.getDisplayName() != null) {
userVmResponse.setDisplayName(userVm.getDisplayName());
userVmResponse.setDisplayName(userVm.getDisplayName());
} else {
userVmResponse.setDisplayName(userVm.getName());
}

View File

@ -3127,6 +3127,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
throw new InvalidParameterValueException("Unable to find a virtual machine with id " + vmId);
}
if (vmInstance.getState() != State.Running) {
throw new InvalidParameterValueException(String.format("The VM %s (%s) is not running, unable to reboot it",
vmInstance.getUuid(), vmInstance.getDisplayNameOrHostName()));
}
_accountMgr.checkAccess(caller, null, true, vmInstance);
checkIfHostOfVMIsInPrepareForMaintenanceState(vmInstance.getHostId(), vmId, "Reboot");
@ -5144,8 +5149,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId);
}
if (vm.getState()== State.Running) {
throw new InvalidParameterValueException("The virtual machine "+ vm.getUuid()+ " ("+ vm.getDisplayName()+ ") is already running");
if (vm.getState() == State.Running) {
throw new InvalidParameterValueException(String.format("The virtual machine %s (%s) is already running",
vm.getUuid(), vm.getDisplayNameOrHostName()));
}
_accountMgr.checkAccess(callerAccount, null, true, vm);