def prepare_syslog_dir(node, prefix=settings.SYSLOG_DIR):
    logger.debug("Preparing syslog directories for node: %s",
                 objects.Node.get_node_fqdn(node))
    logger.debug("prepare_syslog_dir prefix=%s", prefix)
    log_paths = generate_log_paths_for_node(node, prefix)
    links = log_paths['links']
    old = log_paths['old']
    bak = log_paths['bak']
    new = log_paths['new']

    logger.debug("prepare_syslog_dir old=%s", old)
    logger.debug("prepare_syslog_dir new=%s", new)
    logger.debug("prepare_syslog_dir bak=%s", bak)
    logger.debug("prepare_syslog_dir links=%s", str(links))

    # backup directory if it exists
    if os.path.isdir(new):
        logger.debug("New %s already exists. Trying to backup", new)
        if os.path.islink(bak):
            logger.debug("Bak %s already exists and it is link. "
                         "Trying to unlink", bak)
            os.unlink(bak)
        elif os.path.isdir(bak):
            logger.debug("Bak %s already exists and it is directory. "
                         "Trying to remove", bak)
            shutil.rmtree(bak)
        os.rename(new, bak)

    # rename bootstrap directory into fqdn
    if os.path.islink(old):
        logger.debug("Old %s exists and it is link. "
                     "Trying to unlink", old)
        os.unlink(old)
    if os.path.isdir(old):
        logger.debug("Old %s exists and it is directory. "
                     "Trying to rename into %s", old, new)
        os.rename(old, new)
    else:
        logger.debug("Creating %s", new)
        os.makedirs(new)

    # creating symlinks
    for l in links:
        if os.path.islink(l) and os.path.isfile(l):
            logger.debug("%s already exists. "
                         "Trying to unlink", l)
            os.unlink(l)
        if os.path.isdir(l):
            logger.debug("%s already exists and it directory. "
                         "Trying to remove", l)
            shutil.rmtree(l)
        logger.debug("Creating symlink %s -> %s", l, new)
        os.symlink(objects.Node.get_node_fqdn(node), l)

    os.system("/usr/bin/pkill -HUP rsyslog")
dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/utils/logs.py/prepare_syslog_dir/operator `or` -> `and`