Пример #1
0
def node_show():
    """
    Show hostname and node information for each node in the Calico cluster.
    """
    # Set up output table
    headings = [
        "Hostname", "Bird IPv4", "Bird IPv6", "AS Num", "BGP Peers v4",
        "BGP Peers v6"
    ]
    x = PrettyTable(headings, sortby="Hostname")

    try:
        # Get dictionary of host data, indexed by hostname
        hosts = client.get_hosts_data_dict()
        for (host, data) in hosts.iteritems():

            # Combine BGP peer IP and AS numbers into single values
            peer_v4_list = [
                peer["ip"] + " as " + peer["as_num"]
                for peer in data["peer_v4"]
            ]
            peer_v6_list = [
                peer["ip"] + " as " + peer["as_num"]
                for peer in data["peer_v6"]
            ]

            if data["as_num"]:
                bgp_as = data["as_num"]
            else:
                bgp_as = client.get_default_node_as()
                bgp_as += " (inherited)"
            x.add_row([
                host, data["ip_addr_v4"], data["ip_addr_v6"], bgp_as,
                "\n".join(peer_v4_list), "\n".join(peer_v6_list)
            ])
    except DataStoreError:
        print "Error connecting to etcd."
        sys.exit(1)

    print str(x) + "\n"
Пример #2
0
def node_show():
    """
    Show hostname and node information for each node in the Calico cluster.
    """
    # Set up output table
    headings = ["Hostname",
                "Bird IPv4",
                "Bird IPv6",
                "AS Num",
                "BGP Peers v4",
                "BGP Peers v6"]
    x = PrettyTable(headings, sortby="Hostname")

    try:
        # Get dictionary of host data, indexed by hostname
        hosts = client.get_hosts_data_dict()
        for (host, data) in hosts.iteritems():

            # Combine BGP peer IP and AS numbers into single values
            peer_v4_list = [peer["ip"] + " as " + peer["as_num"]
                            for peer in data["peer_v4"]]
            peer_v6_list = [peer["ip"] + " as " + peer["as_num"]
                            for peer in data["peer_v6"]]

            if data["as_num"]:
                bgp_as = data["as_num"]
            else:
                bgp_as = client.get_default_node_as()
                bgp_as += " (inherited)"
            x.add_row([host,
                       data["ip_addr_v4"],
                       data["ip_addr_v6"],
                       bgp_as,
                       "\n".join(peer_v4_list),
                       "\n".join(peer_v6_list)])
    except DataStoreError:
        print "Error connecting to etcd."
        sys.exit(1)

    print str(x) + "\n"