From e407b0195c979614d3a4ba22b229f45ec130c260 Mon Sep 17 00:00:00 2001 From: xuu Date: Thu, 2 Nov 2017 14:01:09 -0600 Subject: [PATCH] add fmt tool --- data/aut-num/AS64738 | 182 +++++++++++++++--------------- utils/schema-check/dn42-schema.py | 27 +++++ 2 files changed, 118 insertions(+), 91 deletions(-) diff --git a/data/aut-num/AS64738 b/data/aut-num/AS64738 index 2f491a0ef..c93052e3f 100644 --- a/data/aut-num/AS64738 +++ b/data/aut-num/AS64738 @@ -1,91 +1,91 @@ -aut-num: AS64738 -as-name: WELTERDE-AS -descr: welterde's AS -remarks: ------< IPv6 downstream >--------------------------------------------- -remarks: <<<<<>>>>> sigi via openvpn over VDSL -mp-group: id sigi-vdsl - node hex.fal2.welterde.net - afi ipv6.unicast - as AS64739 - interface sigi.adq - local fdef:5d0d:ee12:3:1:2:fce3:36 - remote fdef:5d0d:ee12:3:1:2:fce3:42 -mp-peer: id _:sigi-vdsl - ACTION in 64738:2012 community:append - ACCEPT SIGI-SIXXS-IP6NET - ANNOUNCE ANY -remarks: <<<<<>>>>> helios-eve -mp-group: id helios-eve - node gandalf.fal1.welterde.net - as AS64794 - interface helios.eve - ACTION in 64738:2013 community:append - ANNOUNCE ANY - ACCEPT ANY -mp-peer: id _:helios-eve - afi ipv6.unicast - local openvpn-helios-eve.tunnel.gandalf.fal1.welterde.net - remote fdef:5d0d:ee12:3:1:1:fd1a:42 -mp-peer: id helios-eve-ip4:helios-eve - afi ipv4.unicast - local 172.22.255.0 - remote 172.22.255.1 -remarks: <<<<<>>>>> neoraider-chaos -mp-group: id neoraider-chaos - node gandalf.fal1.welterde.net - as AS64784 - interface neoraider.chaos - local openvpn-neoraider-chaos.tunnel.gandalf.fal1.welterde.net - remote welterde-gw.chaos.universe-factory.net - ACTION in 64738:2013 community:append - ACCEPT ANY - ANNOUNCE ANY -mp-peer: id _:neoraider-chaos - afi ipv6.unicast -mp-peer: id _:neoraider-chaos - afi ipv4.unicast -remarks: ------< tinc42 IX >--------------------------------------------------- -remarks: ------[ common ]------------------------------------------------------ -mp-group: id tinc42-ix - node hex.fal2.welterde.net - interface tinc42 - local tinc-tinc42.tunnel.hex.fal2.welterde.net -remarks: ------[ peers ]------------------------------------------------------- -remarks: more route information goes here -remarks: ------< IPv6 communities >-------------------------------------------- -remarks: (0 ) => (0,) Do not advertise to -remarks: (1 ) => (64738,3001) Prepend 64738 1 time -remarks: (2 ) => (64738,3002) Prepend 64738 2 times -remarks: (3 ) => (64738,3003) Prepend 64738 3 times -remarks: (5 ) => (1,) Advertise to -remarks: (10 ) => (64738,4) Do not advertise at -remarks: => (64738,4001) Do not advertise at fal1 -remarks: (15 ) => (3,) Advertise to -remarks: (20 ) => (64738,5) Advertise at -remarks: (25 ) => (64738,3000) Advertise to noone -remarks: (100) => (64738,5000) Advertise to everyone -remarks: -remarks: => (64738,2001) High latency route -remarks: => (64738,2011) Low bandwidth route - <= 1MBit -remarks: => (64738,2012) Medium bandwidth route - < 10Mbit -remarks: => (64738,2013) High bandwidth route - >= 10Mbit -remarks: -----< Locations >---------------------------------------------------- -remarks: (000) => whole AS Implemented via seperate rules -remarks: (001) => fal1 Falkenstein1 - hetzner RZ10 -remarks: (002) => fal2 Falkenstein2 - hetzner RZ12 -remarks: (003) => fmt1 Fremont1 - egihosting via HE -remarks: (004) => ulm1 Ulm1 - @home via acor -remarks: (005) => gar1 Garching1 - @home via m-net -remarks: (006) => jen1 Jena1 - EUServ -remarks: (100) => otr On the run/road - machines not tied to a location -remarks: -----< Routers >------------------------------------------------------ -remarks: (001) => gandalf.fal1 -remarks: (002) => hex.fal2 -remarks: (003) => arda.fmt1 -remarks: (004) => atomi.ulm1 -remarks: (005) => cizzco-1760-1.gar1 -remarks: (006) => dwarfen.jen1 -remarks: (007) => tux.gar1 -admin-c: WELTERDE-DN42 -tech-c: WELTERDE-DN42 -mnt-by: DUMMY-MNT +aut-num: AS64738 +as-name: WELTERDE-AS +descr: welterde's AS +remarks: ------< IPv6 downstream >--------------------------------------------- +remarks: <<<<<>>>>> sigi via openvpn over VDSL +mp-group: id sigi-vdsl + node hex.fal2.welterde.net + afi ipv6.unicast + as AS64739 + interface sigi.adq + local fdef:5d0d:ee12:3:1:2:fce3:36 + remote fdef:5d0d:ee12:3:1:2:fce3:42 +mp-peer: id _:sigi-vdsl + ACTION in 64738:2012 community:append + ACCEPT SIGI-SIXXS-IP6NET + ANNOUNCE ANY +remarks: <<<<<>>>>> helios-eve +mp-group: id helios-eve + node gandalf.fal1.welterde.net + as AS64794 + interface helios.eve + ACTION in 64738:2013 community:append + ANNOUNCE ANY + ACCEPT ANY +mp-peer: id _:helios-eve + afi ipv6.unicast + local openvpn-helios-eve.tunnel.gandalf.fal1.welterde.net + remote fdef:5d0d:ee12:3:1:1:fd1a:42 +mp-peer: id helios-eve-ip4:helios-eve + afi ipv4.unicast + local 172.22.255.0 + remote 172.22.255.1 +remarks: <<<<<>>>>> neoraider-chaos +mp-group: id neoraider-chaos + node gandalf.fal1.welterde.net + as AS64784 + interface neoraider.chaos + local openvpn-neoraider-chaos.tunnel.gandalf.fal1.welterde.net + remote welterde-gw.chaos.universe-factory.net + ACTION in 64738:2013 community:append + ACCEPT ANY + ANNOUNCE ANY +mp-peer: id _:neoraider-chaos + afi ipv6.unicast +mp-peer: id _:neoraider-chaos + afi ipv4.unicast +remarks: ------< tinc42 IX >--------------------------------------------------- +remarks: ------[ common ]------------------------------------------------------ +mp-group: id tinc42-ix + node hex.fal2.welterde.net + interface tinc42 + local tinc-tinc42.tunnel.hex.fal2.welterde.net +remarks: ------[ peers ]------------------------------------------------------- +remarks: more route information goes here +remarks: ------< IPv6 communities >-------------------------------------------- +remarks: (0 ) => (0,) Do not advertise to +remarks: (1 ) => (64738,3001) Prepend 64738 1 time +remarks: (2 ) => (64738,3002) Prepend 64738 2 times +remarks: (3 ) => (64738,3003) Prepend 64738 3 times +remarks: (5 ) => (1,) Advertise to +remarks: (10 ) => (64738,4) Do not advertise at +remarks: => (64738,4001) Do not advertise at fal1 +remarks: (15 ) => (3,) Advertise to +remarks: (20 ) => (64738,5) Advertise at +remarks: (25 ) => (64738,3000) Advertise to noone +remarks: (100) => (64738,5000) Advertise to everyone +remarks: +remarks: => (64738,2001) High latency route +remarks: => (64738,2011) Low bandwidth route - <= 1MBit +remarks: => (64738,2012) Medium bandwidth route - < 10Mbit +remarks: => (64738,2013) High bandwidth route - >= 10Mbit +remarks: -----< Locations >---------------------------------------------------- +remarks: (000) => whole AS Implemented via seperate rules +remarks: (001) => fal1 Falkenstein1 - hetzner RZ10 +remarks: (002) => fal2 Falkenstein2 - hetzner RZ12 +remarks: (003) => fmt1 Fremont1 - egihosting via HE +remarks: (004) => ulm1 Ulm1 - @home via acor +remarks: (005) => gar1 Garching1 - @home via m-net +remarks: (006) => jen1 Jena1 - EUServ +remarks: (100) => otr On the run/road - machines not tied to a location +remarks: -----< Routers >------------------------------------------------------ +remarks: (001) => gandalf.fal1 +remarks: (002) => hex.fal2 +remarks: (003) => arda.fmt1 +remarks: (004) => atomi.ulm1 +remarks: (005) => cizzco-1760-1.gar1 +remarks: (006) => dwarfen.jen1 +remarks: (007) => tux.gar1 +admin-c: WELTERDE-DN42 +tech-c: WELTERDE-DN42 +mnt-by: DUMMY-MNT diff --git a/utils/schema-check/dn42-schema.py b/utils/schema-check/dn42-schema.py index 0a6b4bd5e..c73486a1b 100755 --- a/utils/schema-check/dn42-schema.py +++ b/utils/schema-check/dn42-schema.py @@ -182,7 +182,20 @@ class FileDOM: self.schema = schema self.src = src + def __str__(self): + length = 13 + for i in self.dom: + if len(i[0]) > length: + length = len(i[0]) + 2 + s = "" + for i in self.dom: + l = i[1].split("\n") + s += i[0] + ":" + " " * (length - len(i[0])) + l[0] + "\n" + for m in l[1:]: + s += " " * (length + 1) + m + "\n" + + return s def main(infile, schema): log.debug("Check File: %s" % (infile)) @@ -365,6 +378,12 @@ def get_args(): parser_scan.add_argument('-m', '--use-mntner', nargs='?', help="Only scan files that has a matching MNT [Default None]", action="store") + parser_fmt = subparsers.add_parser('fmt', help='Format file') + parser_fmt.add_argument( + 'infile', nargs="?", help="Path for dn42 data file", type=str) + parser_fmt.add_argument('-i', '--in-place', + help="Format file in place", action="store_true") + return vars(parser.parse_args()) @@ -410,3 +429,11 @@ if __name__ == '__main__': sys.exit(2) elif ck == "FAIL": sys.exit(1) + + elif args["command"] == "fmt": + dom = FileDOM(args["infile"]) + if args["in_place"]: + with open(args["infile"], 'w+') as f: + f.write(str(dom)) + + print(str(dom))