def get_attributes(self, converter=str): """ Get attributes for the osg attributes file using the dict in self.options Returns a dictionary of ATTRIBUTE => value mappings Need to override parent class method since two options may map to OSG_SITE_NAME """ self.log("%s.get_attributes started" % self.__class__) attributes = BaseConfiguration.get_attributes(self) if self.ignored: self.log("%s.get_attributes completed" % self.__class__) return dict( zip([ item.mapping for item in self.options.values() if item.is_mappable() ], [ str(item.value) for item in self.options.values() if item.is_mappable() ])) elif not self.enabled: self.log("%s.get_attributes completed" % self.__class__) return attributes elif self.options['location'].value in ('None', 'UNAVAILABLE'): del attributes['OSG_SQUID_LOCATION'] self.log("Blank location or location set to UNAVAILABLE, " + "not setting environment variable") self.log("%s.get_attributes completed" % self.__class__) return attributes self.log("%s.get_attributes completed" % self.__class__) return attributes
def get_attributes(self, converter=str): """ Get attributes for the osg attributes file using the dict in self.options Returns a dictionary of ATTRIBUTE => value mappings Need to override parent class method since two options may map to OSG_SITE_NAME """ self.log("%s.get_attributes started" % self.__class__) attributes = BaseConfiguration.get_attributes(self, converter) if attributes == {}: self.log("%s.get_attributes completed" % self.__class__) return attributes if ( "OSG_SITE_NAME" in attributes and self.options["resource"].value is not None and not utilities.blank(self.options["resource"].value) ): attributes["OSG_SITE_NAME"] = self.options["resource"].value self.log("%s.get_attributes completed" % self.__class__) return attributes
def get_attributes(self, converter=str): """ Get attributes for the osg attributes file using the dict in self.options Returns a dictionary of ATTRIBUTE => value mappings Need to override parent class method since two options may map to OSG_SITE_NAME """ self.log("%s.get_attributes started" % self.__class__) attributes = BaseConfiguration.get_attributes(self) if self.ignored: self.log("%s.get_attributes completed" % self.__class__) return dict( zip( [item.mapping for item in self.options.values() if item.is_mappable()], [str(item.value) for item in self.options.values() if item.is_mappable()], ) ) elif not self.enabled: self.log("%s.get_attributes completed" % self.__class__) return attributes elif self.options["location"].value in ("None", "UNAVAILABLE"): del attributes["OSG_SQUID_LOCATION"] self.log("Blank location or location set to UNAVAILABLE, " + "not setting environment variable") self.log("%s.get_attributes completed" % self.__class__) return attributes self.log("%s.get_attributes completed" % self.__class__) return attributes
def get_attributes(self, converter=str): """ Get attributes for the osg attributes file using the dict in self.options Returns a dictionary of ATTRIBUTE => value mappings Need to override parent class method since OSG_MANAGEDFORK is bool and needs to be mapped to Y/N """ self.log("%s.get_attributes started" % self.__class__) attributes = BaseConfiguration.get_attributes(self, converter=convert_values) if attributes == {}: attributes['OSG_MANAGEDFORK'] = 'N' self.log("%s.get_attributes completed" % self.__class__) return attributes
def get_attributes(self, converter=str): """ Get attributes for the osg attributes file using the dict in self.options Returns a dictionary of ATTRIBUTE => value mappings Need to override parent class method since two options may map to OSG_SITE_NAME """ self.log("%s.get_attributes started" % self.__class__) attributes = BaseConfiguration.get_attributes(self, converter) if attributes == {}: self.log("%s.get_attributes completed" % self.__class__) return attributes if ('OSG_SITE_NAME' in attributes and self.options['resource'].value is not None and not utilities.blank(self.options['resource'].value)): attributes['OSG_SITE_NAME'] = self.options['resource'].value self.log("%s.get_attributes completed" % self.__class__) return attributes
def parse_configuration(self, configuration): """ Try to get configuration information from ConfigParser or SafeConfigParser object given by configuration and write recognized settings to attributes dict """ self.log('GratiaConfiguration.parse_configuration started') self.check_config(configuration) if (not configuration.has_section(self.config_section) and requirements_are_installed()): self.log('CE probes installed but no Gratia section, auto-configuring gratia') self._auto_configure(configuration) self.log('GratiaConfiguration.parse_configuration completed') return True elif not configuration.has_section(self.config_section): self.enabled = False self.log("%s section not in config file" % self.config_section) self.log('Gratia.parse_configuration completed') return if not self.set_status(configuration): self.log('GratiaConfiguration.parse_configuration completed') return True # set the appropriate defaults if we're on a CE if requirements_are_installed(): if configuration.has_option('Site Information', 'group'): self.grid_group = configuration.get('Site Information', 'group') if self.grid_group == 'OSG': self.options['probes'].default_value = \ self._production_defaults['probes'] elif self.grid_group == 'OSG-ITB': self.options['probes'].default_value = \ self._itb_defaults['probes'] # grab configuration information for various jobmanagers probes = self.get_installed_probes() for probe in probes: if probe == 'condor': self._probe_config['condor'] = {'condor_location': CondorConfiguration.get_condor_location(configuration), 'condor_config': CondorConfiguration.get_condor_config(configuration)} elif probe == 'pbs': if BaseConfiguration.section_disabled(configuration, 'PBS'): # if the PBS jobmanager is disabled, the CE is probably using LSF # in any case, setting up the pbs gratia probe is not useful continue log_option = configfile.Option(name='log_directory', required=configfile.Option.OPTIONAL, default_value='') configfile.get_option(configuration, 'PBS', log_option) self._probe_config['pbs'] = {'log_directory': log_option.value} accounting_log_option = configfile.Option(name='accounting_log_directory', required=configfile.Option.OPTIONAL, default_value='') configfile.get_option(configuration, 'PBS', accounting_log_option) self._probe_config['pbs'] = {'accounting_log_directory': accounting_log_option.value} elif probe == 'lsf': if BaseConfiguration.section_disabled(configuration, 'LSF'): # if the LSF jobmanager is disabled, the CE is probably using PBS # in any case, setting up the pbs gratia probe is not useful continue lsf_location = configfile.Option(name='lsf_location', default_value='/usr/bin') configfile.get_option(configuration, 'LSF', lsf_location) self._probe_config['lsf'] = {'lsf_location': lsf_location.value} log_option = configfile.Option(name='log_directory', required=configfile.Option.OPTIONAL, default_value='') configfile.get_option(configuration, 'LSF', log_option) self._probe_config['lsf']['log_directory'] = log_option.value elif probe == 'sge': if BaseConfiguration.section_disabled(configuration, 'SGE'): # if section is disabled then the following code won't work # since the parse_configuration will short circuit, so # give a warning and then move on self.log("Skipping SGE gratia probe configuration since SGE is disabled", level=logging.WARNING) continue sge_config = SGEConfiguration(logger=self.logger) sge_config.parse_configuration(configuration) self._probe_config['sge'] = {'sge_accounting_file': sge_config.get_accounting_file()} elif probe == 'slurm': if BaseConfiguration.section_disabled(configuration, 'SLURM'): # if section is disabled then the following code won't work # since the parse_configuration will short circuit, so # give a warning and then move on self.log("Skipping Slurm gratia probe configuration since Slurm is disabled", level=logging.WARNING) continue slurm_config = SlurmConfiguration(logger=self.logger) slurm_config.parse_configuration(configuration) self._probe_config['slurm'] = {'db_host': slurm_config.get_db_host(), 'db_port': slurm_config.get_db_port(), 'db_user': slurm_config.get_db_user(), 'db_pass': slurm_config.get_db_pass(), 'db_name': slurm_config.get_db_name(), 'cluster': slurm_config.get_slurm_cluster(), 'location': slurm_config.get_location()} self.get_options(configuration, ignore_options=['itb-jobmanager-gratia', 'itb-gridftp-gratia', 'osg-jobmanager-gratia', 'osg-gridftp-gratia', 'enabled']) if utilities.blank(self.options['probes'].value): self.log('GratiaConfiguration.parse_configuration completed') return self._parse_probes(self.options['probes'].value) self.log('GratiaConfiguration.parse_configuration completed')
def parse_configuration(self, configuration): """ Try to get configuration information from ConfigParser or SafeConfigParser object given by configuration and write recognized settings to attributes dict """ self.log('GratiaConfiguration.parse_configuration started') self.check_config(configuration) if (not configuration.has_section(self.config_section) and requirements_are_installed()): self.log( 'CE probes installed but no Gratia section, auto-configuring gratia' ) self._auto_configure(configuration) self.log('GratiaConfiguration.parse_configuration completed') return True elif not configuration.has_section(self.config_section): self.enabled = False self.log("%s section not in config file" % self.config_section) self.log('Gratia.parse_configuration completed') return if not self.set_status(configuration): self.log('GratiaConfiguration.parse_configuration completed') return True # set the appropriate defaults if we're on a CE if requirements_are_installed(): if configuration.has_option('Site Information', 'group'): self.grid_group = configuration.get('Site Information', 'group') if self.grid_group == 'OSG': self.options['probes'].default_value = \ self._production_defaults['probes'] elif self.grid_group == 'OSG-ITB': self.options['probes'].default_value = \ self._itb_defaults['probes'] # grab configuration information for various jobmanagers probes = self.get_installed_probes() for probe in probes: if probe == 'condor': self._probe_config['condor'] = { 'condor_location': CondorConfiguration.get_condor_location(configuration), 'condor_config': CondorConfiguration.get_condor_config(configuration) } elif probe == 'pbs': if BaseConfiguration.section_disabled( configuration, 'PBS'): # if the PBS jobmanager is disabled, the CE is probably using LSF # in any case, setting up the pbs gratia probe is not useful continue log_option = configfile.Option( name='log_directory', required=configfile.Option.OPTIONAL, default_value='') configfile.get_option(configuration, 'PBS', log_option) self._probe_config['pbs'] = { 'log_directory': log_option.value } accounting_log_option = configfile.Option( name='accounting_log_directory', required=configfile.Option.OPTIONAL, default_value='') configfile.get_option(configuration, 'PBS', accounting_log_option) self._probe_config['pbs'] = { 'accounting_log_directory': accounting_log_option.value } elif probe == 'lsf': if BaseConfiguration.section_disabled( configuration, 'LSF'): # if the LSF jobmanager is disabled, the CE is probably using PBS # in any case, setting up the pbs gratia probe is not useful continue lsf_location = configfile.Option(name='lsf_location', default_value='/usr/bin') configfile.get_option(configuration, 'LSF', lsf_location) self._probe_config['lsf'] = { 'lsf_location': lsf_location.value } log_option = configfile.Option( name='log_directory', required=configfile.Option.OPTIONAL, default_value='') configfile.get_option(configuration, 'LSF', log_option) self._probe_config['lsf'][ 'log_directory'] = log_option.value elif probe == 'sge': if BaseConfiguration.section_disabled( configuration, 'SGE'): # if section is disabled then the following code won't work # since the parse_configuration will short circuit, so # give a warning and then move on self.log( "Skipping SGE gratia probe configuration since SGE is disabled", level=logging.WARNING) continue sge_config = SGEConfiguration(logger=self.logger) sge_config.parse_configuration(configuration) self._probe_config['sge'] = { 'sge_accounting_file': sge_config.get_accounting_file() } elif probe == 'slurm': if BaseConfiguration.section_disabled( configuration, 'SLURM'): # if section is disabled then the following code won't work # since the parse_configuration will short circuit, so # give a warning and then move on self.log( "Skipping Slurm gratia probe configuration since Slurm is disabled", level=logging.WARNING) continue slurm_config = SlurmConfiguration(logger=self.logger) slurm_config.parse_configuration(configuration) self._probe_config['slurm'] = { 'db_host': slurm_config.get_db_host(), 'db_port': slurm_config.get_db_port(), 'db_user': slurm_config.get_db_user(), 'db_pass': slurm_config.get_db_pass(), 'db_name': slurm_config.get_db_name(), 'cluster': slurm_config.get_slurm_cluster(), 'location': slurm_config.get_location() } elif probe == 'htcondor-ce': self._probe_config['htcondor-ce'] = {} self.get_options(configuration, ignore_options=[ 'itb-jobmanager-gratia', 'itb-gridftp-gratia', 'osg-jobmanager-gratia', 'osg-gridftp-gratia', 'enabled' ]) if utilities.blank(self.options['probes'].value): self.log('GratiaConfiguration.parse_configuration completed') return self._parse_probes(self.options['probes'].value) self.log('GratiaConfiguration.parse_configuration completed')