blob: 63e4589212c53f8670e97fb550c6c7ee33f534ed [file] [log] [blame]
showardd1ee1dd2009-01-07 21:33:08 +00001import common
2from autotest_lib.client.common_lib import global_config
3
4CONFIG_SECTION = 'SCHEDULER'
5
6class SchedulerConfig(object):
7 """
8 Contains configuration that can be changed during scheduler execution.
9 """
Alex Millerac189f32014-06-23 13:55:23 -070010 FIELDS = [
11 ('max_processes_per_drone', int),
12 ('max_processes_warning_threshold', float),
Alex Millerac189f32014-06-23 13:55:23 -070013 ('clean_interval_minutes', int),
14 ('max_parse_processes', int),
15 ('tick_pause_sec', float),
16 ('max_transfer_processes', int),
17 ('secs_to_wait_for_atomic_group_hosts', int),
18 ('reverify_period_minutes', int),
19 ('reverify_max_hosts_at_once', int),
20 ('max_repair_limit', int),
21 ('max_provision_retries', int),
22 ]
showardd1ee1dd2009-01-07 21:33:08 +000023
showard77182562009-06-10 00:16:05 +000024
showardd1ee1dd2009-01-07 21:33:08 +000025 def __init__(self):
26 self.read_config()
27
28
29 def read_config(self):
Paul Hobbsb92af21b2015-04-09 15:12:41 -070030 """
31 Reads the attributes (listed in `FIELDS`) from the global config
32 and copies them into self.
33 """
showardd1ee1dd2009-01-07 21:33:08 +000034 config = global_config.global_config
35 config.parse_config_file()
Alex Millerac189f32014-06-23 13:55:23 -070036 for field, data_type in self.FIELDS:
showardd1ee1dd2009-01-07 21:33:08 +000037 setattr(self, field, config.get_config_value(CONFIG_SECTION,
Alex Millerac189f32014-06-23 13:55:23 -070038 field,
Fang Deng9a0c6c32013-09-04 15:34:55 -070039 type=data_type))
showardd1ee1dd2009-01-07 21:33:08 +000040
showard77182562009-06-10 00:16:05 +000041
showardd1ee1dd2009-01-07 21:33:08 +000042config = SchedulerConfig()