From 2c76aa98d5fe49f57c94bde4cbe2ba5ca1ff338a Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 14 Nov 2023 19:50:21 +0100 Subject: wip --- 6/bgp.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to '6/bgp.py') diff --git a/6/bgp.py b/6/bgp.py index 2bd756a..d508762 100755 --- a/6/bgp.py +++ b/6/bgp.py @@ -13,10 +13,22 @@ def to_ansible(kind, hosts): with PrologMQI() as mqi: with mqi.create_thread() as p: - result = p.query("consult(main)") + result = p.query("consult(main), main.") print(result) result = p.query("bgp:bird_config(BirdDict)") r = result[0]["BirdDict"] print(yaml.dump(r)) to_ansible("bgp", r) + + hosts = {} + result = p.query("firewall:fw_rule(Host, Attrs).") +# print(yaml.dump(result)) + for r in result: + host = r["Host"] + if host not in hosts: + hosts[host] = h = {} + h["firewall_rules"] = rules = [] + rules.append(r["Attrs"]) + + to_ansible("firewall", hosts) -- cgit v1.2.3