bug 12139: add a way to specifiy which hypervisor used to start system vm:

Admin can either configure system.vm.default.hypervisor which is a global configuration for all zones, or call updatezone add defaultSystemVMHypervisorType
status 12139: resolved fixed
This commit is contained in:
Edison Su 2012-01-10 15:09:10 -08:00
parent 924953220b
commit 9bcb2affff
7 changed files with 80 additions and 4 deletions

View File

@ -184,7 +184,8 @@ public enum Config {
// UpgradeURL("Advanced", ManagementServer.class, String.class, "upgrade.url", "http://example.com:8080/client/agent/update.zip", "The upgrade URL is the URL of the management server that agents will connect to in order to automatically upgrade.", null),
SystemVMUseLocalStorage("Advanced", ManagementServer.class, Boolean.class, "system.vm.use.local.storage", "false", "Indicates whether to use local storage pools or shared storage pools for system VMs.", null),
SystemVMAutoReserveCapacity("Advanced", ManagementServer.class, Boolean.class, "system.vm.auto.reserve.capacity", "true", "Indicates whether or not to automatically reserver system VM standby capacity.", null),
CPUOverprovisioningFactor("Advanced", ManagementServer.class, String.class, "cpu.overprovisioning.factor", "1", "Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)", null),
SystemVMDefaultHypervisor("Advanced", ManagementServer.class, String.class, "system.vm.default.hypervisor", null, "Hypervisor type used to create system vm", null),
CPUOverprovisioningFactor("Advanced", ManagementServer.class, String.class, "cpu.overprovisioning.factor", "1", "Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)", null),
MemOverprovisioningFactor("Advanced", ManagementServer.class, String.class, "mem.overprovisioning.factor", "1", "Used for memory overprovisioning calculation", null),
LinkLocalIpNums("Advanced", ManagementServer.class, Integer.class, "linkLocalIp.nums", "10", "The number of link local ip that needed by domR(in power of 2)", null),
HypervisorList("Advanced", ManagementServer.class, String.class, "hypervisor.list", HypervisorType.KVM + "," + HypervisorType.XenServer + "," + HypervisorType.VMware + "," + HypervisorType.BareMetal + "," + HypervisorType.Ovm, "The list of hypervisors that this deployment will use.", "hypervisorList"),

View File

@ -527,9 +527,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
s_logger.warn("The number of launched console proxy on zone " + dataCenterId + " has reached to limit");
return null;
}
HypervisorType currentHyp = currentHypervisorType(dataCenterId);
HypervisorType defaultHype = _resourceMgr.getAvailableHypervisor(dataCenterId);
Map<String, Object> context = createProxyInstance(dataCenterId, currentHyp);
Map<String, Object> context = createProxyInstance(dataCenterId, defaultHype);
long proxyVmId = (Long) context.get("proxyVmId");
if (proxyVmId == 0) {

View File

@ -1317,6 +1317,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
//Router is the network element, we don't know the hypervisor type yet.
//Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up
List<HypervisorType> supportedHypervisors = new ArrayList<HypervisorType>();
HypervisorType defaults = _resourceMgr.getDefaultHypervisor(dest.getDataCenter().getId());
if (defaults != HypervisorType.None) {
supportedHypervisors.add(defaults);
}
if (dest.getCluster() != null) {
if (dest.getCluster().getHypervisorType() == HypervisorType.Ovm) {

View File

@ -133,4 +133,8 @@ public interface ResourceManager extends ResourceService{
List<PodCluster> listByDataCenter(long dcId);
List<HostVO> listAllNotInMaintenanceHostsInOneZone(Type type, Long dcId);
HypervisorType getDefaultHypervisor(long zoneId);
HypervisorType getAvailableHypervisor(long zoneId);
}

View File

@ -64,6 +64,7 @@ import com.cloud.capacity.CapacityVO;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.cluster.ClusterManager;
import com.cloud.cluster.ManagementServerNode;
import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.ClusterVO;
@ -109,9 +110,11 @@ import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.StorageService;
import com.cloud.storage.Swift;
import com.cloud.storage.SwiftVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.dao.GuestOSCategoryDao;
import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.storage.dao.StoragePoolHostDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.secondary.SecondaryStorageVmManager;
import com.cloud.storage.swift.SwiftManager;
import com.cloud.template.VirtualMachineTemplate;
@ -199,12 +202,15 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
protected StoragePoolHostDao _storagePoolHostDao;
@Inject(adapter = PodAllocator.class)
protected Adapters<PodAllocator> _podAllocators = null;
@Inject
protected VMTemplateDao _templateDao;
protected long _nodeId = ManagementServerNode.getManagementServerId();
protected HashMap<String, ResourceStateAdapter> _resourceStateAdapters = new HashMap<String, ResourceStateAdapter>();
protected HashMap<Integer, List<ResourceListener>> _lifeCycleListeners = new HashMap<Integer, List<ResourceListener>>();
private HypervisorType _defaultSystemVMHypervisor;
private void insertListener(Integer event, ResourceListener listener) {
List<ResourceListener> lst = _lifeCycleListeners.get(event);
@ -1199,6 +1205,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
_name = name;
_defaultSystemVMHypervisor = HypervisorType.getType(_configDao.getValue(Config.SystemVMDefaultHypervisor.toString()));
return true;
}
@ -1237,6 +1244,62 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
return hypervisorTypes;
}
@Override
public HypervisorType getDefaultHypervisor(long zoneId) {
HypervisorType defaultHyper = HypervisorType.None;
if (_defaultSystemVMHypervisor != HypervisorType.None) {
defaultHyper = _defaultSystemVMHypervisor;
}
DataCenterVO dc = _dcDao.findById(zoneId);
if (dc == null) {
return HypervisorType.None;
}
_dcDao.loadDetails(dc);
String defaultHypervisorInZone = dc.getDetail("defaultSystemVMHypervisorType");
if (defaultHypervisorInZone != null) {
defaultHyper = HypervisorType.getType(defaultHypervisorInZone);
}
List<VMTemplateVO> systemTemplates = _templateDao.listAllSystemVMTemplates();
boolean isValid = false;
for (VMTemplateVO template : systemTemplates) {
if (template.getHypervisorType() == defaultHyper) {
isValid = true;
break;
}
}
if (isValid) {
List<ClusterVO> clusters = _clusterDao.listByDcHyType(zoneId, defaultHyper.toString());
if (clusters.size() <= 0) {
isValid = false;
}
}
if (isValid) {
return defaultHyper;
} else {
return HypervisorType.None;
}
}
@Override
public HypervisorType getAvailableHypervisor(long zoneId) {
HypervisorType defaultHype = getDefaultHypervisor(zoneId);
if (defaultHype == HypervisorType.None) {
List<HypervisorType> supportedHypes = getSupportedHypervisorTypes(zoneId, false, null);
if (supportedHypes.size() > 0) {
defaultHype = supportedHypes.get(0);
}
}
if (defaultHype == HypervisorType.None) {
defaultHype = HypervisorType.Any;
}
return defaultHype;
}
@Override
public void registerResourceStateAdapter(String name, ResourceStateAdapter adapter) {

View File

@ -875,6 +875,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
String time = configs.get("storage.cleanup.interval");
_storageCleanupInterval = NumbersUtil.parseInt(time, 86400);
s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled + ", interval: " + _storageCleanupInterval + ", template cleanup enabled: " + _templateCleanupEnabled);
String workers = configs.get("expunge.workers");

View File

@ -540,7 +540,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
return new HashMap<String, Object>();
}
VMTemplateVO template = _templateDao.findSystemVMTemplate(dataCenterId);
HypervisorType hypeType = _resourceMgr.getAvailableHypervisor(dataCenterId);
VMTemplateVO template = _templateDao.findSystemVMTemplate(dataCenterId, hypeType);
if (template == null) {
s_logger.debug("Can't find a template to start");
throw new CloudRuntimeException("Insufficient capacity exception");