fix(cli): the trunk gets its own row, as over REST
Since f35b59e a CLI poll reports trunk members as `3` with
trunk_group `Trk3`, but `show interfaces brief` has no line for Trk3
itself, so the trunk was missing from the interface list. The REST path
built that row on its own.
Both paths now use napalm_device_types.add_lag_interfaces, and the REST
path's copy is gone. One visible change there: `lag_members` is now in
port order (7, 10) instead of API order; the description already was.
The CLI path does not know the mode yet, so its trunks carry no
lag_mode. That needs `show trunks`, whose output is not at hand.
Needs napalm-device-types f3fa75b.
Closes #5
This commit is contained in:
@@ -884,3 +884,58 @@ class TestApiSetInterfaceExistingMembership:
|
||||
drv.set_interface("10", {"mode": "trunk", "trunk_vlans": [10]})
|
||||
assert "boom" in str(exc.value)
|
||||
api.put.assert_not_called()
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# LAG rows (#5)
|
||||
# ===========================================================================
|
||||
|
||||
|
||||
class TestApiGetInterfacesLag:
|
||||
"""The REST path's trunk rows, kept as they were when it moved to add_lag_interfaces."""
|
||||
|
||||
def _client(self, ports):
|
||||
from napalm_procurve.api_client import ProcurveApiClient
|
||||
|
||||
client = ProcurveApiClient(hostname="192.168.0.1", username="manager", password="secret")
|
||||
responses = {
|
||||
"ports": {"port_element": ports},
|
||||
"port-statistics": {"port_statistics_element": [
|
||||
{"id": p["id"], "port_speed_mbps": 1000} for p in ports
|
||||
]},
|
||||
"system/status/switch": {},
|
||||
}
|
||||
client.get = MagicMock(side_effect=lambda endpoint, **kw: responses[endpoint])
|
||||
return client
|
||||
|
||||
def test_trunk_rows_with_mode(self):
|
||||
client = self._client([
|
||||
{"id": "1", "is_port_up": True, "is_port_enabled": True, "trunk_group": ""},
|
||||
{"id": "3", "is_port_up": False, "is_port_enabled": True, "trunk_group": "trk3", "trunk_mode": "PTT_LACP"},
|
||||
{"id": "4", "is_port_up": True, "is_port_enabled": True, "trunk_group": "trk3", "trunk_mode": "PTT_LACP"},
|
||||
{"id": "10", "is_port_up": False, "is_port_enabled": True, "trunk_group": "trk6"},
|
||||
{"id": "7", "is_port_up": False, "is_port_enabled": True, "trunk_group": "trk6"},
|
||||
])
|
||||
ifaces = client.get_interfaces()
|
||||
|
||||
assert ifaces["trk3"]["lag_members"] == ["3", "4"]
|
||||
assert ifaces["trk3"]["lag_mode"] == "lacp"
|
||||
assert ifaces["trk3"]["is_up"] is True
|
||||
assert ifaces["trk3"]["speed"] == 2000.0
|
||||
assert ifaces["trk6"]["lag_members"] == ["7", "10"]
|
||||
assert ifaces["trk6"]["lag_mode"] == "trunk"
|
||||
assert ifaces["trk6"]["description"] == "LAG (7, 10)"
|
||||
assert ifaces["3"]["trunk_group"] == "trk3"
|
||||
|
||||
|
||||
class TestCliGetInterfacesLag:
|
||||
def test_trunk_rows_from_member_ports(self, driver):
|
||||
driver._send_command = MagicMock(
|
||||
side_effect=lambda cmd: SHOW_INTERFACES_BRIEF_INTRUSION if cmd == "show interfaces brief" else ""
|
||||
)
|
||||
ifaces = driver.get_interfaces()
|
||||
|
||||
assert ifaces["Trk3"]["lag_members"] == ["3", "4"]
|
||||
assert ifaces["Trk6"]["lag_members"] == ["6", "7"]
|
||||
assert ifaces["Trk6"]["is_up"] is True
|
||||
assert ifaces["Trk6"]["is_enabled"] is True
|
||||
|
||||
Reference in New Issue
Block a user