Exemplo n.º 1
0
Arquivo: main.py Projeto: ssato/rpmkit
def compute_delta(refdir, errata, updates, nevra_keys=NEVRA_KEYS):
    """
    :param refdir: Dir has reference data files: packages.json, errata.json
        and updates.json
    :param errata: A list of errata
    :param updates: A list of update packages
    """
    emsg = "Reference %s not found: %s"
    assert os.path.exists(refdir), emsg % ("data dir", refdir)

    ref_es_file = os.path.join(refdir, "errata.json")
    ref_us_file = os.path.join(refdir, "updates.json")
    assert os.path.exists(ref_es_file), emsg % ("errata file", ref_es_file)
    assert os.path.exists(ref_us_file), emsg % ("updates file", ref_us_file)

    ref_es_data = U.json_load(ref_es_file)
    ref_us_data = U.json_load(ref_us_file)
    LOG.debug(_("Loaded reference errata and updates file"))

    ref_eadvs = set(e["advisory"] for e in ref_es_data["data"])
    ref_nevras = set((p[k] for k in nevra_keys) for p in ref_us_data["data"])

    return ([e for e in errata if e["advisory"] not in ref_eadvs],
            [u for u in updates
             if (u[k] for k in nevra_keys) not in ref_nevras])
Exemplo n.º 2
0
def compute_delta(refdir, errata, updates, nevra_keys=NEVRA_KEYS):
    """
    :param refdir: Dir has reference data files: packages.json, errata.json
        and updates.json
    :param errata: A list of errata
    :param updates: A list of update packages
    """
    emsg = "Reference %s not found: %s"
    assert os.path.exists(refdir), emsg % ("data dir", refdir)

    ref_es_file = os.path.join(refdir, "errata.json")
    ref_us_file = os.path.join(refdir, "updates.json")
    assert os.path.exists(ref_es_file), emsg % ("errata file", ref_es_file)
    assert os.path.exists(ref_us_file), emsg % ("updates file", ref_us_file)

    ref_es_data = U.json_load(ref_es_file)
    ref_us_data = U.json_load(ref_us_file)
    LOG.debug(_("Loaded reference errata and updates file"))

    ref_eadvs = set(e["advisory"] for e in ref_es_data["data"])
    ref_nevras = set((p[k] for k in nevra_keys) for p in ref_us_data["data"])

    return ([e for e in errata if e["advisory"] not in ref_eadvs], [
        u for u in updates if (u[k] for k in nevra_keys) not in ref_nevras
    ])
Exemplo n.º 3
0
def add_host_to_metadata(workdir, host):
    metadatafile = os.path.join(workdir, "metadata.json")

    shutil.copy2(metadatafile, metadatafile + ".save")
    metadata = U.json_load(metadatafile)
    metadata["hosts"].append(host)
    U.json_dump(metadata, metadatafile)
Exemplo n.º 4
0
def add_host_to_metadata(workdir, host):
    metadatafile = os.path.join(workdir, "metadata.json")

    shutil.copy2(metadatafile, metadatafile + ".save")
    metadata = U.json_load(metadatafile)
    metadata["hosts"].append(host)
    U.json_dump(metadata, metadatafile)