Skip to content

Commit

Permalink
Linux genie support (#3217)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Pecarina <7978152+mpecarina@users.noreply.github.com>
  • Loading branch information
ktbyers and mpecarina authored May 19, 2023
1 parent d8ef21d commit e07b787
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion netmiko/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def get_structured_data_genie(
)
raise ValueError(msg)

if "cisco" not in platform:
if "cisco" not in platform and "linux" not in platform:
return raw_output

genie_device_mapper = {
Expand All @@ -508,6 +508,9 @@ def get_structured_data_genie(
"cisco_xr": "iosxr",
"cisco_nxos": "nxos",
"cisco_asa": "asa",
"linux": "linux",
"f5_linux": "linux",
"ovs_linux": "linux",
}

os = None
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,20 @@ def test_get_structured_data_genie():
)
assert result["version"]["chassis"] == "WS-C3560CX-8PC-S"

netstat_output = """
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 172.16.0.1 0.0.0.0 UG 0 0 0 eth0
169.254.169.254 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
172.16.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
"""
netstat_output = netstat_output.strip()
routes = utilities.get_structured_data_genie(
netstat_output, platform="linux", command="netstat -rn"
)
nexthop_gw = routes["routes"]["0.0.0.0"]["mask"]["0.0.0.0"]["nexthop"][1]["gateway"]
assert nexthop_gw == "172.16.0.1"


@pytest.mark.parametrize(
"max_loops,delay_factor,timeout,result",
Expand Down

0 comments on commit e07b787

Please sign in to comment.