Esempio n. 1
0
def load_config():
    """Load few parameters from the configuration file
    """
    parser = argparse.ArgumentParser(prog='OSG_autoconf')
    parser.add_argument('config', nargs=1, help='The configuration file')
    args = parser.parse_args()

    config = get_yaml_file_info(args.config[0])

    return config
Esempio n. 2
0
def merge_yaml(config):
    """Merges different yaml file and return the corresponding resource dictionary

    Three different yam files are merged. First we read the factory white list/override file that
    contains the list of entries operators want to generate, with the parameters they want to
    override.
    Then the yaml generated from the OSG collector and the default yam file are read.
    For each entry an all the operator information are "updated" with the information coming from
    the collector first, and from the default file next.

    Returns:
        dict: a dict similar to the one returned by ``get_information``, but with all the defaults
            and the operators overrides in place (only whitelisted entries are returned).
    """
    out = get_yaml_file_info(config["OSG_WHITELIST"])
    osg_info = get_yaml_file_info(config["OSG_YAML"])
    default_information = get_yaml_file_info(config["OSG_DEFAULT"])
    for site, site_information in out.items():
        if site not in osg_info:
            print("You put %s in the whitelist file, but the site is not present in the collector"
                  % site)
            raise ProgramError(2)
        for celem, ce_information in site_information.items():
            if celem not in osg_info[site]:
                print ("Working on whitelisted site %s: cant find ce %s in the generated OSG.yaml"
                       % (site, celem))
                raise ProgramError(3)
            for entry, entry_information in ce_information.items():
                if entry_information is None:
                    out[site][celem][entry] = osg_info[site][celem]["DEFAULT_ENTRY"]
                    entry_information = out[site][celem][entry]
                else:
                    update(entry_information, osg_info[site][celem]["DEFAULT_ENTRY"],
                           overwrite=False)
                update(
                    entry_information,
                    default_information["DEFAULT_SITE"]["DEFAULT_GETEKEEPER"]["DEFAULT_ENTRY"],
                    overwrite=False
                )
    return out
Esempio n. 3
0
def merge_yaml(config, white_list):
    """Merges different yaml file and return the corresponding resource dictionary

    Three different yam files are merged. First we read the factory white list/override file that
    contains the list of entries operators want to generate, with the parameters they want to
    override.
    Then the yaml generated from the OSG collector and the default yam file are read.
    For each entry an all the operator information are "updated" with the information coming from
    the collector first, and from the default file next.

    Returns:
        dict: a dict similar to the one returned by ``get_information``, but with all the defaults
            and the operators overrides in place (only whitelisted entries are returned).
    """
    out = get_yaml_file_info(white_list)
    osg_info = get_yaml_file_info(config["OSG_YAML"])
    default_information = get_yaml_file_info(config["OSG_DEFAULT"])
    for site, site_information in out.items():
        if site_information is None:
            print(
                "There is no site information for %s site in white list file."
                % site)
            del out[site]
            continue
        print("Merging %s" % site)
        if site not in osg_info:
            print(
                "You put %s in the whitelist file, but the site is not present in the collector"
                % site)
            raise ProgramError(2)
        for celem, ce_information in site_information.items():
            if ce_information is None:
                print(
                    "There is no CE information for %s CE in white list file."
                    % celem)
                del out[site][celem]
                continue
            if celem not in osg_info[site]:
                print(
                    "Working on whitelisted site %s: cant find ce %s in the generated OSG.yaml"
                    % (site, celem))
                raise ProgramError(3)
            for entry, entry_information in ce_information.items():
                if entry_information is None:
                    out[site][celem][entry] = osg_info[site][celem][
                        "DEFAULT_ENTRY"]
                    entry_information = out[site][celem][entry]
                else:
                    if osg_info[site][celem]["DEFAULT_ENTRY"][
                            "gridtype"] == "condor":
                        if "attrs" in entry_information:
                            entry_information = update_submit_attrs(
                                entry_information, "GLIDEIN_CPUS", "+xcount")
                            entry_information = update_submit_attrs(
                                entry_information, "GLIDEIN_MaxMemMBs",
                                "+maxMemory")
                            entry_information = update_submit_attrs(
                                entry_information, "GLIDEIN_Max_Walltime",
                                "+maxWallTime")
                    if "limits" in entry_information:
                        if "entry" in entry_information[
                                "limits"] and "frontend" not in entry_information[
                                    "limits"]:
                            entry_information["limits"][
                                "frontend"] = entry_information["limits"][
                                    "entry"]
                        elif "entry" not in entry_information[
                                "limits"] and "frontend" in entry_information[
                                    "limits"]:
                            entry_information["limits"][
                                "entry"] = entry_information["limits"][
                                    "frontend"]
                    update(entry_information,
                           osg_info[site][celem]["DEFAULT_ENTRY"],
                           overwrite=False)
                update(entry_information,
                       default_information["DEFAULT_SITE"]
                       ["DEFAULT_GETEKEEPER"]["DEFAULT_ENTRY"],
                       overwrite=False)
    return out