s_logger.info("Configure VmwareManagerImpl, manager name: " + name);
_name = name;
ComponentLocator locator = ComponentLocator.getCurrentLocator();
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
if (configDao == null) {
throw new ConfigurationException("Unable to get the configuration dao.");
}
if(!configDao.isPremium()) {
s_logger.error("Vmware component can only run under premium distribution");
throw new ConfigurationException("Vmware component can only run under premium distribution");
}
_instance = configDao.getValue(Config.InstanceName.key());
if (_instance == null) {
_instance = "DEFAULT";
}
s_logger.info("VmwareManagerImpl config - instance.name: " + _instance);
_mountParent = configDao.getValue(Config.MountParent.key());
if (_mountParent == null) {
_mountParent = File.separator + "mnt";
}
if (_instance != null) {
_mountParent = _mountParent + File.separator + _instance;
}
s_logger.info("VmwareManagerImpl config - _mountParent: " + _mountParent);
String value = (String)params.get("scripts.timeout");
_timeout = NumbersUtil.parseInt(value, 1440) * 1000;
_storage = (StorageLayer)params.get(StorageLayer.InstanceConfigKey);
if (_storage == null) {
value = (String)params.get(StorageLayer.ClassConfigKey);
if (value == null) {
value = "com.cloud.storage.JavaStorageLayer";
}
try {
Class<?> clazz = Class.forName(value);
_storage = (StorageLayer)ComponentLocator.inject(clazz);
_storage.configure("StorageLayer", params);
} catch (ClassNotFoundException e) {
throw new ConfigurationException("Unable to find class " + value);
}
}
value = configDao.getValue(Config.VmwareUseNexusVSwitch.key());
if(value == null) {
_nexusVSwitchActive = false;
}
else
{
_nexusVSwitchActive = Boolean.parseBoolean(value);
}
_privateNetworkVSwitchName = configDao.getValue(Config.VmwarePrivateNetworkVSwitch.key());
if (_privateNetworkVSwitchName == null) {
if (_nexusVSwitchActive) {
_privateNetworkVSwitchName = "privateEthernetPortProfile";
} else {
_privateNetworkVSwitchName = "vSwitch0";
}
}
_publicNetworkVSwitchName = configDao.getValue(Config.VmwarePublicNetworkVSwitch.key());
if (_publicNetworkVSwitchName == null) {
if (_nexusVSwitchActive) {
_publicNetworkVSwitchName = "publicEthernetPortProfile";
} else {
_publicNetworkVSwitchName = "vSwitch0";
}
}
_guestNetworkVSwitchName = configDao.getValue(Config.VmwareGuestNetworkVSwitch.key());
if (_guestNetworkVSwitchName == null) {
if (_nexusVSwitchActive) {
_guestNetworkVSwitchName = "guestEthernetPortProfile";
} else {
_guestNetworkVSwitchName = "vSwitch0";
}
}
_serviceConsoleName = configDao.getValue(Config.VmwareServiceConsole.key());
if(_serviceConsoleName == null) {
_serviceConsoleName = "Service Console";
}
_managemetPortGroupName = configDao.getValue(Config.VmwareManagementPortGroup.key());
if(_managemetPortGroupName == null) {
_managemetPortGroupName = "Management Network";
}
_defaultSystemVmNicAdapterType = configDao.getValue(Config.VmwareSystemVmNicDeviceType.key());
if(_defaultSystemVmNicAdapterType == null)
_defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString();
_additionalPortRangeStart = NumbersUtil.parseInt(configDao.getValue(Config.VmwareAdditionalVncPortRangeStart.key()), 59000);
if(_additionalPortRangeStart > 65535) {
s_logger.warn("Invalid port range start port (" + _additionalPortRangeStart + ") for additional VNC port allocation, reset it to default start port 59000");
_additionalPortRangeStart = 59000;
}
_additionalPortRangeSize = NumbersUtil.parseInt(configDao.getValue(Config.VmwareAdditionalVncPortRangeSize.key()), 1000);
if(_additionalPortRangeSize < 0 || _additionalPortRangeStart + _additionalPortRangeSize > 65535) {
s_logger.warn("Invalid port range size (" + _additionalPortRangeSize + " for range starts at " + _additionalPortRangeStart);
_additionalPortRangeSize = Math.min(1000, 65535 - _additionalPortRangeStart);
}
_routerExtraPublicNics = NumbersUtil.parseInt(configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
_maxHostsPerCluster = NumbersUtil.parseInt(configDao.getValue(Config.VmwarePerClusterHostMax.key()), VmwareManager.MAX_HOSTS_PER_CLUSTER);
_cpuOverprovisioningFactor = configDao.getValue(Config.CPUOverprovisioningFactor.key());
if(_cpuOverprovisioningFactor == null || _cpuOverprovisioningFactor.isEmpty())
_cpuOverprovisioningFactor = "1";
_memOverprovisioningFactor = configDao.getValue(Config.MemOverprovisioningFactor.key());
if(_memOverprovisioningFactor == null || _memOverprovisioningFactor.isEmpty())
_memOverprovisioningFactor = "1";
_reserveCpu = configDao.getValue(Config.VmwareReserveCpu.key());
if(_reserveCpu == null || _reserveCpu.isEmpty())
_reserveCpu = "false";
_reserveMem = configDao.getValue(Config.VmwareReserveMem.key());
if(_reserveMem == null || _reserveMem.isEmpty())
_reserveMem = "false";
_recycleHungWorker = configDao.getValue(Config.VmwareRecycleHungWorker.key());
if(_recycleHungWorker == null || _recycleHungWorker.isEmpty())
_recycleHungWorker = "false";
_rootDiskController = configDao.getValue(Config.VmwareRootDiskControllerType.key());
if(_rootDiskController == null || _rootDiskController.isEmpty())
_rootDiskController = DiskControllerType.ide.toString();
s_logger.info("Additional VNC port allocation range is settled at " + _additionalPortRangeStart + " to " + (_additionalPortRangeStart + _additionalPortRangeSize));
value = configDao.getValue("vmware.host.scan.interval");
_hostScanInterval = NumbersUtil.parseLong(value, DEFAULT_HOST_SCAN_INTERVAL);
s_logger.info("VmwareManagerImpl config - vmware.host.scan.interval: " + _hostScanInterval);
((VmwareStorageManagerImpl)_storageMgr).configure(params);