コード例 #1
0
def _log(follow, lines, leader, slave, component, filters):
    """ Prints the contents of leader and slave logs.

    :param follow: same as unix tail's -f
    :type follow: bool
    :param lines: number of lines to print
    :type lines: int
    :param leader: whether to print the leading master's log
    :type leader: bool
    :param slave: the slave ID to print
    :type slave: str | None
    :param component: DC/OS component name
    :type component: string
    :param filters: a list of filters ["key:value", ...]
    :type filters: list
    :returns: process return code
    :rtype: int
    """

    if not (leader or slave):
        raise DCOSException('You must choose one of --leader or --mesos-id.')

    if lines is None:
        lines = 10

    lines = util.parse_int(lines)

    if log.dcos_log_enabled(version=2):
        _dcos_log_v2(follow, lines, leader, slave, component, filters)
        return 0

    if not log.has_journald_capability():
        if component or filters:
            raise DCOSException('--component or --filter is not '
                                'supported by files API')

        # fall back to mesos files API.
        mesos_files = _mesos_files(leader, slave)
        log.log_files(mesos_files, follow, lines)
        return 0

    # dcos-log does not support logs from leader and agent.
    if leader and slave:
        raise DCOSException(
            'You must choose one of --leader or --mesos-id.')

    # if journald logging enabled.
    _dcos_log(follow, lines, leader, slave, component, filters)
    return 0
コード例 #2
0
ファイル: main.py プロジェクト: sschneid/dcos-cli
def _log(follow, lines, leader, slave, component, filters):
    """ Prints the contents of leader and slave logs.

    :param follow: same as unix tail's -f
    :type follow: bool
    :param lines: number of lines to print
    :type lines: int
    :param leader: whether to print the leading master's log
    :type leader: bool
    :param slave: the slave ID to print
    :type slave: str | None
    :param component: DC/OS component name
    :type component: string
    :param filters: a list of filters ["key:value", ...]
    :type filters: list
    :returns: process return code
    :rtype: int
    """

    if not (leader or slave):
        raise DCOSException('You must choose one of --leader or --mesos-id.')

    if lines is None:
        lines = 10

    lines = util.parse_int(lines)

    if not log.has_journald_capability():
        if component or filters:
            raise DCOSException('--component or --filter is not '
                                'supported by files API')

        # fall back to mesos files API.
        mesos_files = _mesos_files(leader, slave)
        log.log_files(mesos_files, follow, lines)
        return 0

    # dcos-log does not support logs from leader and agent.
    if leader and slave:
        raise DCOSException(
            'You must choose one of --leader or --mesos-id.')

    # if journald logging enabled.
    _dcos_log(follow, lines, leader, slave, component, filters)
    return 0