Ejemplo n.º 1
0
 def server_configs_from_parser(self, parser):
     """ The following has nothing to deal with Supervisor's server configurations.
     It gets Supvisors configuration.
     Supervisor's ServerOptions has not been designed to be specialized.
     This method is overriden just to have an access point to the Supervisor parser. """
     configs = ServerOptions.server_configs_from_parser(self, parser)
     # set section
     if not parser.has_section(SupvisorsServerOptions._Section):
         raise ValueError('.ini file ({}) does not include a [{}] section'.format(self.configfile, self._Section))
     temp, parser.mysection = parser.mysection, self._Section
     # get values
     opt = self.supvisors_options
     opt.address_list = list(OrderedDict.fromkeys(filter(None, list_of_strings(parser.getdefault('address_list', gethostname())))))
     opt.rules_file = parser.getdefault('rules_file', None)
     if opt.rules_file:
         opt.rules_file = existing_dirpath(opt.rules_file)
     opt.internal_port = self.to_port_num(parser.getdefault('internal_port', '65001'))
     opt.event_port = self.to_port_num(parser.getdefault('event_port', '65002'))
     opt.auto_fence = boolean(parser.getdefault('auto_fence', 'false'))
     opt.synchro_timeout = self.to_timeout(parser.getdefault('synchro_timeout', '15'))
     opt.conciliation_strategy = self.to_conciliation_strategy(parser.getdefault('conciliation_strategy', 'USER'))
     opt.starting_strategy = self.to_starting_strategy(parser.getdefault('starting_strategy', 'CONFIG'))
     # configure statistics
     opt.stats_periods = self.to_periods(list_of_strings(parser.getdefault('stats_periods', '10')))
     opt.stats_histo = self.to_histo(parser.getdefault('stats_histo', 200))
     opt.stats_irix_mode = boolean(parser.getdefault('stats_irix_mode', 'false'))
     # configure logger
     opt.logfile = existing_dirpath(parser.getdefault('logfile', '{}.log'.format(SupvisorsServerOptions._Section)))
     opt.logfile_maxbytes = byte_size(parser.getdefault('logfile_maxbytes', '50MB'))
     opt.logfile_backups = integer(parser.getdefault('logfile_backups', 10))
     opt.loglevel = logging_level(parser.getdefault('loglevel', 'info'))
     # reset mysection and return original result
     parser.mysection = temp
     return configs
Ejemplo n.º 2
0
 def load_process_rules(self, process):
     self.logger.trace('searching program element for {}'.format(process.namespec()))
     program_elt = self.get_program_element(process)
     rules = process.rules
     if program_elt is not None:
         # get addresses rule
         self.get_program_addresses(program_elt, rules)
         # get start_sequence rule
         value = program_elt.findtext('start_sequence')
         try:
             rules.start_sequence = int(value)
             if rules.start_sequence < 0:
                 raise
         except:
             rules.start_sequence = 0
         # get stop_sequence rule
         value = program_elt.findtext('stop_sequence')
         try:
             rules.stop_sequence = int(value)
             if rules.stop_sequence < 0:
                 raise
         except:
             rules.stop_sequence = 0
         # get required rule
         value = program_elt.findtext('required')
         try:
             rules.required = boolean(value)
         except:
             rules.required = False
         # get wait_exit rule
         value = program_elt.findtext('wait_exit')
         try:
             rules.wait_exit = boolean(value)
         except:
             rules.wait_exit = False
         # get expected_loading rule
         value = program_elt.findtext('expected_loading')
         try:
             rules.expected_loading = int(value)
             if not 0 <= rules.expected_loading <= 100:
                 raise
         except:
             rules.expected_loading = 1
         # get running_failure_strategy rule
         value = program_elt.findtext('running_failure_strategy')
         if value:
             strategy = RunningFailureStrategies._from_string(value)
             if strategy:
                 rules.running_failure_strategy = strategy
         # check that rules are compliant with dependencies
         rules.check_dependencies(process.namespec())
         self.logger.debug('process {} - rules {}'.format(process.namespec(), rules))
Ejemplo n.º 3
0
 def test_boolean_returns_false_for_upper_falsy_values(self):
     for s in map(str.upper, datatypes.FALSY_STRINGS):
         actual = datatypes.boolean(s)
         self.assertEqual(actual, False)
Ejemplo n.º 4
0
 def test_boolean_returns_true_for_upper_truthy_values(self):
     for s in map(str.upper, datatypes.TRUTHY_STRINGS):
         actual = datatypes.boolean(s)
         self.assert_(actual, True)
Ejemplo n.º 5
0
 def test_boolean_returns_true_for_truthy_values(self):
     for s in datatypes.TRUTHY_STRINGS:
         actual = datatypes.boolean(s)
         self.assertEqual(actual, True)
Ejemplo n.º 6
0
 def _callFUT(self, arg):
     return datatypes.boolean(arg)
Ejemplo n.º 7
0
 def test_boolean_returns_true_for_truthy_values(self):
     for s in datatypes.TRUTHY_STRINGS:
         actual = datatypes.boolean(s)
         self.assertEqual(actual, True)
Ejemplo n.º 8
0
 def test_boolean_returns_true_for_upper_truthy_values(self):
     for s in map(str.upper, datatypes.TRUTHY_STRINGS):
         actual = datatypes.boolean(s)
         self.assert_(actual, True)
Ejemplo n.º 9
0
 def _callFUT(self, arg):
     return datatypes.boolean(arg)
Ejemplo n.º 10
0
 def authorization(self, data):
     """ Extract authorization and address from data and process event. """
     self.logger.blather('got authorization event: {}'.format(data))
     # split the line received
     address_name, authorized = tuple(x.split(':')[1] for x in data.split())
     self.fsm.on_authorization(address_name, boolean(authorized))
Ejemplo n.º 11
0
 def test_boolean_returns_false_for_upper_falsy_values(self):
     for s in map(str.upper, datatypes.FALSY_STRINGS):
         actual = datatypes.boolean(s)
         self.assertEqual(actual, False)
Ejemplo n.º 12
0
 def authorization(self, data):
     """ Extract authorization and address from data and process event. """
     self.logger.trace('got authorization event: {}'.format(data))
     # split the line received
     address_name, authorized = tuple(x.split(':')[1] for x in data.split())
     self.fsm.on_authorization(address_name, boolean(authorized))
def safe_boolean(value):
    try:
        return boolean(value)
    except ValueError:
        return value