Example #1
0
    def parse_configuration(self, configuration):
        """
        Try to get configuration information from ConfigParser or SafeConfigParser
        object given by configuration and write recognized settings to options dict
        """
        self.log('MiscConfiguration.parse_configuration started')

        self.check_config(configuration)

        if not configuration.has_section(self.config_section):
            self.enabled = False
            self.log("%s section not in config files" % self.config_section)
            self.log('MiscConfiguration.parse_configuration completed')
            return

        self.enabled = True
        self.get_options(configuration, ignore_options=IGNORED_OPTIONS)

        self.htcondor_gateway_enabled = utilities.config_safe_getboolean(
            configuration, 'Gateway', 'htcondor_gateway_enabled', True)
        self.authorization_method = self.options['authorization_method'].value
        self.using_glexec = not utilities.blank(
            self.options['glexec_location'].value)
        self.all_fqans = self.options['all_fqans'].value

        self.log('MiscConfiguration.parse_configuration completed')
Example #2
0
    def parse_configuration(self, configuration):
        """
        Try to get configuration information from ConfigParser or SafeConfigParser
        object given by configuration and write recognized settings to options dict
        """
        self.log('MiscConfiguration.parse_configuration started')

        self.check_config(configuration)

        if not configuration.has_section(self.config_section):
            self.enabled = False
            self.log("%s section not in config files" % self.config_section)
            self.log('MiscConfiguration.parse_configuration completed')
            return

        self.enabled = True
        self.get_options(configuration)

        self.htcondor_gateway_enabled = utilities.config_safe_getboolean(configuration, 'Gateway',
                                                                         'htcondor_gateway_enabled', True)

        self.log('MiscConfiguration.parse_configuration completed')
Example #3
0
def check_section(config, section):
    """
    Check attributes related to a subcluster and make sure that they are consistent
    """
    if "changeme" in section.lower():
        msg = "You have a section named '%s', you must change this name.\n" % section
        raise exceptions.SettingError(msg)

    for option, value in ENTRIES.items():
        status, kind = value
        entry = check_entry(config, section, option, status, kind)
        if option in BANNED_ENTRIES and entry == BANNED_ENTRIES[option]:
            raise exceptions.SettingError("Value for %s in section %s is " \
                                          "a default or banned entry (%s); " \
                                          "you must change this value." % \
                                          (option, section, BANNED_ENTRIES[option]))
        if entry is None:
            continue

        try:
            range_min, range_max = ENTRY_RANGES[option]

            if not (range_min <= entry <= range_max):
                msg = (
                    "Value for %(option)s in section %(section)s is outside allowed range"
                    ", %(range_min)d-%(range_max)d" % locals())
                raise exceptions.SettingError(msg)
        except KeyError:
            pass

    # Special case: Pilot sections either need "os" specified or "require_singularity=true"
    if is_pilot(section):
        require_singularity = utilities.config_safe_getboolean(
            config, section, "require_singularity", True)
        os = utilities.config_safe_get(config, section, "os", None)

        if not require_singularity and not os:
            msg = "'os' must be specified in section %s if 'require_singularity' is false" % section
            raise exceptions.SettingError(msg)
Example #4
0
 def csgbool(section, option):
     return utilities.config_safe_getboolean(configuration, section,
                                             option, False)
Example #5
0
 def safegetbool(option: str, default=None) -> bool:
     return utilities.config_safe_getboolean(config, section, option,
                                             default)
 def csgbool(section, option):
     return utilities.config_safe_getboolean(configuration, section, option, False)