# Path: teuthology/misc.py
# def host_shortname(hostname):
# def canonicalize_hostname(hostname, user='ubuntu'):
# def decanonicalize_hostname(hostname):
# def config_file(string):
#     def __call__(self, parser, namespace, values, option_string=None):
# def merge_configs(config_paths):
# def get_testdir(ctx=None):
# def get_test_user(ctx=None):
# def get_archive_dir(ctx):
# def get_http_log_path(archive_dir, job_id=None):
# def get_results_url(run_name, job_id=None):
# def get_ceph_binary_url(package=None,
#                         branch=None, tag=None, sha1=None, dist=None,
#                         flavor=None, format=None, arch=None):
# def feed_many_stdins(fp, processes):
# def feed_many_stdins_and_close(fp, processes):
# def get_mons(roles, ips,
#              mon_bind_msgr2=False,
#              mon_bind_addrvec=False):
# def skeleton_config(ctx, roles, ips, cluster='ceph',
#                     mon_bind_msgr2=False,
#                     mon_bind_addrvec=False):
# def ceph_role(role):
# def split_role(role):
# def roles_of_type(roles_for_host, type_):
# def cluster_roles_of_type(roles_for_host, type_, cluster):
# def all_roles(cluster):
# def all_roles_of_type(cluster, type_):
# def is_type(type_, cluster=None):
#     def _is_type(role):
# def num_instances_of_type(cluster, type_, ceph_cluster='ceph'):
# def create_simple_monmap(ctx, remote, conf, path=None,
#                          mon_bind_addrvec=False):
#     def gen_addresses():
# def write_file(remote, path, data):
# def sudo_write_file(remote, path, data, perms=None, owner=None):
# def copy_file(from_remote, from_path, to_remote, to_path=None):
# def move_file(remote, from_path, to_path, sudo=False, preserve_perms=True):
# def delete_file(remote, path, sudo=False, force=False, check=True):
# def remove_lines_from_file(remote, path, line_is_valid_test,
#                            string_to_test_for):
# def append_lines_to_file(remote, path, lines, sudo=False):
# def prepend_lines_to_file(remote, path, lines, sudo=False):
# def create_file(remote, path, data="", permissions=str(644), sudo=False):
# def get_file(remote, path, sudo=False, dest_dir='/tmp'):
# def copy_fileobj(src, tarinfo, local_path):
# def pull_directory(remote, remotedir, localdir, write_to=copy_fileobj):
# def pull_directory_tarball(remote, remotedir, localfile):
# def get_wwn_id_map(remote, devs):
# def get_scratch_devices(remote):
# def wait_until_healthy(ctx, remote, ceph_cluster='ceph', use_sudo=False):
# def wait_until_osds_up(ctx, cluster, remote, ceph_cluster='ceph'):
# def reboot(node, timeout=300, interval=30):
# def reconnect(ctx, timeout, remotes=None):
# def get_clients(ctx, roles):
# def get_user():
# def get_mon_names(ctx, cluster='ceph'):
# def get_first_mon(ctx, config, cluster='ceph'):
# def replace_all_with_clients(cluster, config):
# def deep_merge(a, b):
# def get_valgrind_args(testdir, name, preamble, v, exit_on_first_error=True):
# def ssh_keyscan(hostnames, _raise=True):
# def _ssh_keyscan(hostname):
# def ssh_keyscan_wait(hostname):
# def stop_daemons_of_type(ctx, type_, cluster='ceph'):
# def get_system_type(remote, distro=False, version=False):
# def get_pkg_type(os_type):
# def get_distro(ctx):
# def get_distro_version(ctx):
# def get_multi_machine_types(machinetype):
# def is_in_dict(searchkey, searchval, d):
# def sh(command, log_limit=1024, cwd=None, env=None):
# def add_remote_path(ctx, local_dir, remote_dir):
# def archive_logs(ctx, remote_path, log_path):
# def compress_logs(ctx, remote_dir):
# class MergeConfig(argparse.Action):
#     BASE = 'http://{host}/{package}-{format}-{dist}-{arch}-{flavor}/'.format(
#         host=config.gitbuilder_host,
#         package=package,
#         flavor=flavor,
#         arch=arch,
#         format=format,
#         dist=dist
#     )
#             PREFIX = 'mon.'


import contextlib
import logging
from io import BytesIO
from teuthology import misc
from teuthology.job_status import set_status
from teuthology.orchestra import run
        # anyway
        yield
        return

    log.info('Starting syslog monitoring...')

    archive_dir = misc.get_archive_dir(ctx)
    log_dir = '{adir}/syslog'.format(adir=archive_dir)
    run.wait(
        ctx.cluster.run(
            args=['mkdir', '-p', '-m0755', '--', log_dir],
            wait=False,
        )
    )

    CONF = '/etc/rsyslog.d/80-cephtest.conf'
    kern_log = '{log_dir}/kern.log'.format(log_dir=log_dir)
    misc_log = '{log_dir}/misc.log'.format(log_dir=log_dir)
    conf_lines = [
        'kern.* -{kern_log};RSYSLOG_FileFormat'.format(kern_log=kern_log),
        '*.*;kern.none -{misc_log};RSYSLOG_FileFormat'.format(
            misc_log=misc_log),
    ]
    conf_fp = BytesIO('\n'.join(conf_lines).encode())
    try:
        for rem in ctx.cluster.remotes.keys():
            log_context = 'system_u:object_r:var_log_t:s0'
            for log_path in (kern_log, misc_log):
                rem.run(args=['install', '-m', '666', '/dev/null', log_path])
                rem.chcon(log_path, log_context)

# Path: teuthology/misc.py
# def host_shortname(hostname):
# def canonicalize_hostname(hostname, user='ubuntu'):
# def decanonicalize_hostname(hostname):
# def config_file(string):
#     def __call__(self, parser, namespace, values, option_string=None):
# def merge_configs(config_paths):
# def get_testdir(ctx=None):
# def get_test_user(ctx=None):
# def get_archive_dir(ctx):
# def get_http_log_path(archive_dir, job_id=None):
# def get_results_url(run_name, job_id=None):
# def get_ceph_binary_url(package=None,
#                         branch=None, tag=None, sha1=None, dist=None,
#                         flavor=None, format=None, arch=None):
# def feed_many_stdins(fp, processes):
# def feed_many_stdins_and_close(fp, processes):
# def get_mons(roles, ips,
#              mon_bind_msgr2=False,
#              mon_bind_addrvec=False):
# def skeleton_config(ctx, roles, ips, cluster='ceph',
#                     mon_bind_msgr2=False,
#                     mon_bind_addrvec=False):
# def ceph_role(role):
# def split_role(role):
# def roles_of_type(roles_for_host, type_):
# def cluster_roles_of_type(roles_for_host, type_, cluster):
# def all_roles(cluster):
# def all_roles_of_type(cluster, type_):
# def is_type(type_, cluster=None):
#     def _is_type(role):
# def num_instances_of_type(cluster, type_, ceph_cluster='ceph'):
# def create_simple_monmap(ctx, remote, conf, path=None,
#                          mon_bind_addrvec=False):
#     def gen_addresses():
# def write_file(remote, path, data):
# def sudo_write_file(remote, path, data, perms=None, owner=None):
# def copy_file(from_remote, from_path, to_remote, to_path=None):
# def move_file(remote, from_path, to_path, sudo=False, preserve_perms=True):
# def delete_file(remote, path, sudo=False, force=False, check=True):
# def remove_lines_from_file(remote, path, line_is_valid_test,
#                            string_to_test_for):
# def append_lines_to_file(remote, path, lines, sudo=False):
# def prepend_lines_to_file(remote, path, lines, sudo=False):
# def create_file(remote, path, data="", permissions=str(644), sudo=False):
# def get_file(remote, path, sudo=False, dest_dir='/tmp'):
# def copy_fileobj(src, tarinfo, local_path):
# def pull_directory(remote, remotedir, localdir, write_to=copy_fileobj):
# def pull_directory_tarball(remote, remotedir, localfile):
# def get_wwn_id_map(remote, devs):
# def get_scratch_devices(remote):
# def wait_until_healthy(ctx, remote, ceph_cluster='ceph', use_sudo=False):
# def wait_until_osds_up(ctx, cluster, remote, ceph_cluster='ceph'):
# def reboot(node, timeout=300, interval=30):
# def reconnect(ctx, timeout, remotes=None):
# def get_clients(ctx, roles):
# def get_user():
# def get_mon_names(ctx, cluster='ceph'):
# def get_first_mon(ctx, config, cluster='ceph'):
# def replace_all_with_clients(cluster, config):
# def deep_merge(a, b):
# def get_valgrind_args(testdir, name, preamble, v, exit_on_first_error=True):
# def ssh_keyscan(hostnames, _raise=True):
# def _ssh_keyscan(hostname):
# def ssh_keyscan_wait(hostname):
# def stop_daemons_of_type(ctx, type_, cluster='ceph'):
# def get_system_type(remote, distro=False, version=False):
# def get_pkg_type(os_type):
# def get_distro(ctx):
# def get_distro_version(ctx):
# def get_multi_machine_types(machinetype):
# def is_in_dict(searchkey, searchval, d):
# def sh(command, log_limit=1024, cwd=None, env=None):
# def add_remote_path(ctx, local_dir, remote_dir):
# def archive_logs(ctx, remote_path, log_path):
# def compress_logs(ctx, remote_dir):
# class MergeConfig(argparse.Action):
#     BASE = 'http://{host}/{package}-{format}-{dist}-{arch}-{flavor}/'.format(
#         host=config.gitbuilder_host,
#         package=package,
#         flavor=flavor,
#         arch=arch,
#         format=format,
#         dist=dist
#     )
#             PREFIX = 'mon.'


# Path: teuthology/task/internal/syslog.py
import contextlib
import logging
from io import BytesIO
from teuthology import misc
from teuthology.job_status import set_status
from teuthology.orchestra import run

        # anyway
        yield
        return

    log.info('Starting syslog monitoring...')

    archive_dir = misc.get_archive_dir(ctx)
    log_dir = '{adir}/syslog'.format(adir=archive_dir)
    run.wait(
        ctx.cluster.run(
            args=['mkdir', '-p', '-m0755', '--', log_dir],
            wait=False,
        )
    )

    CONF = '/etc/rsyslog.d/80-cephtest.conf'
    kern_log = '{log_dir}/kern.log'.format(log_dir=log_dir)
    misc_log = '{log_dir}/misc.log'.format(log_dir=log_dir)
    conf_lines = [
        'kern.* -{kern_log};RSYSLOG_FileFormat'.format(kern_log=kern_log),
        '*.*;kern.none -{misc_log};RSYSLOG_FileFormat'.format(
            misc_log=misc_log),
    ]
    conf_fp = BytesIO('\n'.join(conf_lines).encode())
    try:
        for rem in ctx.cluster.remotes.keys():
            log_context = 'system_u:object_r:var_log_t:s0'
            for log_path in (kern_log, misc_log):
                rem.run(args=['install', '-m', '666', '/dev/null', log_path])
                rem.chcon(log_path, log_context)

            misc.sudo_write_file(