[cli][domain] better output for list_routes

This commit is contained in:
Maxime Alves LIRMM@home 2020-08-05 21:41:40 +02:00
parent 63bd4c8db6
commit 7c4eafb40c
1 changed files with 12 additions and 5 deletions

View File

@ -53,14 +53,21 @@ def domain(domain, update):
if update:
update_db(domain)
else:
for domain_name in domain:
list_routes(domain)
def list_routes(domain):
click.echo(f'\nDomain {domain} :')
routes = Acl(domain=domain)
click.echo(f'\nDomain : {domain}')
routers = APIRouter(domain=domain)
for router in routers.select():
routes = APIRoute(domain=domain, router=router['name'])
click.echo('# /{name}'.format(**router))
for route in routes.select():
click.echo(f'- {route}')
route.pop('fct_name')
acls = ', '.join([ acl['acl_fct_name'] for acl in Acl(**route).select() ])
route['acls'] = acls
click.echo('- [{http_verb}] {path} ({acls})'.format(**route))
def update_db(domains):