Store a validated zonefile.
    zonefile_data should be a dict.
    The caller should first authenticate the zonefile.
    Return True on success
    Return False on error

def store_atlas_zonefile_data(zonefile_data, zonefile_dir, fsync=True):
    """
    Store a validated zonefile.
    zonefile_data should be a dict.
    The caller should first authenticate the zonefile.
    Return True on success
    Return False on error
    """
    if not os.path.exists(zonefile_dir):
        os.makedirs(zonefile_dir, 0700 )

    zonefile_hash = get_zonefile_data_hash( zonefile_data )
    
    # only store to the latest supported directory
    zonefile_path = atlas_zonefile_path( zonefile_dir, zonefile_hash )
    zonefile_dir_path = os.path.dirname(zonefile_path)

    if os.path.exists(zonefile_path):
        # already exists 
        return True

    if not os.path.exists(zonefile_dir_path):
        os.makedirs(zonefile_dir_path)

    try:
        with open( zonefile_path, "wb" ) as f:
            f.write(zonefile_data)
            f.flush()
            if fsync:
                os.fsync(f.fileno())

    except Exception, e:
        log.exception(e)
        return False
        
    return True