Skip to content
Snippets Groups Projects
Commit 4ea64fe7 authored by Erik Reid's avatar Erik Reid
Browse files

added console output test data

parent d689384e
Branches
Tags
No related merge requests found
Showing
with 41889 additions and 10 deletions
......@@ -87,22 +87,39 @@ def shell_commands():
result[k] = v
return result
def _loads(s, **args):
"""
the json text contains raw backslashes
:param s:
:param args:
:return:
"""
return json.loads(s.replace("\\", "\\\\"), **args)
yield {
"command": "set cli screen-length 0",
"parser": lambda _: (None, None)
"key": None,
"parser": lambda _: None
}
yield {
"command": 'show configuration routing-instances IAS protocols bgp | display json',
"parser": lambda txt: ("bgp", list(neighbors(json.loads(txt))) if txt else {})
"key": "bgp",
"parser": lambda txt: list(neighbors(_loads(txt))) if txt else {}
}
yield {
"command": 'show configuration logical-systems VRR protocols bgp | display json',
"parser": lambda txt: ("vrr", json.loads(txt) if txt else {})
"key": "vrr",
"parser": lambda txt: json.loads(_loads(txt)) if txt else {}
}
yield {
"command": 'show interfaces descriptions | display json',
"parser": lambda txt: ("interfaces", list(interfaces(json.loads(txt, object_pairs_hook=_dups_to_list))) if txt else {})
"key": "interfaces",
"parser": lambda txt: list(interfaces(
_loads(
txt,
object_pairs_hook=_dups_to_list)
)) if txt else {}
}
......@@ -52,15 +52,14 @@ def get_router_details(router, params, q):
command_output = commands_proc_queue.get()
assert len(command_output) == len(commands)
for i, o in enumerate(command_output):
with open("/tmp/%s-%d.output" % (router["hostname"], i), "w") as f:
f.write(o)
# for i, o in enumerate(command_output):
# with open("/tmp/%s-%d.output" % (router["hostname"], i), "w") as f:
# f.write(o)
result = {}
for c, o in zip(commands, command_output):
parsed = c["parser"](o)
if parsed[0]:
result[parsed[0]] = parsed[1]
if c["key"]:
result[c] = c["parser"](o)
commands_proc.join()
threading_logger.debug("... got commands result & joined: %r" % router)
......
Screen length set to 0
This diff is collapsed.
This diff is collapsed.
Screen length set to 0
{
"configuration" : [
{
"attributes" : {"junos:commit-seconds" : "1541765460",
"junos:commit-localtime" : "2018-11-09 12:11:00 UTC",
"junos:commit-user" : "win\anura"
},
"routing-instances" : [
{
"instance" : [
{
"name" :
{
"data" : "IAS"
},
"protocols" : [
{
"bgp" : [
{
"log-updown" : [
{
"data" : null
}
],
"group" : [
{
"name" :
{
"data" : "IAS-NRENS"
},
"family" : [
{
"inet" : [
{
"unicast" : [
{
"rib-group" : [
{
"ribgroup-name" : [
{
"data" : "ias-to-geant-rtbh"
}
]
}
]
}
]
}
]
}
],
"neighbor" : [
{
"name" :
{
"data" : "83.97.88.66"
},
"description" : [
{
"data" : "-- Peering with GRNET --"
}
],
"accept-remote-nexthop" : [
{
"data" : null
}
],
"out-delay" : [
{
"data" : "10"
}
],
"import" : [
{
"data" : "ps-AS-SELF-REJECT"
},
{
"data" : "ps-BOGONS"
},
{
"data" : "ps-IAS-from-GRNET2-nren"
}
],
"family" : [
{
"inet" : [
{
"unicast" : [
{
"prefix-limit" : [
{
"maximum" : [
{
"data" : "125000"
}
]
}
]
}
]
}
]
}
],
"export" : [
{
"data" : "ps-BOGONS"
},
{
"data" : "ps-IAS-to-GRNET2-nren"
}
],
"peer-as" : [
{
"data" : "5408"
}
],
"local-as" : [
{
"as-number" : [
{
"data" : "21320"
}
],
"private" : [
{
"data" : null
}
],
"no-prepend-global-as" : [
{
"data" : null
}
]
}
]
},
{
"name" :
{
"data" : "83.97.88.199"
},
"description" : [
{
"data" : "-- Peering with CYNET --"
}
],
"accept-remote-nexthop" : [
{
"data" : null
}
],
"out-delay" : [
{
"data" : "10"
}
],
"import" : [
{
"data" : "ps-AS-SELF-REJECT"
},
{
"data" : "ps-BOGONS"
},
{
"data" : "ps-IAS-from-CYNET-nren"
}
],
"family" : [
{
"inet" : [
{
"unicast" : [
{
"prefix-limit" : [
{
"maximum" : [
{
"data" : "125000"
}
]
}
]
}
]
}
]
}
],
"authentication-key" : [
{
"data" : "/* SECRET-DATA */"
}
],
"export" : [
{
"data" : "ps-IAS-to-CYNET-nren"
},
{
"data" : "ps-BOGONS"
}
],
"peer-as" : [
{
"data" : "3268"
}
],
"local-as" : [
{
"as-number" : [
{
"data" : "21320"
}
],
"private" : [
{
"data" : null
}
],
"no-prepend-global-as" : [
{
"data" : null
}
]
}
]
}
]
},
{
"name" :
{
"data" : "IAS-NRENS-ipv6"
},
"family" : [
{
"inet6" : [
{
"unicast" : [
{
"rib-group" : [
{
"ribgroup-name" : [
{
"data" : "ias-to-geant-rtbh6"
}
]
}
]
}
]
}
]
}
],
"neighbor" : [
{
"name" :
{
"data" : "2001:798:1::56"
},
"description" : [
{
"data" : "-- IPv6 Peering with GRNET --"
}
],
"accept-remote-nexthop" : [
{
"data" : null
}
],
"out-delay" : [
{
"data" : "10"
}
],
"import" : [
{
"data" : "ps-AS-SELF-REJECT"
},
{
"data" : "ps-BOGONS-V6"
},
{
"data" : "ps-IAS-from-GRnet2-V6-nren"
}
],
"family" : [
{
"inet6" : [
{
"unicast" : [
{
"prefix-limit" : [
{
"maximum" : [
{
"data" : "125000"
}
]
}
]
}
]
}
]
}
],
"export" : [
{
"data" : "ps-BOGONS-V6"
},
{
"data" : "ps-IAS-to-GRnet2-V6-nren"
}
],
"peer-as" : [
{
"data" : "5408"
}
],
"local-as" : [
{
"as-number" : [
{
"data" : "21320"
}
],
"private" : [
{
"data" : null
}
],
"no-prepend-global-as" : [
{
"data" : null
}
]
}
]
},
{
"name" :
{
"data" : "2001:798:1::1a6"
},
"description" : [
{
"data" : "-- IPv6 Peering with CYNET --"
}
],
"accept-remote-nexthop" : [
{
"data" : null
}
],
"out-delay" : [
{
"data" : "10"
}
],
"import" : [
{
"data" : "ps-AS-SELF-REJECT"
},
{
"data" : "ps-BOGONS-V6"
},
{
"data" : "ps-IAS-from-CYNET-V6-nren"
}
],
"family" : [
{
"inet6" : [
{
"unicast" : [
{
"prefix-limit" : [
{
"maximum" : [
{
"data" : "125000"
}
]
}
]
}
]
}
]
}
],
"authentication-key" : [
{
"data" : "/* SECRET-DATA */"
}
],
"export" : [
{
"data" : "ps-IAS-to-CYNET-V6-nren"
},
{
"data" : "ps-BOGONS-V6"
}
],
"peer-as" : [
{
"data" : "3268"
}
],
"local-as" : [
{
"as-number" : [
{
"data" : "21320"
}
],
"private" : [
{
"data" : null
}
],
"no-prepend-global-as" : [
{
"data" : null
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
This diff is collapsed.
Screen length set to 0
{
"configuration" : [
{
"attributes" : {"junos:commit-seconds" : "1540564666",
"junos:commit-localtime" : "2018-10-26 14:37:46 UTC",
"junos:commit-user" : "python"
},
"routing-instances" : [
{
"instance" : [
{
"name" :
{
"data" : "IAS"
},
"protocols" : [
{
"bgp" : [
{
"log-updown" : [
{
"data" : null
}
],
"group" : [
{
"name" :
{
"data" : "IAS-NRENS"
},
"family" : [
{
"inet" : [
{
"unicast" : [
{
"rib-group" : [
{
"ribgroup-name" : [
{
"data" : "ias-to-geant-cls-rtbh"
}
]
}
]
}
]
}
]
}
],
"neighbor" : [
{
"name" :
{
"data" : "83.97.88.142"
},
"description" : [
{
"data" : "-- Peering with ROEDUNET --"
}
],
"accept-remote-nexthop" : [
{
"data" : null
}
],
"out-delay" : [
{
"data" : "10"
}
],
"import" : [
{
"data" : "ps-AS-SELF-REJECT"
},
{
"data" : "ps-BOGONS"
},
{
"data" : "ps-IAS-from-RoEduNet-nren"
}
],
"family" : [
{
"inet" : [
{
"unicast" : [
{
"prefix-limit" : [
{
"maximum" : [
{
"data" : "125000"
}
]
}
]
}
]
}
]
}
],
"export" : [
{
"data" : "ps-BOGONS"
},
{
"data" : "ps-IAS-to-RoEduNet-nren"
}
],
"peer-as" : [
{
"data" : "2614"
}
],
"local-as" : [
{
"as-number" : [
{
"data" : "21320"
}
],
"private" : [
{
"data" : null
}
],
"no-prepend-global-as" : [
{
"data" : null
}
]
}
]
},
{
"name" :
{
"data" : "83.97.88.197"
},
"description" : [
{
"data" : "-- Peering with RENAM --| under testing"
}
],
"accept-remote-nexthop" : [
{
"data" : null
}
],
"out-delay" : [
{
"data" : "10"
}
],
"import" : [
{
"data" : "ps-AS-SELF-REJECT"
},
{
"data" : "ps-BOGONS"
},
{
"data" : "ps-IAS-from-RENAM-nren"
}
],
"family" : [
{
"inet" : [
{
"unicast" : [
{
"prefix-limit" : [
{
"maximum" : [
{
"data" : "125000"
}
]
}
]
}
]
}
]
}
],
"export" : [
{
"data" : "ps-BOGONS"
},
{
"data" : "ps-IAS-to-RENAM-nren"
}
],
"peer-as" : [
{
"data" : "9199"
}
],
"local-as" : [
{
"as-number" : [
{
"data" : "21320"
}
],
"private" : [
{
"data" : null
}
],
"no-prepend-global-as" : [
{
"data" : null
}
]
}
]
}
]
},
{
"name" :
{
"data" : "IAS-NRENS-ipv6"
},
"family" : [
{
"inet6" : [
{
"unicast" : [
{
"rib-group" : [
{
"ribgroup-name" : [
{
"data" : "ias-to-geant-cls-rtbh6"
}
]
}
]
}
]
}
]
}
],
"neighbor" : [
{
"name" :
{
"data" : "2001:798:1::aa"
},
"description" : [
{
"data" : "-- IPv6 Peering with ROEDUNET --"
}
],
"accept-remote-nexthop" : [
{
"data" : null
}
],
"out-delay" : [
{
"data" : "10"
}
],
"import" : [
{
"data" : "ps-AS-SELF-REJECT"
},
{
"data" : "ps-BOGONS-V6"
},
{
"data" : "ps-IAS-from-RoEduNet-V6-nren"
}
],
"family" : [
{
"inet6" : [
{
"unicast" : [
{
"prefix-limit" : [
{
"maximum" : [
{
"data" : "125000"
}
]
}
]
}
]
}
]
}
],
"export" : [
{
"data" : "ps-BOGONS-V6"
},
{
"data" : "ps-IAS-to-RoEduNet-V6-nren"
}
],
"peer-as" : [
{
"data" : "2614"
}
],
"local-as" : [
{
"as-number" : [
{
"data" : "21320"
}
],
"private" : [
{
"data" : null
}
],
"no-prepend-global-as" : [
{
"data" : null
}
]
}
]
},
{
"name" :
{
"data" : "2001:798:1::1a2"
},
"description" : [
{
"data" : "-- IPv6 Peering with RENAM --|under testing"
}
],
"accept-remote-nexthop" : [
{
"data" : null
}
],
"out-delay" : [
{
"data" : "10"
}
],
"import" : [
{
"data" : "ps-AS-SELF-REJECT"
},
{
"data" : "ps-BOGONS-V6"
},
{
"data" : "ps-IAS-from-RENAM-V6-nren"
}
],
"family" : [
{
"inet6" : [
{
"unicast" : [
{
"prefix-limit" : [
{
"maximum" : [
{
"data" : "125000"
}
]
}
]
}
]
}
]
}
],
"export" : [
{
"data" : "ps-BOGONS-V6"
},
{
"data" : "ps-IAS-to-RENAM-V6-nren"
}
],
"peer-as" : [
{
"data" : "9199"
}
],
"local-as" : [
{
"as-number" : [
{
"data" : "21320"
}
],
"private" : [
{
"data" : null
}
],
"no-prepend-global-as" : [
{
"data" : null
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
This diff is collapsed.
Screen length set to 0
This diff is collapsed.
This diff is collapsed.
Screen length set to 0
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment