Beispiel #1
0
    def show_leader(self, json_):
        """
        Returns the Marathon leader in the cluster

        :param json_: output json if True
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        hosts = mesos.MesosDNSClient().hosts('marathon.mesos')
        leader = hosts[0]

        if json_:
            emitter.publish(leader)
        else:
            table = tables.dns_table(hosts)
            emitter.publish(table)
        return 0
Beispiel #2
0
def _dns_lookup(dns_name, json_):
    """
    Returns the IP of the dns-name in the cluster

    :param dns_name: dns name to lookup
    :type dns_name: string
    :param json_: If true, output json.
        Otherwise, output a human readable table.
    :type json_: bool
    """

    ips = mesos.MesosDNSClient().hosts(dns_name)

    if json_:
        emitter.publish(ips)
    else:
        table = tables.dns_table(ips)
        output = six.text_type(table)
        if output:
            emitter.publish(output)

    return 0