def do(args): # ip = ansible.get_node_ip(args.node, args.id) config = network.config.load(args.id) ips = tf.get_network_ips(config) while True: heads = [] for ip in ips: try: url = "http://{}:8080/blocks?count=1".format(ip) head = requests.get(url, timeout=0.1).json()["head"] print("[{}] has {}".format(ip, head[:6])) heads.append(head) except: print("Couldn't reach node {}".format(ip)) heads = [] break if len(set(heads)) == 1: print("All nodes on {}".format(heads[0][:6])) break else: print("Still waiting...") time.sleep(3)
def do(args): # ip = ansible.get_node_ip(args.node, args.id) config = network.config.load(args.id) ips = tf.get_network_ips(config) count = 0 endpoints = [] while True: print("Still waiting on %s" % args.id) try: url = "http://{}:8800/store/EndpointRegistryTransaction/*?p=1".format( ips[0]) request = urllib.request.Request(url) result = urllib.request.urlopen(request).read().decode() data = yaml.load(result) except: print("Couldn't reach node 0") data = {} count = len(data.keys()) for key in data: host = data[key]['Host'] if host not in endpoints: endpoints.append(host) print("Found endpoint: %s (%d/%d)" % (data[key]['Host'], len(endpoints), len(ips))) if count != len(ips): time.sleep(3) else: break
def do(args): try: config = network.config.load(args.id) ips = tf.get_network_ips(config) for ip in ips: print(args.prefix + ip + args.suffix + args.delim, end='') print() except KeyError: print('Network not found %s' % args.id)
def do(args): networks = network.config.list_networks() for nid in networks: config = network.config.load(nid) ips = tf.get_network_ips(config) format_str = '{:<8} {:<3} ' + '{:<16}' print(format_str.format(nid, 'ID', 'IP')) for idx, ip in enumerate(ips): print(format_str.format('', idx, ip)) print()
def get(config): ips = tf.get_network_ips(config) stats = {} for ip in ips: stats[ip] = _get_stats(ip) # TODO: Compute aggregate stats # - Txn Rate is averaged, need to store time/count somehow stats = _add_aggregate_stats(stats) return stats