From 8a29082b7bdfaf9e782b14635c9886288333d311 Mon Sep 17 00:00:00 2001 From: "David M. Johnson" Date: Wed, 6 May 2015 09:25:53 -0600 Subject: [PATCH] Bug Fix: don't add undefined ports to list returned by getVlanPorts(). Handles the case where a wire in the wires table has an 'Unused' role (which is how logical wires begin life -- then once their underlying physical links are built into vlans, snmpit changes their wires.role changes to 'Node'). This change ensures undef ports (which is what is returned for wires entries with 'Unused' roles) don't make it into the getVlanPorts list, where they cause snmpit to die, of course. --- tbsetup/snmpit_test/snmpit_lib.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tbsetup/snmpit_test/snmpit_lib.pm b/tbsetup/snmpit_test/snmpit_lib.pm index 21f9a3c2e..560f88bfd 100644 --- a/tbsetup/snmpit_test/snmpit_lib.pm +++ b/tbsetup/snmpit_test/snmpit_lib.pm @@ -360,13 +360,21 @@ sub getVlanPorts (@) { foreach my $member (@members) { my $nodeid; my $iface; + my $port; if ($member->GetAttribute("node_id", \$nodeid) != 0 || $member->GetAttribute("iface", \$iface) != 0) { die("*** $0:\n". " Missing attributes for $member in $vlan\n"); } - push(@ports, Port->LookupByIface($nodeid, $iface)); + $port = Port->LookupByIface($nodeid, $iface); + # + # Ports can be undef -- i.e., if this is a layer 2 path implemented + # by layer 1 wires, it hasn't been given a type yet. + # + if (defined($port)) { + push(@ports, $port); + } } } return @ports; -- GitLab