Ejemplo n.º 1
0
def _read_cached_zonefile(zonefile_path, zonefile_hash):
    """
    Read and verify a cached zone file
    """

    with open(zonefile_path, "r") as f:
        data = f.read()

    # sanity check
    if not verify_zonefile(data, zonefile_hash):
        log.debug("Corrupt zonefile '%s'" % zonefile_hash)
        return None

    return data
def _read_cached_zonefile( zonefile_path, zonefile_hash ):
    """
    Read and verify a cached zone file
    """

    with open(zonefile_path, "r") as f:
        data = f.read()

    # sanity check 
    if not verify_zonefile( data, zonefile_hash ):
        log.debug("Corrupt zonefile '%s'" % zonefile_hash)
        return None

    return data
Ejemplo n.º 3
0
def get_cached_zonefile_data(zonefile_hash, zonefile_dir=None):
    """
    Get a serialized cached zonefile from local disk 
    Return None if not found
    """
    if zonefile_dir is None:
        zonefile_dir = get_zonefile_dir()

    zonefile_path_dir = cached_zonefile_dir(zonefile_dir, zonefile_hash)
    zonefile_path = os.path.join(zonefile_path_dir, "zonefile.txt")
    if not os.path.exists(zonefile_path):
        log.debug("No zonefile at %s" % zonefile_path)
        return None

    with open(zonefile_path, "r") as f:
        data = f.read()

    # sanity check
    if not verify_zonefile(data, zonefile_hash):
        log.debug("Corrupt zonefile '%s'" % zonefile_hash)
        return None

    return data