From 510d8c73213e715f109cc8ec4eb5eea0f97cd3df Mon Sep 17 00:00:00 2001 From: Gregor Michels Date: Thu, 3 Jul 2025 18:10:17 +0200 Subject: [PATCH] dicitfy read_ commands --- main.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/main.py b/main.py index 5e3f7ad..61e7ac1 100755 --- a/main.py +++ b/main.py @@ -312,28 +312,41 @@ def update_port_vlan(host: str, cookie: str, port: str): def read_ports(host: str, xssid: str) -> dict: - return extract_data_from_table(get_cmd(host, xssid, API_CMD_IDS.READ_PORTS.value)) + return dictify( + extract_data_from_table(get_cmd(host, xssid, API_CMD_IDS.READ_PORTS.value)), + "Port", + ) def read_vlans(host: str, xssid: str) -> dict: - return extract_data_from_table(get_cmd(host, xssid, API_CMD_IDS.READ_VLANS.value)) + return dictify( + extract_data_from_table(get_cmd(host, xssid, API_CMD_IDS.READ_VLANS.value)), + "VLAN ID", + ) def read_vlan_ports(host: str, xssid: str) -> dict: - return extract_data_from_table( - get_cmd(host, xssid, API_CMD_IDS.READ_VLAN_PORTS.value) + return dictify( + extract_data_from_table( + get_cmd(host, xssid, API_CMD_IDS.READ_VLAN_PORTS.value) + ), + "Port", ) def read_stp_ports(host: str, xssid: str) -> dict: - return extract_data_from_table( - get_cmd(host, xssid, API_CMD_IDS.READ_STP_PORTS.value) + return dictify( + extract_data_from_table(get_cmd(host, xssid, API_CMD_IDS.READ_STP_PORTS.value)), + "Port", ) def read_vlan_port_cfg(host: str, xssid: str, vid: int) -> dict: - return parse_vlan_ports( - get_cmd(host, xssid, API_CMD_IDS.READ_VLAN_PORT_CFG.value, vid=vid) + return dictify( + parse_vlan_ports( + get_cmd(host, xssid, API_CMD_IDS.READ_VLAN_PORT_CFG.value, vid=vid) + ), + "VLAN", ) @@ -341,10 +354,4 @@ if __name__ == "__main__": IP = "192.168.42.100" cookie = get_login_cookie(IP, "admin", os.environ.get("ADMIN_PW")) - # print(delete_vlan(IP, cookie, 423)) - # print(delete_vlan(IP, cookie, 111)) - # print(delete_vlan(IP, cookie, 666)) - # - # print(update_vlan_name(IP, cookie, 2009, "customer_2009")) - - print(read_vlan_port_cfg(IP, cookie, 2)) + print(read_stp_ports(IP, cookie))