Esempio n. 1
0
    def setup_htcondor_ce_config(self):
        """
        Populate the config file that tells htcondor-ce where the condor
        pool is and where the spool directory is.

        Returns True if successful, False otherwise
        """
        if not utilities.rpm_installed('htcondor-ce'):
            self.log("Unable to configure htcondor-ce for Condor: htcondor-ce not installed", level=logging.ERROR)
            return False

        def get_condor_ce_config_val(variable):
            return utilities.get_condor_config_val(variable, executable='condor_ce_config_val', quiet_undefined=True)

        # Get values for the settings we want to update. We can get the
        # values from condor_config_val; in the case of JOB_ROUTER_SCHEDD2_NAME,
        # we have FULL_HOSTNAME as a fallback in case SCHEDD_NAME is missing.
        # We also get the current / default value from condor_ce_config_val;
        # only update the setting in case the value from
        # condor_config_val is different from the value from condor_ce_config_val.
        condor_ce_config = {}
        for condor_ce_config_key, condor_config_keys in [
            ('JOB_ROUTER_SCHEDD2_NAME', ['SCHEDD_NAME', 'FULL_HOSTNAME']),
            ('JOB_ROUTER_SCHEDD2_POOL', ['COLLECTOR_HOST']),
            ('JOB_ROUTER_SCHEDD2_SPOOL', ['SPOOL'])]:

            condor_config_value = None
            for condor_config_value in (utilities.get_condor_config_val(k, quiet_undefined=True) for k in
                                        condor_config_keys):
                if condor_config_value:
                    break

            condor_ce_config_value = get_condor_ce_config_val(condor_ce_config_key)
            if not (condor_config_value or condor_ce_config_value):
                self.log("Unable to determine value for %s from %s and default not set; check your Condor config" %
                         (condor_ce_config_key, ' or '.join(condor_config_keys)), level=logging.ERROR)
                return False
            elif not condor_config_value:
                continue  # can't set anything for this

            # Special case for JOB_ROUTER_SCHEDD2_POOL: append port if necessary (SOFTWARE-1744)
            if condor_ce_config_key == 'JOB_ROUTER_SCHEDD2_POOL':
                condor_collector_port = (utilities.get_condor_config_val('COLLECTOR_PORT', quiet_undefined=True)
                                         or '9618')
                condor_config_value = self._add_port_if_necessary(condor_config_value, condor_collector_port)

            if not condor_ce_config_value or condor_ce_config_value != condor_config_value:
                condor_ce_config[condor_ce_config_key] = condor_config_value

        if condor_ce_config:
            buf = utilities.read_file(JobManagerConfiguration.HTCONDOR_CE_CONFIG_FILE,
                                      default="# This file is managed by osg-configure\n")
            for key, value in condor_ce_config.items():
                buf = utilities.add_or_replace_setting(buf, key, value, quote_value=False)

            if not utilities.atomic_write(JobManagerConfiguration.HTCONDOR_CE_CONFIG_FILE, buf):
                return False

        return True
Esempio n. 2
0
    def warn_on_non_default_local_config_dir(self):
        """Warn the user if the default condor local config dir
        (/etc/condor/config.d) is not searched by their Condor install,
        i.e. is not in the LOCAL_CONFIG_DIR variable.  (Note that despite
        the name, LOCAL_CONFIG_DIR may be a list).

        """
        real_default_local_config_dir = os.path.realpath(self.DEFAULT_LOCAL_CONFIG_DIR)

        if not os.path.exists(real_default_local_config_dir):
            self.log("%s does not exist; check your Condor installation" % self.DEFAULT_LOCAL_CONFIG_DIR,
                     level=logging.WARNING)
            return

        local_config_dir = utilities.get_condor_config_val('LOCAL_CONFIG_DIR', quiet_undefined=True)
        if not local_config_dir:
            self.log("LOCAL_CONFIG_DIR cannot be determined; check your Condor config", level=logging.WARNING)
            return

        # does not handle dir names with spaces or commas but apparently neither does condor
        real_local_config_dirs = [os.path.realpath(x) for x in re.split('[, ]+', local_config_dir)]
        if real_default_local_config_dir not in real_local_config_dirs:
            self.log("%s not found in LOCAL_CONFIG_DIR; this may cause failures with gratia and htcondor-ce."
                     " Check your Condor config" % self.DEFAULT_LOCAL_CONFIG_DIR,
                     level=logging.WARNING)
            return
Esempio n. 3
0
    def warn_on_non_default_local_config_dir(self):
        """Warn the user if the default condor local config dir
        (/etc/condor/config.d) is not searched by their Condor install,
        i.e. is not in the LOCAL_CONFIG_DIR variable.  (Note that despite
        the name, LOCAL_CONFIG_DIR may be a list).

        """
        real_default_local_config_dir = os.path.realpath(
            self.DEFAULT_LOCAL_CONFIG_DIR)

        if not os.path.exists(real_default_local_config_dir):
            self.log("%s does not exist; check your Condor installation" %
                     self.DEFAULT_LOCAL_CONFIG_DIR,
                     level=logging.WARNING)
            return

        local_config_dir = utilities.get_condor_config_val(
            'LOCAL_CONFIG_DIR', quiet_undefined=True)
        if not local_config_dir:
            self.log(
                "LOCAL_CONFIG_DIR cannot be determined; check your Condor config",
                level=logging.WARNING)
            return

        # does not handle dir names with spaces or commas but apparently neither does condor
        real_local_config_dirs = [
            os.path.realpath(x) for x in re.split('[, ]+', local_config_dir)
        ]
        if real_default_local_config_dir not in real_local_config_dirs:
            self.log(
                "%s not found in LOCAL_CONFIG_DIR; this may cause failures with gratia and htcondor-ce."
                " Check your Condor config" % self.DEFAULT_LOCAL_CONFIG_DIR,
                level=logging.WARNING)
            return
Esempio n. 4
0
 def get_condor_ce_config_val(variable):
     return utilities.get_condor_config_val(variable, executable='condor_ce_config_val', quiet_undefined=True)
Esempio n. 5
0
 def get_condor_ce_config_val(variable):
     return utilities.get_condor_config_val(
         variable,
         executable='condor_ce_config_val',
         quiet_undefined=True)
Esempio n. 6
0
    def setup_htcondor_ce_config(self):
        """
        Populate the config file that tells htcondor-ce where the condor
        pool is and where the spool directory is.

        Returns True if successful, False otherwise
        """
        if not utilities.rpm_installed('htcondor-ce'):
            self.log(
                "Unable to configure htcondor-ce for Condor: htcondor-ce not installed",
                level=logging.ERROR)
            return False

        def get_condor_ce_config_val(variable):
            return utilities.get_condor_config_val(
                variable,
                executable='condor_ce_config_val',
                quiet_undefined=True)

        # Get values for the settings we want to update. We can get the
        # values from condor_config_val; in the case of JOB_ROUTER_SCHEDD2_NAME,
        # we have FULL_HOSTNAME as a fallback in case SCHEDD_NAME is missing.
        # We also get the current / default value from condor_ce_config_val;
        # only update the setting in case the value from
        # condor_config_val is different from the value from condor_ce_config_val.
        condor_ce_config = {}
        for condor_ce_config_key, condor_config_keys in [
            ('JOB_ROUTER_SCHEDD2_NAME', ['SCHEDD_NAME', 'FULL_HOSTNAME']),
            ('JOB_ROUTER_SCHEDD2_POOL', ['COLLECTOR_HOST']),
            ('JOB_ROUTER_SCHEDD2_SPOOL', ['SPOOL'])
        ]:

            condor_config_value = None
            for condor_config_value in (utilities.get_condor_config_val(
                    k, quiet_undefined=True) for k in condor_config_keys):
                if condor_config_value:
                    break

            condor_ce_config_value = get_condor_ce_config_val(
                condor_ce_config_key)
            if not (condor_config_value or condor_ce_config_value):
                self.log(
                    "Unable to determine value for %s from %s and default not set; check your Condor config"
                    % (condor_ce_config_key, ' or '.join(condor_config_keys)),
                    level=logging.ERROR)
                return False
            elif not condor_config_value:
                continue  # can't set anything for this

            # Special case for JOB_ROUTER_SCHEDD2_POOL: append port if necessary (SOFTWARE-1744)
            if condor_ce_config_key == 'JOB_ROUTER_SCHEDD2_POOL':
                condor_collector_port = (utilities.get_condor_config_val(
                    'COLLECTOR_PORT', quiet_undefined=True) or '9618')
                condor_config_value = self._add_port_if_necessary(
                    condor_config_value, condor_collector_port)

            if not condor_ce_config_value or condor_ce_config_value != condor_config_value:
                condor_ce_config[condor_ce_config_key] = condor_config_value

        if condor_ce_config:
            buf = utilities.read_file(
                JobManagerConfiguration.HTCONDOR_CE_CONFIG_FILE,
                default="# This file is managed by osg-configure\n")
            for key, value in condor_ce_config.items():
                buf = utilities.add_or_replace_setting(buf,
                                                       key,
                                                       value,
                                                       quote_value=False)

            if not utilities.atomic_write(
                    JobManagerConfiguration.HTCONDOR_CE_CONFIG_FILE, buf):
                return False

        return True