Skip to content

Commit

Permalink
Added an interface pattern for the types of interfaces that get_inter…
Browse files Browse the repository at this point in the history
…faces() would normally throw an exception
  • Loading branch information
ktulu2602 committed Jun 5, 2018
1 parent 9210a81 commit f81a9e5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion napalm_panos/panos.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from datetime import datetime
import time
import re

# local modules
try:
Expand Down Expand Up @@ -515,6 +516,7 @@ def get_interfaces(self):
'mac_address': '',
'description': 'N/A'
}
interface_pattern = re.compile(r'(ethernet\d+\.\d+)|(ae\d+\.\d+)|(loopback\.)|(tunnel\.)')
interface_dict = {}
interface_list = self._extract_interface_list()

Expand All @@ -528,7 +530,7 @@ def get_interfaces(self):
interface_info_json = json.dumps(interface_info_xml['response']['result']['hw'])
interface_info = json.loads(interface_info_json)
except KeyError as err:
if 'loopback.' in intf and 'hw' in str(err):
if interface_pattern.search(intf) and 'hw' in str(err):
# loopback sub-ifs don't return a 'hw' key
interface_dict[intf] = LOOPBACK_SUBIF_DEFAULTS
continue
Expand Down

0 comments on commit f81a9e5

Please sign in to comment.