From 49808acb6fd2cafcdbd1ef09e68cd782df4d6071 Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Sat, 3 Jul 2021 21:35:14 -0700 Subject: [PATCH] Improve handling of Junos XML errors --- hyperglass/parsing/juniper.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hyperglass/parsing/juniper.py b/hyperglass/parsing/juniper.py index 83c9fb1..3f2ad9b 100644 --- a/hyperglass/parsing/juniper.py +++ b/hyperglass/parsing/juniper.py @@ -65,6 +65,11 @@ def parse_juniper(output: Sequence) -> Dict: # noqa: C901 log.debug("Initially Parsed Response: \n{}", parsed) if "rpc-reply" in parsed.keys(): + if "xnm:error" in parsed["rpc-reply"]: + if "message" in parsed["rpc-reply"]["xnm:error"]: + err = parsed["rpc-reply"]["xnm:error"]["message"] + raise ParsingError('Error from device: "{}"', err) + parsed_base = parsed["rpc-reply"]["route-information"] elif "route-information" in parsed.keys(): parsed_base = parsed["route-information"]