@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { Map<String, String> configs = _configDao.getConfiguration("Network", params); _numWorkerThreads = NumbersUtil.parseInt( configs.get(Config.SecurityGroupWorkerThreads.key()), WORKER_THREAD_COUNT); _timeBetweenCleanups = NumbersUtil.parseInt( configs.get(Config.SecurityGroupWorkCleanupInterval.key()), TIME_BETWEEN_CLEANUPS); _globalWorkLockTimeout = NumbersUtil.parseInt(configs.get(Config.SecurityGroupWorkGlobalLockTimeout.key()), 300); /* register state listener, no matter security group is enabled or not */ VirtualMachine.State.getStateMachine().registerListener(this); _answerListener = new SecurityGroupListener(this, _agentMgr, _workDao); _agentMgr.registerForHostEvents(_answerListener, true, true, true); _serverId = ((ManagementServer) ComponentLocator.getComponent(ManagementServer.Name)).getId(); s_logger.info( "SecurityGroupManager: num worker threads=" + _numWorkerThreads + ", time between cleanups=" + _timeBetweenCleanups + " global lock timeout=" + _globalWorkLockTimeout); createThreadPools(); return true; }
// Adapter implementation: (facilitates plug in loading) // Required because Discoverer extends Adapter // Overrides Adapter.configure to always return true // Inherit Adapter.getName // Inherit Adapter.stop // Inherit Adapter.start @Override public final boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException { super.configure(name, params); // TODO: allow timeout on we HTTPRequests to be configured _agentMgr.registerForHostEvents(this, true, false, true); _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); return true; }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { _vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600); _storageOverProvisioningFactor = NumbersUtil.parseFloat( _configDao.getValue(Config.StorageOverprovisioningFactor.key()), 1.0f); _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HostCapacity-Checker")); VirtualMachine.State.getStateMachine().registerListener(this); _agentManager.registerForHostEvents( new StorageCapacityListener(_capacityDao, _storageOverProvisioningFactor), true, false, false); _agentManager.registerForHostEvents( new ComputeCapacityListener(_capacityDao, this), true, false, false); return true; }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { _name = name; _isEnabled = Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())); if (_isEnabled) { _executorPool = Executors.newScheduledThreadPool(10, new NamedThreadFactory("OVS")); _cleanupExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("OVS-Cleanup")); _listener = new OvsTunnelListener(_tunnelDao, _hostDao); _agentMgr.registerForHostEvents(_listener, true, true, true); } return true; }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { if (s_logger.isInfoEnabled()) { s_logger.info("Start configuring AgentBasedConsoleProxyManager"); } _name = name; ComponentLocator locator = ComponentLocator.getCurrentLocator(); ConfigurationDao configDao = locator.getDao(ConfigurationDao.class); if (configDao == null) { throw new ConfigurationException("Unable to get the configuration dao."); } Map<String, String> configs = configDao.getConfiguration("management-server", params); String value = configs.get("consoleproxy.url.port"); if (value != null) { _consoleProxyUrlPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_URL_PORT); } value = configs.get("consoleproxy.port"); if (value != null) { _consoleProxyPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_VNC_PORT); } value = configs.get("consoleproxy.sslEnabled"); if (value != null && value.equalsIgnoreCase("true")) { _sslEnabled = true; } _instance = configs.get("instance.name"); _consoleProxyUrlDomain = configs.get("consoleproxy.url.domain"); _listener = new ConsoleProxyListener(this); _agentMgr.registerForHostEvents(_listener, true, true, false); _itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this); if (s_logger.isInfoEnabled()) { s_logger.info( "AgentBasedConsoleProxyManager has been configured. SSL enabled: " + _sslEnabled); } return true; }
@Override public boolean configure(String name, Map<String, Object> params) { final Map<String, String> configs = _configDao.getConfiguration("management-server", params); _proxy = configs.get(Config.SecStorageProxy.key()); String cert = configs.get("secstorage.ssl.cert.domain"); if (!"realhostip.com".equalsIgnoreCase(cert)) { s_logger.warn( "Only realhostip.com ssl cert is supported, ignoring self-signed and other certs"); } _copyAuthPasswd = configs.get("secstorage.copy.password"); DownloadListener dl = new DownloadListener(this); ComponentContext.inject(dl); _agentMgr.registerForHostEvents(dl, true, false, false); return true; }
@Override public boolean configure(String name, Map<String, Object> params) { final Map<String, String> configs = _configDao.getConfiguration("ManagementServer", params); _sslCopy = Boolean.parseBoolean(configs.get("secstorage.encrypt.copy")); _proxy = configs.get(Config.SecStorageProxy.key()); _ssvmUrlDomain = configs.get("secstorage.ssl.cert.domain"); _copyAuthPasswd = configs.get("secstorage.copy.password"); _agentMgr.registerForHostEvents(new DownloadListener(this), true, false, false); ReadyTemplateStatesSearch = _vmTemplateHostDao.createSearchBuilder(); ReadyTemplateStatesSearch.and( "download_state", ReadyTemplateStatesSearch.entity().getDownloadState(), SearchCriteria.Op.EQ); ReadyTemplateStatesSearch.and( "destroyed", ReadyTemplateStatesSearch.entity().getDestroyed(), SearchCriteria.Op.EQ); ReadyTemplateStatesSearch.and( "host_id", ReadyTemplateStatesSearch.entity().getHostId(), SearchCriteria.Op.EQ); SearchBuilder<VMTemplateVO> TemplatesWithNoChecksumSearch = _templateDao.createSearchBuilder(); TemplatesWithNoChecksumSearch.and( "checksum", TemplatesWithNoChecksumSearch.entity().getChecksum(), SearchCriteria.Op.NULL); ReadyTemplateStatesSearch.join( "vm_template", TemplatesWithNoChecksumSearch, TemplatesWithNoChecksumSearch.entity().getId(), ReadyTemplateStatesSearch.entity().getTemplateId(), JoinBuilder.JoinType.INNER); TemplatesWithNoChecksumSearch.done(); ReadyTemplateStatesSearch.done(); return true; }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { AllocatedIpSearch = _ipAddressDao.createSearchBuilder(); AllocatedIpSearch.and("allocated", AllocatedIpSearch.entity().getAllocatedTime(), Op.NNULL); AllocatedIpSearch.and("dc", AllocatedIpSearch.entity().getDataCenterId(), Op.EQ); SearchBuilder<NetworkVO> networkJoin = _networksDao.createSearchBuilder(); networkJoin.and("guestType", networkJoin.entity().getGuestType(), Op.EQ); AllocatedIpSearch.join( "network", networkJoin, AllocatedIpSearch.entity().getSourceNetworkId(), networkJoin.entity().getId(), JoinBuilder.JoinType.INNER); AllocatedIpSearch.done(); _networkStatsInterval = NumbersUtil.parseInt(_configDao.getValue(Config.DirectNetworkStatsInterval.key()), 86400); _TSinclZones = _configDao.getValue(Config.TrafficSentinelIncludeZones.key()); _TSexclZones = _configDao.getValue(Config.TrafficSentinelExcludeZones.key()); _agentMgr.registerForHostEvents( new DirectNetworkStatsListener(_networkStatsInterval), true, false, false); _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); return true; }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { _agentMgr.registerForHostEvents(this, true, false, false); _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); return super.configure(name, params); }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { s_logger.info("Configure VmwareManagerImpl, manager name: " + name); 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) { _storage = new JavaStorageLayer(); _storage.configure("StorageLayer", params); } value = _configDao.getValue(Config.VmwareCreateFullClone.key()); if (value == null) { _fullCloneFlag = false; } else { _fullCloneFlag = Boolean.parseBoolean(value); } _portsPerDvPortGroup = NumbersUtil.parseInt( _configDao.getValue(Config.VmwarePortsPerDVPortGroup.key()), _portsPerDvPortGroup); _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); _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); _agentMgr.registerForHostEvents(this, true, true, true); s_logger.info("VmwareManagerImpl has been successfully configured"); return true; }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { 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); } } _privateNetworkVSwitchName = configDao.getValue(Config.VmwarePrivateNetworkVSwitch.key()); if (_privateNetworkVSwitchName == null) { _privateNetworkVSwitchName = "vSwitch0"; } _publicNetworkVSwitchName = configDao.getValue(Config.VmwarePublicNetworkVSwitch.key()); if (_publicNetworkVSwitchName == null) { _publicNetworkVSwitchName = "vSwitch0"; } _guestNetworkVSwitchName = configDao.getValue(Config.VmwareGuestNetworkVSwitch.key()); if (_guestNetworkVSwitchName == null) { _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"; } configDao.getValue(Config.VmwareServiceConsole.key()); _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); } _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"; s_logger.info( "Additional VNC port allocation range is settled at " + _additionalPortRangeStart + " to " + (_additionalPortRangeStart + _additionalPortRangeSize)); value = configDao.getValue(Config.VmwareGuestNicDeviceType.key()); if (value == null || "E1000".equalsIgnoreCase(value)) this._guestNicDeviceType = VirtualEthernetCardType.E1000; else if ("PCNet32".equalsIgnoreCase(value)) this._guestNicDeviceType = VirtualEthernetCardType.PCNet32; else if ("Vmxnet2".equalsIgnoreCase(value)) this._guestNicDeviceType = VirtualEthernetCardType.Vmxnet2; else if ("Vmxnet3".equalsIgnoreCase(value)) this._guestNicDeviceType = VirtualEthernetCardType.Vmxnet3; else this._guestNicDeviceType = VirtualEthernetCardType.E1000; 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); _agentMgr.registerForHostEvents(this, true, true, true); s_logger.info("VmwareManagerImpl has been successfully configured"); return true; }
@Override public boolean configure(final String name, final Map<String, Object> xmlParams) throws ConfigurationException { _name = name; ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name); _serverId = ((ManagementServer) ComponentLocator.getComponent(ManagementServer.Name)).getId(); _investigators = locator.getAdapters(Investigator.class); _fenceBuilders = locator.getAdapters(FenceBuilder.class); Map<String, String> params = new HashMap<String, String>(); final ConfigurationDao configDao = locator.getDao(ConfigurationDao.class); if (configDao != null) { params = configDao.getConfiguration(Long.toHexString(_serverId), xmlParams); } String value = params.get("workers"); final int count = NumbersUtil.parseInt(value, 1); _workers = new WorkerThread[count]; for (int i = 0; i < _workers.length; i++) { _workers[i] = new WorkerThread("HA-Worker-" + i); } value = params.get("force.ha"); _forceHA = Boolean.parseBoolean(value); value = params.get("time.to.sleep"); _timeToSleep = NumbersUtil.parseInt(value, 60) * 1000; value = params.get("max.retries"); _maxRetries = NumbersUtil.parseInt(value, 5); value = params.get("time.between.failures"); _timeBetweenFailures = NumbersUtil.parseLong(value, 3600) * 1000; value = params.get("time.between.cleanup"); _timeBetweenCleanups = NumbersUtil.parseLong(value, 3600 * 24); value = params.get("wait"); _operationTimeout = NumbersUtil.parseInt(value, 1800) * 2; value = params.get("stop.retry.interval"); _stopRetryInterval = NumbersUtil.parseInt(value, 10 * 60); value = params.get("restart.retry.interval"); _restartRetryInterval = NumbersUtil.parseInt(value, 10 * 60); value = params.get("investigate.retry.interval"); _investigateRetryInterval = NumbersUtil.parseInt(value, 1 * 60); value = params.get("migrate.retry.interval"); _migrateRetryInterval = NumbersUtil.parseInt(value, 2 * 60); _instance = params.get("instance"); if (_instance == null) { _instance = "VMOPS"; } _stopped = true; _executor = Executors.newScheduledThreadPool(count, new NamedThreadFactory("HA")); _agentMgr.registerForHostEvents(new VmSyncListener(this, _agentMgr), true, true, true); return true; }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { if (s_logger.isInfoEnabled()) { s_logger.info("Start configuring secondary storage vm manager : " + 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."); } Map<String, String> configs = configDao.getConfiguration("management-server", params); _secStorageVmRamSize = NumbersUtil.parseInt(configs.get("secstorage.vm.ram.size"), DEFAULT_SS_VM_RAMSIZE); _secStorageVmCpuMHz = NumbersUtil.parseInt(configs.get("secstorage.vm.cpu.mhz"), DEFAULT_SS_VM_CPUMHZ); String useServiceVM = configDao.getValue("secondary.storage.vm"); boolean _useServiceVM = false; if ("true".equalsIgnoreCase(useServiceVM)) { _useServiceVM = true; } String sslcopy = configDao.getValue("secstorage.encrypt.copy"); if ("true".equalsIgnoreCase(sslcopy)) { _useSSlCopy = true; } _allowedInternalSites = configDao.getValue("secstorage.allowed.internal.sites"); String value = configs.get("secstorage.capacityscan.interval"); _capacityScanInterval = NumbersUtil.parseLong(value, DEFAULT_CAPACITY_SCAN_INTERVAL); _instance = configs.get("instance.name"); if (_instance == null) { _instance = "DEFAULT"; } Map<String, String> agentMgrConfigs = configDao.getConfiguration("AgentManager", params); _mgmt_host = agentMgrConfigs.get("host"); if (_mgmt_host == null) { s_logger.warn( "Critical warning! Please configure your management server host address right after you have started your management server and then restart it, otherwise you won't have access to secondary storage"); } value = agentMgrConfigs.get("port"); _mgmt_port = NumbersUtil.parseInt(value, 8250); _listener = new SecondaryStorageListener(this, _agentMgr); _agentMgr.registerForHostEvents(_listener, true, false, true); _itMgr.registerGuru(VirtualMachine.Type.SecondaryStorageVm, this); _useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key())); _serviceOffering = new ServiceOfferingVO( "System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, _secStorageVmCpuMHz, null, null, false, null, _useLocalStorage, true, null, true, VirtualMachine.Type.SecondaryStorageVm, true); _serviceOffering.setUniqueName("Cloud.com-SecondaryStorage"); _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering); // this can sometimes happen, if DB is manually or programmatically manipulated if (_serviceOffering == null) { String msg = "Data integrity problem : System Offering For Secondary Storage VM has been removed?"; s_logger.error(msg); throw new ConfigurationException(msg); } if (_useServiceVM) { _loadScanner = new SystemVmLoadScanner<Long>(this); _loadScanner.initScan(STARTUP_DELAY, _capacityScanInterval); } if (s_logger.isInfoEnabled()) { s_logger.info("Secondary storage vm Manager is configured."); } return true; }