diff --git a/napalm_panos/panos.py b/napalm_panos/panos.py index a89c404..42dd8c1 100644 --- a/napalm_panos/panos.py +++ b/napalm_panos/panos.py @@ -508,7 +508,7 @@ def get_route_to(self, destination='', protocol=''): return routes def get_interfaces(self): - LOOPBACK_SUBIF_DEFAULTS = { + SUBIF_DEFAULTS = { 'is_up': True, 'is_enabled': True, 'speed': 0, @@ -516,7 +516,7 @@ def get_interfaces(self): 'mac_address': '', 'description': 'N/A' } - interface_pattern = re.compile(r"(ethernet\d+/\d+\.\d+)|(ae\d+\.\d+)|(loopback\.)|(tunnel\.)") + subintf_pattern = re.compile(r"(ethernet\d+/\d+\.\d+)|(ae\d+\.\d+)|(loopback\.)|(tunnel\.)") interface_dict = {} interface_list = self._extract_interface_list() @@ -530,9 +530,9 @@ 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 interface_pattern.search(intf) and 'hw' in str(err): - # loopback sub-ifs don't return a 'hw' key - interface_dict[intf] = LOOPBACK_SUBIF_DEFAULTS + if subintf_pattern.search(intf) and 'hw' in str(err): + # physical/ae/tunnel/loopback sub-ifs don't return a 'hw' key + interface_dict[intf] = SUBIF_DEFAULTS continue raise diff --git a/test/unit/mocked_data/test_get_interfaces/normal/_show__interface_all__interface___show_.xml b/test/unit/mocked_data/test_get_interfaces/normal/_show__interface_all__interface___show_.xml index f11dbbd..ee6f0c5 100644 --- a/test/unit/mocked_data/test_get_interfaces/normal/_show__interface_all__interface___show_.xml +++ b/test/unit/mocked_data/test_get_interfaces/normal/_show__interface_all__interface___show_.xml @@ -2,7 +2,7 @@ ethernet1/1 - Trust + N/A 1 @@ -12,6 +12,18 @@ 16 + + ethernet1/1.143 + Untrust + vr:default + 1 + + + 143 + 1.2.3.4/28 + 256 + + ethernet1/2 Untrust @@ -48,6 +60,30 @@ 256 + + tunnel + + N/A + 1 + + + 0 + N/A + 4 + + + + tunnel.100 + zone1 + vr:default + 1 + + + 0 + 2.3.4.5/30 + 259 + + @@ -55,10 +91,10 @@ full 0 up - 1000/full/up - ba:db:ee:fb:ad:10 + 10000/full/up + 00:50:56:11:22:33 (autoneg) - 1000 + 10000 16 @@ -105,5 +141,16 @@ [n/a] 3 + + tunnel + [n/a] + 6 + up + [n/a]/[n/a]/up + e4:a7:49:aa:bb:cc + (unknown) + [n/a] + 4 + diff --git a/test/unit/mocked_data/test_get_interfaces/normal/_show__interface_ethernet1_1__interface___show_.xml b/test/unit/mocked_data/test_get_interfaces/normal/_show__interface_ethernet1_1__interface___show_.xml index 8d67353..55bd1fe 100644 --- a/test/unit/mocked_data/test_get_interfaces/normal/_show__interface_ethernet1_1__interface___show_.xml +++ b/test/unit/mocked_data/test_get_interfaces/normal/_show__interface_ethernet1_1__interface___show_.xml @@ -1,83 +1,92 @@ - - - - - - vsys1 - - - - - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - ethernet1/1 - 0 - 0 - 0 - 0 - 0 - - - - - 0 - ethernet1/1 - 0 - 431 - 0 - 431 - 27642 - - 0 - 1 - 426 - 0 - 1 - 27354 - 0 - 90 - - - - - - False - False - 0 - layer3 - Trust - 16 - False - ethernet1/1 - - - ethernet1/1 - full - 0 - auto - ba:db:ee:fb:ad:10 - up - auto - layer3 - auto - 1000 - 16 - False - - dp0 - + + + + False + 0 + + + + vsys1 + + + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2906986214 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ethernet1/1 + 0 + 0 + 8476173 + 0 + 0 + 0 + 8476173 + + + + + 14379659738635 + ethernet1/1 + 0 + 3672234582 + 2957211983 + 717527578 + 1569907802791 + + 11547146575 + 0 + 0 + 3672234582 + 0 + 1569907802791 + 0 + 14379659738635 + + + + + + False + False + 0 + layer3 + 0 + False + N/A + 16 + False + ethernet1/1 + + + ethernet1/1 + full + 0 + auto + 00:50:56:11:22:33 + up + auto + layer3 + auto + 10000 + 16 + False + + dp0 + + \ No newline at end of file diff --git a/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json b/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json index 63dca99..dc53112 100644 --- a/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json @@ -34,11 +34,19 @@ "ethernet1/1": { "is_enabled": true, "is_up": true, - "mac_address": "BA:DB:EE:FB:AD:10", + "mac_address": "00:50:56:11:22:33", "speed": 1000, "description": "N/A", "last_flapped": -1.0 }, + "tunnel": { + "is_enabled": true, + "is_up": true, + "mac_address": "E4:A7:49:AA:BB:CC", + "speed": 0, + "description": "N/A", + "last_flapped": -1.0 + }, "loopback.100": { "is_enabled": true, "last_flapped": -1.0, @@ -46,5 +54,22 @@ "speed": 0, "description": "N/A", "is_up": true + }, + "tunnel.100": { + "is_enabled": true, + "last_flapped": -1.0, + "mac_address": "", + "speed": 0, + "description": "N/A", + "is_up": true + }, + "ethernet1/1.143": { + "is_enabled": true, + "last_flapped": -1.0, + "mac_address": "", + "speed": 0, + "description": "N/A", + "is_up": true + } } \ No newline at end of file