mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 9330: ensure that console proxies are always created from the same hypervisor type
This commit is contained in:
parent
2a45327a89
commit
b56c82e3b6
@ -74,6 +74,8 @@ import com.cloud.exception.StorageUnavailableException;
|
|||||||
import com.cloud.host.Host.Type;
|
import com.cloud.host.Host.Type;
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
|
import com.cloud.hypervisor.Hypervisor;
|
||||||
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.info.ConsoleProxyConnectionInfo;
|
import com.cloud.info.ConsoleProxyConnectionInfo;
|
||||||
import com.cloud.info.ConsoleProxyInfo;
|
import com.cloud.info.ConsoleProxyInfo;
|
||||||
import com.cloud.info.ConsoleProxyLoadInfo;
|
import com.cloud.info.ConsoleProxyLoadInfo;
|
||||||
@ -528,8 +530,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
s_logger.warn("The number of launched console proxy on zone " + dataCenterId + " has reached to limit");
|
s_logger.warn("The number of launched console proxy on zone " + dataCenterId + " has reached to limit");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
HypervisorType currentHyp = currentHypervisorType(dataCenterId);
|
||||||
|
|
||||||
Map<String, Object> context = createProxyInstance(dataCenterId);
|
Map<String, Object> context = createProxyInstance(dataCenterId, currentHyp);
|
||||||
|
|
||||||
long proxyVmId = (Long) context.get("proxyVmId");
|
long proxyVmId = (Long) context.get("proxyVmId");
|
||||||
if (proxyVmId == 0) {
|
if (proxyVmId == 0) {
|
||||||
@ -558,7 +561,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, Object> createProxyInstance(long dataCenterId) throws ConcurrentOperationException {
|
protected Map<String, Object> createProxyInstance(long dataCenterId, HypervisorType desiredHyp) throws ConcurrentOperationException {
|
||||||
|
|
||||||
long id = _consoleProxyDao.getNextInSequence(Long.class, "id");
|
long id = _consoleProxyDao.getNextInSequence(Long.class, "id");
|
||||||
String name = VirtualMachineName.getConsoleProxyName(id, _instance);
|
String name = VirtualMachineName.getConsoleProxyName(id, _instance);
|
||||||
@ -582,7 +585,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false, false).get(0), null));
|
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false, false).get(0), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
VMTemplateVO template = _templateDao.findSystemVMTemplate(dataCenterId);
|
VMTemplateVO template = _templateDao.findSystemVMTemplate(dataCenterId, desiredHyp);
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
s_logger.debug("Can't find a template to start");
|
s_logger.debug("Can't find a template to start");
|
||||||
throw new CloudRuntimeException("Insufficient capacity exception");
|
throw new CloudRuntimeException("Insufficient capacity exception");
|
||||||
@ -869,6 +872,14 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
return l.size() < launchLimit;
|
return l.size() < launchLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HypervisorType currentHypervisorType(long dcId) {
|
||||||
|
List<ConsoleProxyVO> l = _consoleProxyDao.getProxyListInStates(dcId, VirtualMachine.State.Starting,
|
||||||
|
VirtualMachine.State.Running, VirtualMachine.State.Stopping, VirtualMachine.State.Stopped,
|
||||||
|
VirtualMachine.State.Migrating, VirtualMachine.State.Shutdowned, VirtualMachine.State.Unknown);
|
||||||
|
|
||||||
|
return l.size() > 0? l.get(0).getHypervisorType():HypervisorType.Any;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkCapacity(ConsoleProxyLoadInfo proxyCountInfo, ConsoleProxyLoadInfo vmCountInfo) {
|
private boolean checkCapacity(ConsoleProxyLoadInfo proxyCountInfo, ConsoleProxyLoadInfo vmCountInfo) {
|
||||||
|
|
||||||
if (proxyCountInfo.getCount() * _capacityPerProxy - vmCountInfo.getCount() <= _standbyCapacity) {
|
if (proxyCountInfo.getCount() * _capacityPerProxy - vmCountInfo.getCount() <= _standbyCapacity) {
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.DomainVO;
|
||||||
|
import com.cloud.hypervisor.Hypervisor;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
|
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
|
||||||
@ -67,6 +68,8 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long> {
|
|||||||
public List<VMTemplateVO> listByHypervisorType(HypervisorType hyperType);
|
public List<VMTemplateVO> listByHypervisorType(HypervisorType hyperType);
|
||||||
public List<VMTemplateVO> publicIsoSearch();
|
public List<VMTemplateVO> publicIsoSearch();
|
||||||
VMTemplateVO findSystemVMTemplate(long zoneId);
|
VMTemplateVO findSystemVMTemplate(long zoneId);
|
||||||
|
VMTemplateVO findSystemVMTemplate(long zoneId, HypervisorType hType);
|
||||||
|
|
||||||
VMTemplateVO findRoutingTemplate(HypervisorType type);
|
VMTemplateVO findRoutingTemplate(HypervisorType type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -475,6 +475,9 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
return tmplt;
|
return tmplt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (tmplts.size() > 0 && hType == HypervisorType.Any) {
|
||||||
|
return tmplts.get(0);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user