From f548ecd9abc3d8ca438826f9203408137acdf235 Mon Sep 17 00:00:00 2001 From: ubaumann Date: Sat, 10 Jul 2021 17:30:15 +0200 Subject: [PATCH 1/5] Change interfaces to a mapping --- example-result.json | 90 +++++++++++++++++---------------------------- show_run.ttp | 2 +- 2 files changed, 35 insertions(+), 57 deletions(-) diff --git a/example-result.json b/example-result.json index 009a6e0..c719c15 100644 --- a/example-result.json +++ b/example-result.json @@ -1,9 +1,8 @@ [ [ { - "interfaces": [ - { - "interface": "Loopback1", + "interfaces": { + "Loopback1": { "mode": null, "disabled": false, "ip": null, @@ -20,12 +19,11 @@ "output_mac_acl": null, "input_policy": null }, - { + "FastEthernet0/0": { "speed": "auto", "duplex": "auto", "ip": "10.0.2.33", "mask": "255.255.255.0", - "interface": "FastEthernet0/0", "mode": null, "disabled": false, "description": null, @@ -38,13 +36,12 @@ "output_mac_acl": null, "input_policy": null }, - { + "FastEthernet0/1": { "speed": "auto", "duplex": "auto", "ip": "192.168.1.1", "mask": "255.255.255.0", "description": "cat", - "interface": "FastEthernet0/1", "mode": null, "disabled": false, "dot1q": null, @@ -56,12 +53,11 @@ "output_mac_acl": null, "input_policy": null }, - { + "FastEthernet1/0": { "speed": "auto", "duplex": "auto", "ip": "192.168.3.1", "mask": "255.255.255.0", - "interface": "FastEthernet1/0", "mode": null, "disabled": false, "description": null, @@ -74,10 +70,9 @@ "output_mac_acl": null, "input_policy": null }, - { + "FastEthernet2/0": { "speed": "auto", "duplex": "auto", - "interface": "FastEthernet2/0", "mode": null, "disabled": false, "ip": null, @@ -92,8 +87,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/0", + "FastEthernet3/0": { "mode": null, "disabled": false, "ip": null, @@ -110,8 +104,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/1", + "FastEthernet3/1": { "mode": null, "disabled": false, "ip": null, @@ -128,8 +121,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/2", + "FastEthernet3/2": { "mode": null, "disabled": false, "ip": null, @@ -146,8 +138,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/3", + "FastEthernet3/3": { "mode": null, "disabled": false, "ip": null, @@ -164,8 +155,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/4", + "FastEthernet3/4": { "mode": null, "disabled": false, "ip": null, @@ -182,8 +172,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/5", + "FastEthernet3/5": { "mode": null, "disabled": false, "ip": null, @@ -200,8 +189,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/6", + "FastEthernet3/6": { "mode": null, "disabled": false, "ip": null, @@ -218,8 +206,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/7", + "FastEthernet3/7": { "mode": null, "disabled": false, "ip": null, @@ -236,8 +223,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/8", + "FastEthernet3/8": { "mode": null, "disabled": false, "ip": null, @@ -254,8 +240,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/9", + "FastEthernet3/9": { "mode": null, "disabled": false, "ip": null, @@ -272,8 +257,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/10", + "FastEthernet3/10": { "mode": null, "disabled": false, "ip": null, @@ -290,8 +274,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/11", + "FastEthernet3/11": { "mode": null, "disabled": false, "ip": null, @@ -308,8 +291,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/12", + "FastEthernet3/12": { "mode": null, "disabled": false, "ip": null, @@ -326,8 +308,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/13", + "FastEthernet3/13": { "mode": null, "disabled": false, "ip": null, @@ -344,8 +325,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/14", + "FastEthernet3/14": { "mode": null, "disabled": false, "ip": null, @@ -362,8 +342,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "FastEthernet3/15", + "FastEthernet3/15": { "mode": null, "disabled": false, "ip": null, @@ -380,10 +359,9 @@ "output_mac_acl": null, "input_policy": null }, - { + "Port-channel1": { "negation": "auto", "description": "", - "interface": "Port-channel1", "mode": null, "disabled": false, "ip": null, @@ -437,11 +415,10 @@ } ] }, - { + "Vlan1": { "input_policy": "BG_MARKING", "output_mac_acl": "MAC_ACL", "input_mac_acl": "MAC_ACL", - "interface": "Vlan1", "mode": null, "disabled": false, "ip": null, @@ -455,8 +432,7 @@ "vlan": null, "ip_directed_broadcast": null }, - { - "interface": "Vlan2", + "Vlan2": { "mode": null, "disabled": false, "ip": null, @@ -473,8 +449,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "Vlan3", + "Vlan3": { "mode": null, "disabled": false, "ip": null, @@ -491,8 +466,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "Vlan5", + "Vlan5": { "mode": null, "disabled": false, "ip": null, @@ -509,8 +483,7 @@ "output_mac_acl": null, "input_policy": null }, - { - "interface": "Vlan99", + "Vlan99": { "mode": null, "disabled": false, "ip": null, @@ -527,7 +500,7 @@ "output_mac_acl": null, "input_policy": null } - ], + }, "global": { "http_server": { "enabled": false @@ -1269,6 +1242,11 @@ } ] }, + "eigrp": { + "no_passive_interface": { + "interface": "Loopback0" + } + }, "bgp": [ { "neighbor_ip": "10.0.0.4", diff --git a/show_run.ttp b/show_run.ttp index f930b96..06e8d57 100644 --- a/show_run.ttp +++ b/show_run.ttp @@ -1,4 +1,4 @@ - + interface {{ interface }} {{ mode | set(None) }} {{ disabled | set(False) }} From 3292aad2e04796e2a0e6a2949b3fa370dff31b2e Mon Sep 17 00:00:00 2001 From: ubaumann Date: Sat, 10 Jul 2021 17:34:22 +0200 Subject: [PATCH 2/5] Change interfaces service instances to mapping --- example-result.json | 13 +++++-------- show_run.ttp | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/example-result.json b/example-result.json index c719c15..c06b41b 100644 --- a/example-result.json +++ b/example-result.json @@ -376,9 +376,8 @@ "input_mac_acl": null, "output_mac_acl": null, "input_policy": null, - "service_instance": [ - { - "id": "100", + "service_instance": { + "100": { "pop": "1", "symmetric": "symmetric", "input_policy": "PM-INGRESS-NETCONTROL-COS", @@ -389,9 +388,8 @@ "second_vlan": "32" } }, - { + "151": { "description": "TDM-E1_WT", - "id": "151", "pop": "1", "symmetric": "symmetric", "input_policy": "PM-INGRESS-NNI-TDM", @@ -401,9 +399,8 @@ "vlan": "151" } }, - { + "152": { "description": "TDM-E1_PT", - "id": "152", "pop": "1", "symmetric": "symmetric", "input_policy": "PM-INGRESS-NNI-TDM", @@ -413,7 +410,7 @@ "vlan": "default" } } - ] + } }, "Vlan1": { "input_policy": "BG_MARKING", diff --git a/show_run.ttp b/show_run.ttp index 06e8d57..d30c734 100644 --- a/show_run.ttp +++ b/show_run.ttp @@ -32,7 +32,7 @@ interface {{ interface }} mac access-group {{ input_mac_acl }} in mac access-group {{ output_mac_acl }} out service-policy input {{ input_policy }} - + {{ pop | set(None) }} {{ symmetric | set(False) }} {{ input_policy | set(None) }} From 69d2a82c0a7b4026f4374373df290ee229e898a3 Mon Sep 17 00:00:00 2001 From: ubaumann Date: Sat, 10 Jul 2021 17:44:33 +0200 Subject: [PATCH 3/5] Change bridge domains to mapping --- example-result.json | 54 ++++++++++++++++++--------------------------- show_run.ttp | 2 +- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/example-result.json b/example-result.json index c06b41b..8658f70 100644 --- a/example-result.json +++ b/example-result.json @@ -1004,48 +1004,38 @@ } ] }, - "bridge_domain": [ - { - "igmp_snooping_enabled": false, - "name": "3001" + "bridge_domain": { + "3001": { + "igmp_snooping_enabled": false }, - { - "igmp_snooping_enabled": false, - "name": "3002" + "3002": { + "igmp_snooping_enabled": false }, - { - "igmp_snooping_enabled": false, - "name": "3003" + "3003": { + "igmp_snooping_enabled": false }, - { - "igmp_snooping_enabled": false, - "name": "3004" + "3004": { + "igmp_snooping_enabled": false }, - { - "igmp_snooping_enabled": false, - "name": "3005" + "3005": { + "igmp_snooping_enabled": false }, - { - "igmp_snooping_enabled": false, - "name": "3006" + "3006": { + "igmp_snooping_enabled": false }, - { - "igmp_snooping_enabled": false, - "name": "3007" + "3007": { + "igmp_snooping_enabled": false }, - { - "igmp_snooping_enabled": false, - "name": "3008" + "3008": { + "igmp_snooping_enabled": false }, - { - "igmp_snooping_enabled": false, - "name": "3009" + "3009": { + "igmp_snooping_enabled": false }, - { - "igmp_snooping_enabled": false, - "name": "3010" + "3010": { + "igmp_snooping_enabled": false } - ] + } }, "management": { "hostname": { diff --git a/show_run.ttp b/show_run.ttp index d30c734..caf6770 100644 --- a/show_run.ttp +++ b/show_run.ttp @@ -309,7 +309,7 @@ class-map match-{{match_type}} {{class_name}} - + bridge-domain {{name}} {{ igmp_snooping_enabled | set(True) }} no ip igmp snooping{{ igmp_snooping_enabled | set(False) }} From e372e9a899390fa8f78e04c656b5d929a0493a73 Mon Sep 17 00:00:00 2001 From: ubaumann Date: Sat, 10 Jul 2021 17:58:20 +0200 Subject: [PATCH 4/5] Change lines to mapping --- example-result.json | 16 ++++++---------- show_run.ttp | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/example-result.json b/example-result.json index 8658f70..322d995 100644 --- a/example-result.json +++ b/example-result.json @@ -1091,30 +1091,26 @@ } } ], - "line": [ - { + "line": { + "con 0": { "logging": "synchronous", - "vty": "con 0", "password": null }, - { + "aux 0": { "logging": "synchronous", - "vty": "aux 0", "password": null }, - { + "vty 0 4": { "input": "ssh", "local": "local", - "vty": "vty 0 4", "password": null }, - { + "vty 5 15": { "input": "ssh", "local": "local", - "vty": "vty 5 15", "password": null } - ] + } }, "routing": { "routes": { diff --git a/show_run.ttp b/show_run.ttp index caf6770..502265b 100644 --- a/show_run.ttp +++ b/show_run.ttp @@ -155,7 +155,7 @@ vtp mode transparent{{ enabled | set(False) }} ntp server {{ ip_address }} - + line {{ vty | re(".+") | record(vty) }} {{ password | set(None) }} logging {{logging}} From d60a637034b33795f7a355244b1b10b3c2ff12eb Mon Sep 17 00:00:00 2001 From: ubaumann Date: Sun, 11 Jul 2021 09:54:43 +0200 Subject: [PATCH 5/5] Change OSPF and OSPF networks to mappings --- example-result.json | 84 +++++++++++++++++++-------------------------- show_run.ttp | 8 ++--- 2 files changed, 39 insertions(+), 53 deletions(-) diff --git a/example-result.json b/example-result.json index 322d995..a70ba09 100644 --- a/example-result.json +++ b/example-result.json @@ -1117,58 +1117,44 @@ "weight": null }, "ospf": { - "router_id": "10.249.16.152", - "process": "7306", - "passive_interface_enabled": true, - "area": { - "area": "0.0.0.60", - "area_type": "nssa" - }, - "no_passive_interface": { - "interface": "Loopback0" - }, - "networks": [ - { - "network": "10.249.16.152", - "wildcard": "0.0.0.0", - "area": "0.0.0.60" - }, - { - "network": "10.249.24.136", - "wildcard": "0.0.0.7", - "area": "0.0.0.60" - }, - { - "network": "10.249.29.24", - "wildcard": "0.0.0.7", - "area": "0.0.0.60" - }, - { - "network": "10.251.250.94", - "wildcard": "0.0.0.1", - "area": "0.0.0.60" - }, - { - "network": "10.251.250.180", - "wildcard": "0.0.0.1", - "area": "0.0.0.60" - }, - { - "network": "10.251.253.88", - "wildcard": "0.0.0.1", - "area": "0.0.0.60" + "7306": { + "router_id": "10.249.16.152", + "passive_interface_enabled": true, + "area": { + "0.0.0.60": { + "area_type": "nssa" + } }, - { - "network": "10.251.253.90", - "wildcard": "0.0.0.1", - "area": "0.0.0.60" + "no_passive_interface": { + "interface": "Loopback0" }, - { - "network": "10.251.253.168", - "wildcard": "0.0.0.7", - "area": "0.0.0.60" + "networks": { + "10.249.16.152/0": { + "area": "0.0.0.60" + }, + "10.249.24.136/29": { + "area": "0.0.0.60" + }, + "10.249.29.24/29": { + "area": "0.0.0.60" + }, + "10.251.250.94/31": { + "area": "0.0.0.60" + }, + "10.251.250.180/31": { + "area": "0.0.0.60" + }, + "10.251.253.88/31": { + "area": "0.0.0.60" + }, + "10.251.253.90/31": { + "area": "0.0.0.60" + }, + "10.251.253.168/29": { + "area": "0.0.0.60" + } } - ] + } }, "rip": { "redistribute": "static", diff --git a/show_run.ttp b/show_run.ttp index 502265b..27bcede 100644 --- a/show_run.ttp +++ b/show_run.ttp @@ -186,11 +186,11 @@ vrf {{ vrf | re(".+") | record(vrf) }} exit-address-family - + router ospf {{ process | re(".+") | record(process) }} {{ router_id | set(None) }} router-id {{ router_id }} - + area {{ area }} {{ area_type }} {{ passive_interface_enabled | set(False) }} @@ -198,8 +198,8 @@ router ospf {{ process | re(".+") | record(process) }} no passive-interface {{interface}} - - network {{network}} {{wildcard}} area {{area}} + + network {{network | PHRASE | to_ip | with_prefixlen}} area {{area}}