Skip to content

Commit

Permalink
Merge pull request #1320 from jonstout/nso-link-discovery
Browse files Browse the repository at this point in the history
wrap load_xml call in eval to prevent crash
  • Loading branch information
jonstout authored Aug 12, 2021
2 parents 13a6fbd + 3c0ea0f commit b973da0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion perl-lib/OESS/lib/OESS/NSO/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ sub get_vrf_statistics {
my $err = $self->get_json_errors($result);
if (defined $err) {
&$sub($response, $err);
return;
}

# Extract CLI payload from JSON response and strip leading
Expand All @@ -654,7 +655,15 @@ sub get_vrf_statistics {
$raw_response =~ s/<\/Response>.*\z/<\/Response>/s;

# Parse XMl string and extract statistics
my $dom = XML::LibXML->load_xml(string => $raw_response);
my $dom;
eval {
$dom = XML::LibXML->load_xml(string => $raw_response);
};
if ($@) {
$self->{logger}->error("Failed to load XML in get_vrf_statistics: $body");
&$sub($response, "$@");
return;
}

# Lookup Instance named 'default' and get VRFTable from inside
my $instances = $dom->findnodes('//Response/Get/Operational/BGP/InstanceTable/Instance');
Expand Down

0 comments on commit b973da0

Please sign in to comment.