Skip to content

Commit

Permalink
Standardized FIB entries key generation
Browse files Browse the repository at this point in the history
  • Loading branch information
acelebanski committed Feb 8, 2024
1 parent 706e033 commit 8bd6273
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
16 changes: 13 additions & 3 deletions docs/panos-upgrade-assurance/api/firewall_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ Get route table entries, either retrieved from DHCP or configured manually.

The actual API command is `show routing route`.

In the returned `dict` the key is made of three route properties delimited with an underscore (`_`) in the following
In the returned `dict` the key is made of four route properties delimited with an underscore (`_`) in the following
order:

* virtual router name,
Expand Down Expand Up @@ -1230,22 +1230,32 @@ Get the information from the forwarding information table (FIB).

The actual API command run is `show routing fib`.

In the returned `dict` the key is made of three route properties delimited with an underscore (`_`) in the following
order:

* destination CIDR,
* network interface name,
* next-hop address or name.

The key does not provide any meaningful information, it's there only to introduce uniqueness for each entry. All
properties that make a key are also available in the value of a dictionary element.

__Returns__


`dict`: Status of the route entries in the FIB

```python showLineNumbers title="Sample output"
{
'0.0.0.0/0_ethernet1/1': {
'0.0.0.0/0_ethernet1/1_10.10.11.1': {
'Destination': '0.0.0.0/0',
'Interface': 'ethernet1/1',
'Next Hop Type': '0',
'Flags': 'ug',
'Next Hop': '10.10.11.1',
'MTU': '1500'
},
'1.1.1.1/32_loopback.10': {
'1.1.1.1/32_loopback.10_0.0.0.0': {
'Destination': '1.1.1.1/32',
'Interface': 'loopback.10',
'Next Hop Type': '3',
Expand Down
1 change: 1 addition & 0 deletions examples/readiness_checks/run_readiness_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
# 'all',
"nics",
"routes",
"fib_routes",
"license",
"arp_table",
"content_version",
Expand Down
18 changes: 14 additions & 4 deletions panos_upgrade_assurance/firewall_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def get_routes(self) -> dict:
The actual API command is `show routing route`.
In the returned `dict` the key is made of three route properties delimited with an underscore (`_`) in the following
In the returned `dict` the key is made of four route properties delimited with an underscore (`_`) in the following
order:
* virtual router name,
Expand Down Expand Up @@ -1415,21 +1415,31 @@ def get_fib(self) -> dict:
The actual API command run is `show routing fib`.
In the returned `dict` the key is made of three route properties delimited with an underscore (`_`) in the following
order:
* destination CIDR,
* network interface name,
* next-hop address or name.
The key does not provide any meaningful information, it's there only to introduce uniqueness for each entry. All
properties that make a key are also available in the value of a dictionary element.
# Returns
dict: Status of the route entries in the FIB
```python showLineNumbers title="Sample output"
{
'0.0.0.0/0_ethernet1/1': {
'0.0.0.0/0_ethernet1/1_10.10.11.1': {
'Destination': '0.0.0.0/0',
'Interface': 'ethernet1/1',
'Next Hop Type': '0',
'Flags': 'ug',
'Next Hop': '10.10.11.1',
'MTU': '1500'
},
'1.1.1.1/32_loopback.10': {
'1.1.1.1/32_loopback.10_0.0.0.0': {
'Destination': '1.1.1.1/32',
'Interface': 'loopback.10',
'Next Hop Type': '3',
Expand All @@ -1455,7 +1465,7 @@ def get_fib(self) -> dict:

for entry in entries if isinstance(entries, list) else [entries]:
if isinstance(entry, dict):
key = f'{entry["dst"]}_{entry["interface"]}'
key = f'{entry["dst"]}_{entry["interface"]}_{entry["nexthop"]}'
result_entry = {
"Destination": entry.get("dst"),
"Interface": entry.get("interface"),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_firewall_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,15 +1821,15 @@ def test_get_fib_routes(self, fw_proxy_mock):
fw_proxy_mock.op.return_value = raw_response

assert fw_proxy_mock.get_fib() == {
"0.0.0.0/0_ethernet1/1": {
"0.0.0.0/0_ethernet1/1_10.10.11.1": {
"Destination": "0.0.0.0/0",
"Interface": "ethernet1/1",
"Next Hop Type": "0",
"Flags": "ug",
"Next Hop": "10.10.11.1",
"MTU": "1500",
},
"1.1.1.1/32_loopback.10": {
"1.1.1.1/32_loopback.10_1.2.3.4": {
"Destination": "1.1.1.1/32",
"Interface": "loopback.10",
"Next Hop Type": "3",
Expand Down

0 comments on commit 8bd6273

Please sign in to comment.