Skip to content

Commit

Permalink
status: add neighbors to routers json
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed May 10, 2024
1 parent 2e5775b commit 6e93e2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions framework/internal/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'path_exists': lambda path: os.path.exists(path),
'read_file': lambda path: open(path).read(),
'oneline': lambda text: ''.join(text.splitlines()),
'list': lambda iter: list(iter),
}

def render(node_name: str, dry: bool = False) -> None:
Expand Down
19 changes: 10 additions & 9 deletions templates/file-server/routers.json.j2
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
{% for name, data in hostvars.items() %}
"{{ name }}": {
"name": "{{ data['site_name'] }}",
"ip_addresses": ["{{ data['host_ip'] }}"],
"host": "{{ data['ansible_host'] }}",
"prefix": "{{ data['default_prefix'] }}",
"shortname": "{{ name }}",
"position": {{ data['position'] }}
}
{%- if not loop.last -%},{% endif %}
{{ name | tojson }}: {{{
'shortname': name,
'name': data['site_name'],
'ip_addresses': [data['host_ip']],
'host': data['ansible_host'],
'prefix': data['default_prefix'],
'neighbors': list(neighbors.keys()),
'position': data['position'],
} | tojson }}
{% if not loop.last %},{% endif %}
{% endfor %}
}

0 comments on commit 6e93e2f

Please sign in to comment.