Statistics
| Branch: | Tag: | Revision:

root / tools / util.py @ 92c53da1

History | View | Annotate | Download (545 Bytes)

1 2e2bd2a6 Giorgos Verigakis
DEFAULT_HOST = '127.0.0.1:8000'
2 2e2bd2a6 Giorgos Verigakis
DEFAULT_API = 'v1.1redux'
3 2e2bd2a6 Giorgos Verigakis
4 2e2bd2a6 Giorgos Verigakis
5 2e2bd2a6 Giorgos Verigakis
def address_to_string(address):
6 2e2bd2a6 Giorgos Verigakis
    key = address['id']
7 2e2bd2a6 Giorgos Verigakis
    val = ' '.join(ip['addr'] for ip in address['values'])
8 2e2bd2a6 Giorgos Verigakis
    return '%s: %s' % (key, val)
9 2e2bd2a6 Giorgos Verigakis
10 2e2bd2a6 Giorgos Verigakis
def print_server(server):
11 2e2bd2a6 Giorgos Verigakis
    for key, val in sorted(server.items()):
12 2e2bd2a6 Giorgos Verigakis
        if key == 'metadata':
13 2e2bd2a6 Giorgos Verigakis
            val = ', '.join('%s="%s"' % x for x in val['values'].items())
14 2e2bd2a6 Giorgos Verigakis
        if key == 'addresses':
15 2e2bd2a6 Giorgos Verigakis
            val = ', '.join(address_to_string(address) for address in val['values'])
16 2e2bd2a6 Giorgos Verigakis
        print '%s: %s' % (key.rjust(12), val)