

def _create_logfile_for_node(self, log_config, log_entries, node=None):
    if log_config['remote']:
        log_dir = os.path.join(self.log_dir, node.ip)
        ((not os.path.isdir(log_dir)) and os.makedirs(log_dir))
        log_file = os.path.join(log_dir, log_config['path'])
    else:
        log_file = log_config['path']
    with open(log_file, 'w') as f:
        for log_entry in log_entries:
            f.write(self._format_log_entry(log_entry))
            f.flush()

dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/test/unit/test_logs_handlers.py TestLogs._create_logfile_for_node/original