Пример #1
0
    def _configure_slurm_probe(self):
        """
        Do SLURM probe specific configuration
        """
        config_location = GRATIA_CONFIG_FILES['slurm']
        buf = file(config_location).read()

        settings = self._probe_config['slurm']
        if not validation.valid_file(settings['db_pass']):
            self.log("Slurm DB password file not present",
                     level=logging.ERROR,
                     option='db_pass',
                     section='SLURM')
            return True

        buf = self.replace_setting(buf, 'SlurmDbHost', settings['db_host'])
        buf = self.replace_setting(buf, 'SlurmDbPort', settings['db_port'])
        buf = self.replace_setting(buf, 'SlurmDbUser', settings['db_user'])
        buf = self.replace_setting(buf, 'SlurmDbPasswordFile', settings['db_pass'])
        buf = self.replace_setting(buf, 'SlurmDbName', settings['db_name'])
        buf = self.replace_setting(buf, 'SlurmCluster', settings['cluster'])
        buf = self.replace_setting(buf, 'SlurmLocation', settings['location'])

        if not utilities.atomic_write(config_location, buf):
            return False
        return True
Пример #2
0
    def setup_gram_config(self):
        """
        Populate the gram config file with correct values

        Returns True if successful, False otherwise
        """
        buf = open(SGEConfiguration.GRAM_CONFIG_FILE).read()

        for binfile in ['qsub', 'qstat', 'qdel', 'qconf']:
            bin_location = os.path.join(self.options['sge_bin_location'].value, binfile)
            if validation.valid_file(bin_location):
                buf = utilities.add_or_replace_setting(buf, binfile, bin_location)

        for setting in ['sge_cell', 'sge_root', 'sge_config']:
            buf = utilities.add_or_replace_setting(buf, setting, self.options[setting].value)

        if self.options['seg_enabled'].value:
            buf = utilities.add_or_replace_setting(buf, 'log_path', self.options['log_file'].value)

        if self.options['default_queue'].value != '':
            buf = utilities.add_or_replace_setting(buf, 'default_queue', self.options['default_queue'].value)

            if self.options['validate_queues'].value:
                buf = utilities.add_or_replace_setting(buf, 'validate_queues', 'yes', quote_value=False)
            else:
                buf = utilities.add_or_replace_setting(buf, 'validate_queues', 'no', quote_value=False)

        if self.options['available_queues'].value != '':
            buf = utilities.add_or_replace_setting(buf, 'available_queues', self.options['available_queues'].value)

        if not utilities.atomic_write(SGEConfiguration.GRAM_CONFIG_FILE, buf):
            return False
        return True
Пример #3
0
    def setup_gram_config(self):
        """
        Populate the gram config file with correct values

        Returns True if successful, False otherwise
        """
        contents = open(PBSConfiguration.GRAM_CONFIG_FILE).read()
        for binfile in ['qsub', 'qstat', 'qdel']:
            bin_location = os.path.join(self.pbs_bin_location, binfile)
            if validation.valid_file(bin_location):
                contents = utilities.add_or_replace_setting(contents, binfile, bin_location)

        if self.options['pbs_server'].value != '':
            contents = utilities.add_or_replace_setting(contents, 'pbs_default', self.options['pbs_server'].value)

        if self.options['seg_enabled'].value:
            if (self.options['log_directory'].value is None or
                    not validation.valid_directory(self.options['log_directory'].value)):
                mesg = "%s is not a valid directory location " % self.options['log_directory'].value
                mesg += "for pbs log files"
                self.log(mesg,
                         section=self.config_section,
                         option='log_directory',
                         level=logging.ERROR)
                return False

            contents = utilities.add_or_replace_setting(contents, 'log_path', self.options['log_directory'].value)

        if not utilities.atomic_write(PBSConfiguration.GRAM_CONFIG_FILE, contents):
            return False

        return True
Пример #4
0
    def _enable_xacml(self):
        """
        Enable authorization services using xacml protocol
        """

        self.log("Updating " + GSI_AUTHZ_LOCATION, level=logging.INFO)

        gsi_contents = "globus_mapping liblcas_lcmaps_gt4_mapping.so lcmaps_callout\n"
        if not utilities.atomic_write(GSI_AUTHZ_LOCATION, gsi_contents):
            self.log("Error while writing to " + GSI_AUTHZ_LOCATION,
                     level=logging.ERROR)
            raise exceptions.ConfigureError("Error while writing to " +
                                            GSI_AUTHZ_LOCATION)

        self.log("Updating " + GUMS_CLIENT_LOCATION, level=logging.INFO)
        location_re = re.compile("^gums.location=.*$", re.MULTILINE)
        authz_re = re.compile("^gums.authz=.*$", re.MULTILINE)
        if not validation.valid_file(GUMS_CLIENT_LOCATION):
            gums_properties = "gums.location=https://%s:8443" % (self.options['gums_host'].value)
            gums_properties += "/gums/services/GUMSAdmin\n"
            gums_properties += "gums.authz=https://%s:8443" % (self.options['gums_host'].value)
            gums_properties += "/gums/services/GUMSXACMLAuthorizationServicePort"
        else:
            gums_properties = open(GUMS_CLIENT_LOCATION).read()
            replacement = "gums.location=https://%s:8443" % (self.options['gums_host'].value)
            replacement += "/gums/services/GUMSAdmin"
            gums_properties = location_re.sub(replacement, gums_properties)
            replacement = "gums.authz=https://%s:8443" % (self.options['gums_host'].value)
            replacement += "/gums/services/GUMSXACMLAuthorizationServicePort"
            gums_properties = authz_re.sub(replacement, gums_properties)
        utilities.atomic_write(GUMS_CLIENT_LOCATION, gums_properties)
Пример #5
0
    def setup_gram_config(self):
        """
        Populate the gram config file with correct values

        Returns True if successful, False otherwise
        """
        buf = open(LSFConfiguration.GRAM_CONFIG_FILE).read()
        for binfile in ['bsub', 'bqueues', 'bjobs', 'bhist', 'bacct', 'bkill']:
            bin_location = os.path.join(self.lsf_bin_location, binfile)
            if validation.valid_file(bin_location):
                buf = utilities.add_or_replace_setting(buf, binfile, 'bin_location')

        if self.options['seg_enabled'].value:
            if (self.options['log_directory'].value is None or
                    not validation.valid_directory(self.options['log_directory'].value)):
                mesg = "%s is not a valid directory location " % self.options['log_directory'].value
                mesg += "for lsf log files"
                self.log(mesg,
                         section=self.config_section,
                         option='log_directory',
                         level=logging.ERROR)
                return False

            buf = utilities.add_or_replace_setting(buf, 'log_path', self.options['log_directory'].value)

        buf = utilities.add_or_replace_setting(buf, 'lsf_profile', self.options['lsf_profile'].value)

        if not utilities.atomic_write(LSFConfiguration.GRAM_CONFIG_FILE, buf):
            return False
        return True
Пример #6
0
    def _update_lcmaps_file(self, gums=True):
        """
        Update lcmaps file and give appropriate messages if lcmaps.db.rpmnew exists
        """
        warning_message = """It appears that you've updated the lcmaps RPM and the
configuration has changed.
If you have ever edited /etc/lcmaps.db by hand (most people don't), then you
should:
   1. Edit /etc/lcmaps.db.rpmnew to make your changes again
   2. mv /etc/lcmaps.db.rpmnew /etc/lcmaps.db
If you haven't edited /etc/lcmaps.db by hand, then you can just use the new
configuration:
   1. mv /etc/lcmaps.db.rpmnew /etc/lcmaps.db"""

        files_to_update = [LCMAPS_DB_LOCATION]
        rpmnew_file = LCMAPS_DB_LOCATION + ".rpmnew"
        if validation.valid_file(rpmnew_file):
            self.log(warning_message, level=logging.WARNING)
            files_to_update.append(rpmnew_file)

        for lcmaps_db_file in files_to_update:
            self.log("Updating " + lcmaps_db_file, level=logging.INFO)
            lcmaps_db = open(lcmaps_db_file).read()

            lcmaps_db = self._update_lcmaps_text(lcmaps_db, gums, self.options['gums_host'].value)

            utilities.atomic_write(lcmaps_db_file, lcmaps_db)
Пример #7
0
    def configure(self, attributes):
        """Configure storage locations for ce usage"""

        self.log("StorageConfiguration.configure started")

        if not self.enabled:
            self.log("Not enabled, exiting")
            self.log("StorageConfiguration.configure completed")
            return True

        if self.options["app_dir"].value in ("UNSET", "UNAVAILABLE"):
            self.log("OSG_APP unset or unavailable, exiting")
            self.log("StorageConfiguration.configure completed")
            return True

        if self._app_dir_in_oasis(self.options["app_dir"].value):
            self.log("OSG_APP is in OASIS, exiting")
            self.log("StorageConfiguration.configure completed")
            return True

        status = True
        grid3_location = os.path.join(self.options["app_dir"].value, "etc", "grid3-locations.txt")
        if not validation.valid_file(grid3_location):
            grid3_source = os.path.join("/", "etc", "osg", "grid3-locations.txt")
            if not validation.valid_file(grid3_source):
                self.log("Can't get grid3-location file at %s" % (grid3_source), level=logging.WARNING)
                self.log("You will need to manually create one at %s" % (grid3_location), level=logging.WARNING)

            try:
                shutil.copyfile(grid3_source, grid3_location)
            except IOError:
                self.log(
                    "Can't copy grid3-location file from %s to %s" % (grid3_source, grid3_location),
                    level=logging.WARNING,
                )
            try:
                if validation.valid_file(grid3_location):
                    os.chmod(grid3_location, 0666)
            except IOError:
                self.log("Can't set permissions on grid3-location file at %s" % (grid3_location), level=logging.WARNING)

        self.log("StorageConfiguration.configure completed")
        return status
Пример #8
0
    def configure(self, attributes):
        """Configure installation using attributes"""
        self.log('MiscConfiguration.configure started')

        if not self.enabled:
            self.log('Not enabled')
            self.log('MiscConfiguration.configure completed')
            return True

        # run fetch-crl script
        if not utilities.fetch_crl():
            self.log("Error while running fetch-crl script", level=logging.ERROR)
            raise exceptions.ConfigureError('fetch-crl returned non-zero exit code')

        using_gums = False
        if self.options['authorization_method'].value == 'xacml':
            using_gums = True
            self._enable_xacml()
        elif self.options['authorization_method'].value == 'gridmap':
            self._disable_callout()
        elif self.options['authorization_method'].value == 'local-gridmap':
            self._disable_callout()
        else:
            self.log("Unknown authorization method: %s" % \
                     self.options['authorization_method'].value,
                     option='authorization_method',
                     section=self.config_section,
                     level=logging.ERROR)
            raise exceptions.ConfigureError("Invalid authorization_method option " +
                                            "in Misc Services")

        if self.options['edit_lcmaps_db'].value:
            if validation.valid_file(LCMAPS_DB_LOCATION):
                self._update_lcmaps_file(using_gums)
            else:
                self.log("Not updating lcmaps.db because it's not accessible",
                         level=logging.DEBUG)
        else:
            self.log("Not updating lcmaps.db because edit_lcmaps_db is false",
                     level=logging.DEBUG)

        if self.htcondor_gateway_enabled:
            self.write_gridmap_to_htcondor_ce_config()

        ensure_valid_user_vo_file(using_gums, logger=self.logger)
        # Call configure_vdt_cleanup (enabling or disabling as necessary)
        self._configure_cleanup()

        self.log('MiscConfiguration.configure completed')
        return True
Пример #9
0
    def setup_gram_config(self):
        """
        Populate the gram config file with correct values

        Returns True if successful, False otherwise
        """
        contents = open(SlurmConfiguration.GRAM_CONFIG_FILE).read()
        for binfile in ['qsub', 'qstat', 'qdel']:
            bin_location = os.path.join(self.slurm_bin_location, binfile)
            if validation.valid_file(bin_location):
                contents = utilities.add_or_replace_setting(contents, binfile, bin_location)

        if not utilities.atomic_write(SlurmConfiguration.GRAM_CONFIG_FILE, contents):
            return False

        return True
Пример #10
0
    def setup_gram_config(self):
        """
        Populate the gram config file with correct values

        Returns True if successful, False otherwise
        """

        buf = open(CondorConfiguration.GRAM_CONFIG_FILE).read()
        for binfile in ['condor_submit', 'condor_rm']:
            bin_location = os.path.join(self.condor_bin_location, binfile)
            if validation.valid_file(bin_location):
                buf = utilities.add_or_replace_setting(buf, binfile, bin_location)
        if not utilities.blank(self.options['condor_config'].value):
            buf = utilities.add_or_replace_setting(buf, 'condor_config', self.options['condor_config'].value)

        if not utilities.atomic_write(CondorConfiguration.GRAM_CONFIG_FILE, buf):
            return False

        return True
Пример #11
0
    def _update_lcmaps_file(self):
        """
        Update lcmaps file and give appropriate messages if lcmaps.db.rpmnew exists
        """

        self.log("Updating " + LCMAPS_DB_LOCATION, level=logging.INFO)
        lcmaps_db = open(LCMAPS_DB_LOCATION).read()
        endpoint_re = re.compile(r'^\s*"--endpoint\s+https://.*/gums/services.*"\s*$',
                                 re.MULTILINE)
        replacement = "             \"--endpoint https://%s:8443" % (self.options['gums_host'].value)
        replacement += "/gums/services/GUMSXACMLAuthorizationServicePort\""
        lcmaps_db = endpoint_re.sub(replacement, lcmaps_db)
        utilities.atomic_write(LCMAPS_DB_LOCATION, lcmaps_db)

        rpmnew_file = LCMAPS_DB_LOCATION + ".rpmnew"
        warning_message = """It appears that you've updated the lcmaps RPM and the
configuration has changed. 
If you have ever edited /etc/lcmaps.db by hand (most people don't), then you 
should:
   1. Edit /etc/lcmaps.db.rpmnew to make your changes again
   2. mv /etc/lcmaps.db.rpmnew /etc/lcmaps.db
If you haven't edited /etc/lcmaps.db by hand, then you can just use the new 
configuration:
   1. mv /etc/lcmaps.db.rpmnew /etc/lcmaps.db"""
        if validation.valid_file(rpmnew_file):
            self.log(warning_message, level=logging.WARNING)
        else:
            return

        lcmaps_db = open(rpmnew_file).read()
        endpoint_re = re.compile(r'^\s*"--endpoint\s+https://.*/gums/services.*"\s*$',
                                 re.MULTILINE)
        replacement = "             \"--endpoint https://%s:8443" % (self.options['gums_host'].value)
        replacement += "/gums/services/GUMSXACMLAuthorizationServicePort\""
        lcmaps_db = endpoint_re.sub(replacement, lcmaps_db)
        utilities.atomic_write(rpmnew_file, lcmaps_db)
Пример #12
0
    def check_attributes(self, attributes):
        """Check attributes currently stored and make sure that they are consistent"""
        self.log('SGEConfiguration.check_attributes started')
        attributes_ok = True
        if not self.enabled:
            self.log('SGE not enabled, returning True')
            self.log('SGEConfiguration.check_attributes completed')
            return attributes_ok

        if self.ignored:
            self.log('Ignored, returning True')
            self.log('SGEConfiguration.check_attributes completed')
            return attributes_ok

        # make sure locations exist
        if not validation.valid_location(self.options['sge_root'].value):
            attributes_ok = False
            self.log("Non-existent location given: %s" %
                     (self.options['sge_root'].value),
                     option='sge_root',
                     section=self.config_section,
                     level=logging.ERROR)

        settings_file = os.path.join(self.options['sge_root'].value,
                                     self.options['sge_cell'].value,
                                     'common',
                                     'settings.sh')

        if not validation.valid_file(settings_file):
            attributes_ok = False
            self.log("$SGE_ROOT/$SGE_CELL/common/settings.sh not present: %s" %
                     settings_file,
                     option='sge_cell',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_directory(self.options['sge_bin_location'].value):
            attributes_ok = False
            self.log("sge_bin_location not valid: %s" % self.options['sge_bin_location'].value,
                     option='sge_bin_location',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['job_contact'].value,
                                        'sge'):
            attributes_ok = False
            self.log("Invalid job contact: %s" %
                     (self.options['job_contact'].value),
                     option='job_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['util_contact'].value,
                                        'sge'):
            attributes_ok = False
            self.log("Invalid util contact: %s" %
                     (self.options['util_contact'].value),
                     option='util_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        if self.options['seg_enabled'].value:
            if (self.options['log_file'].value is None or
                    not validation.valid_file(self.options['log_file'].value)):
                mesg = "%s is not a valid file path " % self.options['log_file'].value
                mesg += "for sge log files"
                self.log(mesg,
                         section=self.config_section,
                         option='log_file',
                         level=logging.ERROR)
                attributes_ok = False

        key = 'sge_config'
        if (not self.options[key].value or
                not validation.valid_file(self.options[key].value)):
            attributes_ok = False
            self.log("%s is not a valid file: %s" % (key, self.options[key].value),
                     section=self.config_section,
                     option=key,
                     level=logging.ERROR)

        self.log('SGEConfiguration.check_attributes completed')
        return attributes_ok
Пример #13
0
    def check_attributes(self, attributes):
        """Check attributes currently stored and make sure that they are consistent"""
        self.log('LSFConfiguration.check_attributes started')

        attributes_ok = True

        if not self.enabled:
            self.log('LSF not enabled, returning True')
            self.log('LSFConfiguration.check_attributes completed')
            return attributes_ok

        if self.ignored:
            self.log('Ignored, returning True')
            self.log('LSFConfiguration.check_attributes completed')
            return attributes_ok


        # make sure locations exist
        if not validation.valid_location(self.options['lsf_location'].value):
            attributes_ok = False
            self.log("Non-existent location given: %s" %
                     (self.options['lsf_location'].value),
                     option='lsf_location',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_directory(self.lsf_bin_location):
            attributes_ok = False
            self.log("Given lsf_location %r has no bin/ directory" % self.options['lsf_location'].value,
                     option='lsf_location',
                     section=self.config_section,
                     level=logging.ERROR)

        if self.options['lsf_conf'].value and not validation.valid_directory(self.options['lsf_conf'].value):
            attributes_ok = False
            self.log("Non-existent directory given: %s" %
                     (self.options['lsf_conf'].value),
                     option='lsf_conf',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_file(self.options['lsf_profile'].value):
            attributes_ok = False
            self.log("Non-existent location given: %s" %
                     (self.options['lsf_profile'].value),
                     option='lsf_profile',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['job_contact'].value,
                                        'lsf'):
            attributes_ok = False
            self.log("Invalid job contact: %s" %
                     (self.options['job_contact'].value),
                     option='job_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['util_contact'].value,
                                        'lsf'):
            attributes_ok = False
            self.log("Invalid util contact: %s" %
                     (self.options['util_contact'].value),
                     option='util_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        self.log('LSFConfiguration.check_attributes completed')
        return attributes_ok
Пример #14
0
    def check_attributes(self, attributes):
        """Check attributes currently stored and make sure that they are consistent"""
        self.log('SGEConfiguration.check_attributes started')
        attributes_ok = True
        if not self.enabled:
            self.log('SGE not enabled, returning True')
            self.log('SGEConfiguration.check_attributes completed')
            return attributes_ok

        if self.ignored:
            self.log('Ignored, returning True')
            self.log('SGEConfiguration.check_attributes completed')
            return attributes_ok

        # make sure locations exist
        if not validation.valid_location(self.options['sge_root'].value):
            attributes_ok = False
            self.log("Non-existent location given: %s" %
                     (self.options['sge_root'].value),
                     option='sge_root',
                     section=self.config_section,
                     level=logging.ERROR)

        settings_file = os.path.join(self.options['sge_root'].value,
                                     self.options['sge_cell'].value, 'common',
                                     'settings.sh')

        if not validation.valid_file(settings_file):
            attributes_ok = False
            self.log("$SGE_ROOT/$SGE_CELL/common/settings.sh not present: %s" %
                     settings_file,
                     option='sge_cell',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_directory(
                self.options['sge_bin_location'].value):
            attributes_ok = False
            self.log("sge_bin_location not valid: %s" %
                     self.options['sge_bin_location'].value,
                     option='sge_bin_location',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['job_contact'].value,
                                        'sge'):
            attributes_ok = False
            self.log("Invalid job contact: %s" %
                     (self.options['job_contact'].value),
                     option='job_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['util_contact'].value,
                                        'sge'):
            attributes_ok = False
            self.log("Invalid util contact: %s" %
                     (self.options['util_contact'].value),
                     option='util_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        if self.options['seg_enabled'].value:
            if (self.options['log_file'].value is None or
                    not validation.valid_file(self.options['log_file'].value)):
                mesg = "%s is not a valid file path " % self.options[
                    'log_file'].value
                mesg += "for sge log files"
                self.log(mesg,
                         section=self.config_section,
                         option='log_file',
                         level=logging.ERROR)
                attributes_ok = False

        key = 'sge_config'
        if (not self.options[key].value
                or not validation.valid_file(self.options[key].value)):
            attributes_ok = False
            self.log("%s is not a valid file: %s" %
                     (key, self.options[key].value),
                     section=self.config_section,
                     option=key,
                     level=logging.ERROR)

        self.log('SGEConfiguration.check_attributes completed')
        return attributes_ok
Пример #15
0
    def check_attributes(self, attributes):
        """Check attributes currently stored and make sure that they are consistent"""
        self.log('BoscoConfiguration.check_attributes started')

        attributes_ok = True

        if not self.enabled:
            self.log('Bosco not enabled, returning True')
            self.log('BoscoConfiguration.check_attributes completed')
            return attributes_ok

        if self.ignored:
            self.log('Ignored, returning True')
            self.log('BoscoConfiguration.check_attributes completed')
            return attributes_ok

        if self.options['batch'].value not in [
                'pbs', 'lsf', 'sge', 'condor', 'slurm'
        ]:
            attributes_ok = False
            self.log("Batch attribute is not valid: %s" %
                     (self.options['batch'].value),
                     option='batch',
                     section=self.config_section,
                     level=logging.ERROR)

        # TODO: check if the ssh_key has the correct permissions!
        if not validation.valid_file(self.options['ssh_key'].value):
            attributes_ok = False
            self.log("ssh_key given is not a file: %s" %
                     (self.options['ssh_key'].value),
                     option='ssh_key',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_integer(self.options['max_jobs'].value):
            attributes_ok = False
            self.log("max_jobs is not an integer: %s" %
                     (self.options['max_jobs'].value),
                     option='max_jobs',
                     section=self.config_section,
                     level=logging.ERROR)

        # Split the users, comma seperated
        split_users = self.options['users'].value.split(',')
        for user in split_users:
            if not validation.valid_user(user.strip()):
                attributes_ok = False
                self.log("%s is not a valid user" % (user.strip()),
                         option='users',
                         section=self.config_section,
                         level=logging.ERROR)

        # TODO: validate list of usernames

        endpoint = self.options['endpoint'].value
        if len(endpoint.split('@')) != 2:
            attributes_ok = False
            self.log("endpoint not in user@host format: %s" % endpoint,
                     option='endpoint',
                     section=self.config_section,
                     level=logging.ERROR)

        if self.opt_val("install_cluster") not in [
                "always", "never", "if_needed"
        ]:
            self.log("install_cluster attribute is not valid: %s" %
                     self.opt_val("install_cluster"),
                     option="install_cluster",
                     section=self.config_section,
                     level=logging.ERROR)

        self.log('BoscoConfiguration.check_attributes completed')
        return attributes_ok
Пример #16
0
    def check_attributes(self, attributes):
        """Check attributes currently stored and make sure that they are consistent"""
        self.log('LSFConfiguration.check_attributes started')

        attributes_ok = True

        if not self.enabled:
            self.log('LSF not enabled, returning True')
            self.log('LSFConfiguration.check_attributes completed')
            return attributes_ok

        if self.ignored:
            self.log('Ignored, returning True')
            self.log('LSFConfiguration.check_attributes completed')
            return attributes_ok

        # make sure locations exist
        if not validation.valid_location(self.options['lsf_location'].value):
            attributes_ok = False
            self.log("Non-existent location given: %s" %
                     (self.options['lsf_location'].value),
                     option='lsf_location',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_directory(self.lsf_bin_location):
            attributes_ok = False
            self.log("Given lsf_location %r has no bin/ directory" %
                     self.options['lsf_location'].value,
                     option='lsf_location',
                     section=self.config_section,
                     level=logging.ERROR)

        if self.options['lsf_conf'].value and not validation.valid_directory(
                self.options['lsf_conf'].value):
            attributes_ok = False
            self.log("Non-existent directory given: %s" %
                     (self.options['lsf_conf'].value),
                     option='lsf_conf',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_file(self.options['lsf_profile'].value):
            attributes_ok = False
            self.log("Non-existent location given: %s" %
                     (self.options['lsf_profile'].value),
                     option='lsf_profile',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['job_contact'].value,
                                        'lsf'):
            attributes_ok = False
            self.log("Invalid job contact: %s" %
                     (self.options['job_contact'].value),
                     option='job_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['util_contact'].value,
                                        'lsf'):
            attributes_ok = False
            self.log("Invalid util contact: %s" %
                     (self.options['util_contact'].value),
                     option='util_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        self.log('LSFConfiguration.check_attributes completed')
        return attributes_ok
Пример #17
0
    def check_attributes(self, attributes):
        """Check attributes currently stored and make sure that they are consistent"""
        self.log('BoscoConfiguration.check_attributes started')
        
        attributes_ok = True
        
        if not self.enabled:
            self.log('Bosco not enabled, returning True')
            self.log('BoscoConfiguration.check_attributes completed')
            return attributes_ok

        if self.ignored:
            self.log('Ignored, returning True')
            self.log('BoscoConfiguration.check_attributes completed')
            return attributes_ok
            
        #if not validation.valid_domain(self.options['endpoint'].value):
        #    attributes_ok = False
        #    self.log("Endpoint is not a valid hostname: %s" % 
        #             (self.options['endpoint'].value),
        #             option='endpoint',
        #             section=self.config_section,
        #             level=logging.ERROR)
        
        if self.options['batch'].value not in ['pbs', 'lsf', 'sge', 'condor', 'slurm']:
            attributes_ok = False
            self.log("Batch attribute is not valid: %s" % 
                     (self.options['batch'].value),
                     option='batch',
                     section=self.config_section,
                     level=logging.ERROR)
        
        # Change the  batch value to pbs if it slurm, for now
        if self.options['batch'].value is 'slurm':
            self.options['batch'].value = 'pbs'
        
        # TODO: check if the ssh_key has the correct permissions!
        if not validation.valid_file(self.options['ssh_key'].value):
            attributes_ok = False
            self.log("ssh_key given is not a file: %s" %
                     (self.options['ssh_key'].value),
                     option='ssh_key',
                     section=self.config_section,
                     level=logging.ERROR)
        
        
        if not validation.valid_integer(self.options['max_jobs'].value):
            attributes_ok = False
            self.log("max_jobs is not an integer: %s" %
                     (self.options['max_jobs'].value),
                     option='max_jobs',
                     section=self.config_section,
                     level=logging.ERROR)
        
        # Split the users, comma seperated
        split_users = self.options['users'].value.split(',')
        for user in split_users:
            if not validation.valid_user(user.strip()):
                attributes_ok = False
                self.log("%s is not a valid user" %
                         (user.strip()),
                         option='users',
                         section=self.config_section,
                         level=logging.ERROR)

        # TODO: validate list of usernames

        endpoint = self.options['endpoint'].value
        if len(endpoint.split('@')) != 2:
            attributes_ok = False
            self.log("endpoint not in user@host format: %s" %
                     endpoint,
                     option='endpoint',
                     section=self.config_section,
                     level=logging.ERROR)
        
        self.log('BoscoConfiguration.check_attributes completed')
        return attributes_ok
Пример #18
0
    def check_attributes(self, attributes):
        """Check attributes currently stored and make sure that they are consistent"""
        self.log('CondorConfiguration.check_attributes started')

        if not self.enabled:
            self.log('CondorConfiguration.check_attributes completed returning True')
            return True

        if self.ignored:
            self.log('CondorConfiguration.check_attributes completed returning True')
            return True

        attributes_ok = True

        # make sure locations exist
        self.log('checking condor_location')
        if not validation.valid_location(self.options['condor_location'].value):
            attributes_ok = False
            self.log("Non-existent location given: %s" %
                     (self.options['condor_location'].value),
                     option='condor_location',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_directory(self.condor_bin_location):
            attributes_ok = False
            self.log("Given condor_location %r has no bin/ directory" % self.options['condor_location'].value,
                     option='condor_location',
                     section=self.config_section,
                     level=logging.ERROR)

        self.log('checking condor_config')
        if not validation.valid_file(self.options['condor_config'].value):
            attributes_ok = False
            self.log("Non-existent location given: %s" %
                     (self.options['condor_config'].value),
                     option='condor_config',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['job_contact'].value,
                                        'condor'):
            attributes_ok = False
            self.log("Invalid job contact: %s" %
                     (self.options['job_contact'].value),
                     option='job_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        if not validation.valid_contact(self.options['util_contact'].value,
                                        'condor'):
            attributes_ok = False
            self.log("Invalid util contact: %s" %
                     (self.options['util_contact'].value),
                     option='util_contact',
                     section=self.config_section,
                     level=logging.ERROR)

        self.log('CondorConfiguration.check_attributes completed returning %s' \
                 % attributes_ok)
        return attributes_ok
Пример #19
0
    def _check_auth_settings(self):
        """ Check authorization/certificate settings and make sure that they are valid """

        check_value = True

        # Do not allow both the service cert settings and proxy settings
        # first create some helper variables
        blank_service_vals = (
            utilities.blank(self.options['service_cert'].value)
            and utilities.blank(self.options['service_key'].value)
            and utilities.blank(self.options['service_proxy'].value))

        default_service_vals = (self.options['service_cert'].value ==
                                self.options['service_cert'].default_value)
        default_service_vals &= (self.options['service_key'].value ==
                                 self.options['service_key'].default_value)
        default_service_vals &= (self.options['service_proxy'].value ==
                                 self.options['service_proxy'].default_value)

        blank_user_proxy = utilities.blank(self.options['user_proxy'].value)

        if (not blank_user_proxy and default_service_vals):
            self.log('User proxy specified and service_cert, service_key, ' +
                     'service_proxy at default values, assuming user_proxy ' +
                     'takes precedence in ' + self.config_section + ' section')
            self.use_service_cert = False
        elif not blank_user_proxy and not blank_service_vals:
            self.log(
                "You cannot specify user_proxy with any of (service_cert, " +
                "service_key, service_proxy).  They are mutually exclusive " +
                "options in %s section." % self.config_section,
                level=logging.ERROR)
            check_value = False

        # Make sure that either a service cert or user cert is selected
        if not ((self.options['service_cert'].value
                 and self.options['service_key'].value
                 and self.options['service_proxy'].value)
                or self.options['user_proxy'].value):
            self.log("You must specify either service_cert/service_key/" +
                     "service_proxy *or* user_proxy in order to provide " +
                     "credentials for RSV to run jobs in " +
                     " %s section" % self.config_section,
                     level=logging.ERROR)
            check_value = False

        if not blank_user_proxy:
            # if not using a service certificate, make sure that the proxy file exists
            value = self.options['user_proxy'].value
            if utilities.blank(value) or not validation.valid_file(value):
                self.log("user_proxy does not point to an existing file: %s" %
                         value,
                         section=self.config_section,
                         option='user_proxy',
                         level=logging.ERROR)
                check_value = False
        else:
            for optname in 'service_cert', 'service_key':
                value = self.options[optname].value
                if utilities.blank(value):
                    self.log("%s must have a valid location" % optname,
                             section=self.config_section,
                             option=optname,
                             level=logging.ERROR)
                    check_value = False
                elif not self.copy_host_cert_for_service_cert and not validation.valid_file(
                        value):
                    self.log("%s must point to an existing file" % optname,
                             section=self.config_section,
                             option=optname,
                             level=logging.ERROR)
                    check_value = False

            value = self.options['service_proxy'].value
            if utilities.blank(value):
                self.log("service_proxy must have a valid location: %s" %
                         value,
                         section=self.config_section,
                         option='service_proxy',
                         level=logging.ERROR)
                check_value = False

            value = os.path.dirname(self.options['service_proxy'].value)
            if not validation.valid_location(value):
                self.log("service_proxy must be located in a valid " +
                         "directory: %s" % value,
                         section=self.config_section,
                         option='service_proxy',
                         level=logging.ERROR)
                check_value = False

        return check_value