Backport PR#6919 last commit (#218)

This commit is contained in:
Nicolas Vazquez 2022-12-23 10:50:00 -03:00 committed by GitHub
parent 5c83f90096
commit f77ab62377
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 14 deletions

View File

@ -18,9 +18,8 @@ package org.apache.cloudstack.consoleproxy;
import com.cloud.utils.component.Manager;
import org.apache.cloudstack.api.command.user.consoleproxy.ConsoleEndpoint;
import org.apache.cloudstack.framework.config.Configurable;
public interface ConsoleAccessManager extends Manager, Configurable {
public interface ConsoleAccessManager extends Manager {
ConsoleEndpoint generateConsoleEndpoint(Long vmId, String extraSecurityToken, String clientAddress);

View File

@ -47,7 +47,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.apache.cloudstack.api.command.user.consoleproxy.ConsoleEndpoint;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.security.keys.KeysManager;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
@ -207,13 +206,14 @@ public class ConsoleAccessManagerImpl extends ManagerBase implements ConsoleAcce
throw new CloudRuntimeException(msg);
}
if (vm.getHostId() == null) {
Long hostId = vm.getState() != VirtualMachine.State.Migrating ? vm.getHostId() : vm.getLastHostId();
if (hostId == null) {
msg = "VM " + vmUuid + " lost host info, sending blank response for console access request";
s_logger.warn(msg);
throw new CloudRuntimeException(msg);
}
HostVO host = managementServer.getHostBy(vm.getHostId());
HostVO host = managementServer.getHostBy(hostId);
if (host == null) {
msg = "VM " + vmUuid + "'s host does not exist, sending blank response for console access request";
s_logger.warn(msg);
@ -465,13 +465,4 @@ public class ConsoleAccessManagerImpl extends ManagerBase implements ConsoleAcce
}
}
@Override
public String getConfigComponentName() {
return ConsoleAccessManagerImpl.class.getSimpleName();
}
@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey[] {};
}
}