summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2023-11-14 14:19:55 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2023-11-14 14:19:55 +0100
commit4d471f0b706733624a845143cafb6dd8add90eed (patch)
tree417efc58964f8b43007dcbecf77e6b05a0bd6fa3
parent6dca28918be80a3ef0c2959a99067337f59f5972 (diff)
downloadprolog-firewall-4d471f0b706733624a845143cafb6dd8add90eed.tar.gz
prolog-firewall-4d471f0b706733624a845143cafb6dd8add90eed.tar.bz2
prolog-firewall-4d471f0b706733624a845143cafb6dd8add90eed.tar.xz
prolog-firewall-4d471f0b706733624a845143cafb6dd8add90eed.zip
wip
-rw-r--r--6/bgp.pl11
-rwxr-xr-x6/bgp.py7
-rw-r--r--6/group_vars/hash/bgp.yaml1
-rw-r--r--6/group_vars/knot/bgp.yaml1
-rw-r--r--6/group_vars/kv24ix/bgp.yaml1
-rw-r--r--6/group_vars/lhn2ix/bgp.yaml1
6 files changed, 9 insertions, 13 deletions
diff --git a/6/bgp.pl b/6/bgp.pl
index 6d16500..d398c4c 100644
--- a/6/bgp.pl
+++ b/6/bgp.pl
@@ -72,9 +72,9 @@ router_path(X, Y, V) :- \+ member(X, V), router_link(X, _, Z), router_path(Z, Y,
to_dict(router(R), Dict) :-
neighbors(R, Neighbors),
maplist(to_dict(), Neighbors, NeighborDicts),
- Dict = _{
- host: R,
- neighbors: NeighborDicts}.
+ Dict = R-_{
+ neighbors: NeighborDicts
+ }.
to_dict(neighbor(_, Remote), Dict) :- host_config(Remote, RC),
Dict = neighbor{
@@ -84,6 +84,7 @@ to_dict(neighbor(_, Remote), Dict) :- host_config(Remote, RC),
}
}.
-bird_config(RouterDicts) :-
+bird_config(BirdConfig) :-
routers(Routers),
- maplist(to_dict(), Routers, RouterDicts).
+ maplist(to_dict(), Routers, RouterDicts),
+ dict_pairs(BirdConfig, bird_config, RouterDicts).
diff --git a/6/bgp.py b/6/bgp.py
index 5096b67..995a0c8 100755
--- a/6/bgp.py
+++ b/6/bgp.py
@@ -4,10 +4,9 @@ from swiplserver import PrologMQI, PrologThread
import yaml
import os
-def to_ansible(kind, objs):
- for o in objs:
- host = o['host']
- print(f"k={host}")
+def to_ansible(kind, hosts):
+ for host, o in hosts.items():
+ print(f"host={host}")
os.makedirs(f"group_vars/{host}", exist_ok=True)
with open(f"group_vars/{host}/{kind}.yaml", "w") as f:
f.write(yaml.dump(o))
diff --git a/6/group_vars/hash/bgp.yaml b/6/group_vars/hash/bgp.yaml
index e479515..8b57bbe 100644
--- a/6/group_vars/hash/bgp.yaml
+++ b/6/group_vars/hash/bgp.yaml
@@ -1,4 +1,3 @@
-host: hash
neighbors:
- neighbor:
hostname: fdf3:aad9:a885:0b3a::1
diff --git a/6/group_vars/knot/bgp.yaml b/6/group_vars/knot/bgp.yaml
index 808e2cf..23d0232 100644
--- a/6/group_vars/knot/bgp.yaml
+++ b/6/group_vars/knot/bgp.yaml
@@ -1,4 +1,3 @@
-host: knot
neighbors:
- neighbor:
hostname: fdf3:aad9:a885:0b3a::13
diff --git a/6/group_vars/kv24ix/bgp.yaml b/6/group_vars/kv24ix/bgp.yaml
index 4f69f7c..e4a0cf6 100644
--- a/6/group_vars/kv24ix/bgp.yaml
+++ b/6/group_vars/kv24ix/bgp.yaml
@@ -1,4 +1,3 @@
-host: kv24ix
neighbors:
- neighbor:
hostname: fdf3:aad9:a885:0b3a::13
diff --git a/6/group_vars/lhn2ix/bgp.yaml b/6/group_vars/lhn2ix/bgp.yaml
index 73732ae..e4a0cf6 100644
--- a/6/group_vars/lhn2ix/bgp.yaml
+++ b/6/group_vars/lhn2ix/bgp.yaml
@@ -1,4 +1,3 @@
-host: lhn2ix
neighbors:
- neighbor:
hostname: fdf3:aad9:a885:0b3a::13