Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omada / OMDSDN - Fails due to KeyError: 'null' #997

Open
3 of 7 tasks
xfilo opened this issue Feb 17, 2025 · 21 comments
Open
3 of 7 tasks

Omada / OMDSDN - Fails due to KeyError: 'null' #997

xfilo opened this issue Feb 17, 2025 · 21 comments
Labels
bug 🐛 Something isn't working next release/in dev image🚀 This is coming in the next release or was already released if the issue is Closed. Waiting for reply⏳ Waiting for the original poster to respond, or discussion in progress.

Comments

@xfilo
Copy link
Contributor

xfilo commented Feb 17, 2025

Is there an existing issue for this?

The issue occurs in the following browsers. Select at least 2.

  • Firefox
  • Chrome
  • Edge
  • Safari (unsupported) - PRs welcome
  • N/A - This is an issue with the backend

Current Behavior

I enabled the OMDSDN plugin, configured it, ran it manually and it fails on this error:

Traceback (most recent call last):
  File "/app/front/plugins/omada_sdn_imp/omada_sdn.py", line 660, in <module>
    main()
  File "/app/front/plugins/omada_sdn_imp/omada_sdn.py", line 284, in main
    device_data = get_device_data(clients_list, switches_and_aps, device_handler)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/front/plugins/omada_sdn_imp/omada_sdn.py", line 649, in get_device_data
    add_uplink(
  File "/app/front/plugins/omada_sdn_imp/omada_sdn.py", line 198, in add_uplink
    if device_data_bymac[switch_mac][SWITCH_AP] == "null":
       ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'null'

Expected Behavior

I actually don't know, what is the exact expected behaviour, but I made a temporary fix like this - basically placed the whole function in a try-catch:

def add_uplink(
    uplink_mac,
    switch_mac,
    device_data_bymac,
    sadevices_linksbymac,
    port_byswitchmac_byclientmac,
):
    try:
        # mylog(OMDLOGLEVEL, [f'[{pluginName}] trying to add uplink="{uplink_mac}" to switch="{switch_mac}"'])
        # mylog(OMDLOGLEVEL, [f'[{pluginName}] before adding:"{device_data_bymac[switch_mac]}"'])
        if device_data_bymac[switch_mac][SWITCH_AP] == "null":
            device_data_bymac[switch_mac][SWITCH_AP] = uplink_mac
            if (
                device_data_bymac[switch_mac][TYPE] == "Switch"
                and device_data_bymac[uplink_mac][TYPE] == "Switch"
            ):
                port_to_uplink = port_byswitchmac_byclientmac[switch_mac][uplink_mac]
                # find_port_of_uplink_switch(switch_mac, uplink_mac)
            else:
                port_to_uplink = device_data_bymac[uplink_mac][PORT_SSID]
            device_data_bymac[switch_mac][PORT_SSID] = port_to_uplink
        #    mylog(OMDLOGLEVEL, [f'[{pluginName}] after adding:"{device_data_bymac[switch_mac]}"'])
        for link in sadevices_linksbymac[switch_mac]:
            if (
                device_data_bymac[link][SWITCH_AP] == "null"
                and device_data_bymac[switch_mac][TYPE] == "Switch"
            ):
                add_uplink(
                    switch_mac,
                    link,
                    device_data_bymac,
                    sadevices_linksbymac,
                    port_byswitchmac_byclientmac,
                )
    except KeyError as e:
        mylog(OMDLOGLEVEL, [f"KeyError: {str(e)} occurred while processing {switch_mac}"])
        return

Steps To Reproduce

Other than running the omada_sdn.py manually from the Settings tab, I don't know how to reproduce the issue.
Doesn't matter if it's ran manually or it scheduled, the result is the same.
Maybe it's an issue on my side, but I cannot tell.

app.conf

docker-compose.yml

What installation are you running?

Production (netalertx)

app.log

Here is the shortened log:

02:33:48 [2025-02-17 02:33:48+01:00] START Run: OMDSDN
02:33:48 [Plugins] Timeout: 30
02:33:48 [Plugin utils] Pre-Resolved CMD: python3/app/front/plugins/omada_sdn_imp/omada_sdn.py
02:33:48 [Plugins] Executing: python3 /app/front/plugins/omada_sdn_imp/omada_sdn.py
02:33:48 [Plugins] Resolved : ['python3', '/app/front/plugins/omada_sdn_imp/omada_sdn.py']
02:33:53 [plugin_helper] reading config file
02:33:48 [OMDSDN] starting execution
02:33:48 [Database] Opening DB
02:33:48 [OMDSDN] callomada:-t myomada target --url http://192.168.100.XXX:8088 --user XXX --password XXX --site XXX --set-default
02:33:49 [OMDSDN] login to omada result is: Set target myomada to controller Omada Controller_9FF42D and site XX

02:33:49 [OMDSDN] callomada:-t myomada clients
02:33:49 [OMDSDN] clients found:"18"
0C-XX-XX-XX-XX-E4 192.168.120.XXX Asus AC51-U AP       Switch SG2218 D8-XX-XX-XX-X-FE (14)
...
78-XX-XX-XX-XX-4D 192.168.110.XXX Lenovo Tab P11       Switch SG2218 D8-XX-XX-XX-X-FE (7)

02:33:49 [OMDSDN] callomada:-t myomada devices
02:33:50 [OMDSDN] omada devices (switches, access points) found:"2"
  74-XX-XX-XX-XX-8A   192.168.100.XXX gateway CONNECTED        Router ER605 74-XX-XX-XX-XX-8A ER605 v2.0
D8-XX-XX-XX-XX-FE   192.168.100.XXX  switch CONNECTED        Switch SG2218 D8-XX-XX-XX-XX-FE SG2218 v1.20

02:33:50 [OMDSDN] ffsb
02:33:50 [OMDSDN] switches_and_aps rows: "2"
02:33:52 [OMDSDN] switch=74-XX-XX-XX-XX-8A details=
02:33:52 [OMDSDN] switch=D8-XX-XX-XX-X-FE details=Name: Switch SG2218 D8-XX-XX-XX-X-FE
Address: D8-XX-XX-XX-X-FE (192.168.100.XXX)
Status: CONNECTED (CONNECTED)
Ports: 18
Supports PoE: False
Model: SG2218 v1.20
LED Setting: SITE_SETTINGS
Uptime: 6h 26m 49s
Uplink switch: 74-XX-XX-XX-XX-8A Router ER605 74-XX-XX-XX-XX-8A

02:33:52 [OMDSDN] switches details collected "2"
02:33:52 [OMDSDN] dump details collected "2"
02:33:52 [OMDSDN]adding switch: "['74-XX-XX-XX-XX-8A', '192.168.100.XXX', 'Router', 'null', 'null']"
02:33:52 [OMDSDN] switchdump:
02:33:52 [OMDSDN]adding switch: "['D8-XX-XX-XX-X-FE', '192.168.100.XXX', 'Switch', 'null', 'null']"
02:33:52 [OMDSDN] switch_macbyname: "{'Router': '74-XX-XX-XX-XX-8A', 'Switch': 'D8-XX-XX-XX-X-FE'}"
02:33:52 [OMDSDN] switches: "{'74-XX-XX-XX-XX-8A': ['74-XX-XX-XX-XX-8A', '192.168.100.XXX', 'Router', 'null', 'null', 'null'], 'D8-XX-XX-XX-X-FE': ['D8-XX-XX-XX-X-FE', '192.168.100.XXX', 'Switch', 'null', 'null', 'Switch']}"
02:33:52 [OMDSDN] omada_clients_outputs rows: "18"
02:33:52 [OMDSDN] TEST name from MAC: DESKTOP-2JHCHQU
02:33:52 [OMDSDN] could not find the mac adddress for: "SG2218"
02:33:52 [OMDSDN] tokens: "['D8-XX-XX-XX-XX-84', '192.168.100.XXX', 'DESKTOP-2JHCHQU', 'Switch', 'SG2218', 'D8-XX-XX-XX-X-FE', '(3)']"
02:33:52 [OMDSDN] tokens_reordered: "['D8-XX-XX-XX-XX-84', '192.168.100.XXX', 'DESKTOP-2JHCHQU', 'SG2218', 'Switch', 'null']"
...
02:33:52 [OMDSDN] TEST name from MAC: Lenovo
02:33:52 [OMDSDN] could not find the mac adddress for: "P11"
02:33:52 [OMDSDN] tokens: "['78-XX-XX-XX-XX-4D', '192.168.110.XXX', 'Lenovo', 'Tab', 'P11', 'Switch', 'SG2218', 'D8-XX-XX-XX-X-FE', '(7)']"
02:33:52 [OMDSDN] tokens_reordered: "['78-XX-XX-XX-XX-4D', '192.168.110.XXX', 'Lenovo', 'P11', 'Tab', 'null']"
02:33:52 [OMDSDN] results are: "[]"
02:33:52 [DEBUG] Default Gateway IP: 192.168.100.XXX
Traceback (most recent call last):
  File "/app/front/plugins/omada_sdn_imp/omada_sdn.py", line 662, in <module>
    main()
  File "/app/front/plugins/omada_sdn_imp/omada_sdn.py", line 286, in main
    device_data = get_device_data(clients_list, switches_and_aps, device_handler)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/front/plugins/omada_sdn_imp/omada_sdn.py", line 651, in get_device_data
    add_uplink(
  File "/app/front/plugins/omada_sdn_imp/omada_sdn.py", line 201, in add_uplink
    if device_data_bymac[switch_mac][SWITCH_AP] == "null":
       ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'null'

02:33:53 [2025-02-17 02:33:53+01:00] END Run: OMDSDN

Debug enabled

  • I have read and followed the steps in the wiki link above and provided the required debug logs and the log section covers the time when the issue occurs.
@xfilo xfilo added the bug 🐛 Something isn't working label Feb 17, 2025
jokob-sk pushed a commit that referenced this issue Feb 17, 2025
@jokob-sk
Copy link
Owner

This should be fixed in the -dev image. It would be great if you could test this. Can you please switch to the netalertx-dev docker image (backup everything at first or, ideally spin up a separate container with a separate db and config), in about 15 minutes (or after the last action finishes) from now?

Thanks in advance,
j

@jokob-sk jokob-sk added next release/in dev image🚀 This is coming in the next release or was already released if the issue is Closed. Waiting for reply⏳ Waiting for the original poster to respond, or discussion in progress. labels Feb 17, 2025
@jokob-sk
Copy link
Owner

@FlyingToto would be helpful if you could test as well if this doesn't break something. 🙏

@xfilo
Copy link
Contributor Author

xfilo commented Feb 17, 2025

Hey @jokob-sk, thanks for the quick response! I tested the netalertx-dev image using the same configuration, and it works for me. Do you have an estimate on when the fix will be available in the official image? No rush, just asking out of curiosity. Thanks.

@FlyingToto
Copy link
Contributor

wow! you guys are way too fast for me! :-)
I suspect that the issue might come from the fact that the plugin was not designed to accommodate tplinks routers.
(Originally, I didn't have one, then I bought super cheap one to test on ebay but with US dept warning about tplink's inherent backdoor I reflashed it with openwrt which makes it a good router but lost compatibility with omada... )

going back to the question, surrounding the section with a catch will avoid the error but you won't be able to any data from the plugin...

I am thinking that 2 other options which might be to instruct the plugin to ignore parsing the routers for now:

  1. in the section where "callomada -t myomada devices" try to remove the rows with "gateway" or "Router"
02:33:49 [OMDSDN] callomada:-t myomada devices
02:33:50 [OMDSDN] omada devices (switches, access points) found:"2"
  74-XX-XX-XX-XX-8A   192.168.100.XXX gateway CONNECTED        Router ER605 74-XX-XX-XX-XX-8A ER605 v2.0
D8-XX-XX-XX-XX-FE   192.168.100.XXX  switch CONNECTED        Switch SG2218 D8-XX-XX-XX-XX-FE SG2218 v1.20

This should also avoid another limitation of netalertX which is that it doesn't support routers specifically and represent them like switches. Theoretically, by parsing the switch configuration alone, it will still detect the router and report it like any other devices and even insert it between the ISP link and the switch properly.

  1. in the same section, substitue the type "router" with "Switch". since most tplinks routers include also several ports for the LAN, it should be able to process it like a standard tplink switch...

@xfilo
Copy link
Contributor Author

xfilo commented Feb 17, 2025

In the first option, what do you mean by "try to remove the rows with gateway or router" ?
I'm not sure where or how I'm supposed to remove them - same for the second option. Could you please clarify?

@FlyingToto
Copy link
Contributor

for option (2) I would suggest to try the following:
(be careful to preserve the space alignement... )
note: this is just for testing purposes... if it works we need to make it a bit resilient by limiting the replacement to specific fields only to avoid replacing people's devices names if they called their router "router" but then... that would be such a lack of imagination...

replace:

switches_and_aps = callomada(["-t", "myomada", "devices"])
    mylog(
        "verbose",
        [
            f'[{pluginName}] omada devices (switches, access points) found:"{switches_and_aps.count("\n")}" \n  {switches_and_aps}'
        ],
    )

with:

switches_and_aps = callomada(["-t", "myomada", "devices"])
    mylog(
        "verbose",
        [
            f'[{pluginName}] omada devices (switches, access points) found:"{switches_and_aps.count("\n")}" \n  {switches_and_aps}'
        ],
    )
    #### trying to fake tplink routers as plain switches ####
    switches_and_aps = re.sub(r'Router', 'Switch', switches_and_aps)
    switches_and_aps = re.sub(r'gateway', 'switch', switches_and_aps)
    mylog(
        "verbose",
        [
            f'[{pluginName}] omada devices (switches, access points) found and swapped routers as switches"{switches_and_aps.count("\n")}" \n  {switches_and_aps}'
        ],
    )

@xfilo
Copy link
Contributor Author

xfilo commented Feb 17, 2025

I modified the omada_sdn.py file to include the script you provided (above). However, I wasn’t sure which image to use, so I tested both.

  • With the netalertx image and your modification, running omada_sdn.py failed with the same error that led to the creation of this issue.
  • With the netalertx-dev image and your modification, omada_sdn.py ran successfully, but I didn’t notice any difference compared to running netalertx-dev without modifying omada_sdn.py.

@FlyingToto
Copy link
Contributor

@xfilo, you can double check that your code has been modified in the logs, when the plugin runs you should see a second entry that should look like this:
(where the router show as a switch)

from:

02:33:49 [OMDSDN] callomada:-t myomada devices
02:33:50 [OMDSDN] omada devices (switches, access points) found:"2"
  74-XX-XX-XX-XX-8A   192.168.100.XXX gateway CONNECTED        Router ER605 74-XX-XX-XX-XX-8A ER605 v2.0
D8-XX-XX-XX-XX-FE   192.168.100.XXX  switch CONNECTED        Switch SG2218 D8-XX-XX-XX-XX-FE SG2218 v1.20

to:

02:33:49 [OMDSDN] callomada:-t myomada devices
02:33:50 [OMDSDN] omada devices (switches, access points) found:"2"
  74-XX-XX-XX-XX-8A   192.168.100.XXX gateway CONNECTED        Router ER605 74-XX-XX-XX-XX-8A ER605 v2.0
D8-XX-XX-XX-XX-FE   192.168.100.XXX  switch CONNECTED        Switch SG2218 D8-XX-XX-XX-XX-FE SG2218 v1.20
02:33:50 [OMDSDN] omada devices (switches, access points) found **and swapped routers as switches**:"2"
  74-XX-XX-XX-XX-8A   192.168.100.XXX **switch** CONNECTED        **Switch** ER605 74-XX-XX-XX-XX-8A ER605 v2.0
D8-XX-XX-XX-XX-FE   192.168.100.XXX  switch CONNECTED        Switch SG2218 D8-XX-XX-XX-XX-FE SG2218 v1.20

@xfilo
Copy link
Contributor Author

xfilo commented Feb 18, 2025

Hey @FlyingToto, correct, there is a second entry in the log. However, my previous statement still holds—using the official image, the execution fails, while with the dev image, it runs successfully, but there is no actual difference except for the log output.

@FlyingToto
Copy link
Contributor

but it replaced "router" with "switch" correct?

try this...

  • Assuming your ER605 is configured with 1 port going to the ISP WAN, 1 port going to your SG2218, nothing connected to the other LAN ports.
  • add a laptop (or something) to one of the other unused LAN ports of the router ER605
  • with option 2, you should see the ER605 with 3 connections (WAN, SG2218, laptop), and all the devices connected to your sg2218

@xfilo
Copy link
Contributor Author

xfilo commented Feb 18, 2025

Yes, router was replaced with switch.

I connected my computer (DESKTOP-2JHCHQU in the logs) directly to the ER605 router, modified the .py script with the code you provided, and used the netalertx-dev image. Below are the results.

I’ve highlighted some key pieces (my opinion) in the log below with ⬇️⬆️.

18:09:48 [2025-02-18 18:09:48+01:00] START Run: OMDSDN
18:09:48 [Plugins] Executing: python3 /app/front/plugins/omada_sdn_imp/omada_sdn.py
18:09:53 [Plugins] Output: [plugin_helper] reading config file
18:09:49 [OMDSDN] starting execution
18:09:49 [Database] Opening DB
18:09:49 [OMDSDN] callomada:-t myomada target --url http://192.168.100.XXX:8088 --user XXX --password XXX --site XXX --set-default
18:09:49 [OMDSDN] login to omada result is: Set target myomada to controller Omada Controller_9FF42D and site XX

18:09:49 [OMDSDN] callomada:-t myomada clients
18:09:50 [OMDSDN] clients found:"18"
⬇️
D8-XX-XX-XX-XX-84 192.168.100.XXX DESKTOP-2JHCHQU      Router ER605 74-XX-XX-XX-XX-8A
⬆️
...
78-XX-XX-XX-XX-4D 192.168.110.XXX Lenovo_Tab_P11       Switch SG2218 D8-XX-XX-XX-XX-FE (7)

18:09:50 [OMDSDN] callomada:-t myomada devices
18:09:51 [OMDSDN] omada devices (switches, access points) found:"2"
  74-XX-XX-XX-XX-8A   192.168.100.XXX gateway CONNECTED        Router ER605 74-XX-XX-XX-XX-8A ER605 v2.0
D8-XX-XX-XX-XX-FE   192.168.100.XXX  switch CONNECTED        Switch SG2218 D8-XX-XX-XX-XX-FE SG2218 v1.20

18:09:51 [OMDSDN] omada devices (switches, access points) found and swapped routers as switches"2"
  74-XX-XX-XX-XX-8A   192.168.100.XXX switch CONNECTED        Switch ER605 74-XX-XX-XX-XX-8A ER605 v2.0
D8-XX-XX-XX-XX-FE   192.168.100.XXX  switch CONNECTED        Switch SG2218 D8-XX-XX-XX-XX-FE SG2218 v1.20

18:09:51 [OMDSDN] ffsb
18:09:51 [OMDSDN] switches_and_aps rows: "2"
18:09:52 [OMDSDN] switch=74-XX-XX-XX-XX-8A details=
18:09:52 [OMDSDN] switch=D8-XX-XX-XX-XX-FE details=Name: Switch SG2218 D8-XX-XX-XX-XX-FE
Address: D8-XX-XX-XX-XX-FE (192.168.100.XXX)
Status: CONNECTED (CONNECTED)
Ports: 18
Supports PoE: False
Model: SG2218 v1.20
LED Setting: SITE_SETTINGS
Uptime: 1day(s) 4h 32m 3s
Uplink switch: 74-XX-XX-XX-XX-8A Router ER605 74-XX-XX-XX-XX-8A

18:09:52 [OMDSDN] switches details collected "2"
18:09:52 [OMDSDN] dump details collected "2"
⬇️
18:09:52 [OMDSDN] switchdump: Name: Router ER605 74-XX-XX-XX-XX-8A
Address: 74-XX-XX-XX-XX-8A (192.168.100.XXX)
Status: DISCONNECTED (DISCONNECTED)
LAN Ports: 0
Model: ER605 v2.0
LED Setting: SITE_SETTINGS
Uptime: None
⬆️

18:09:52 [OMDSDN]adding switch: "['74-XX-XX-XX-XX-8A', '192.168.100.XXX', 'Switch', 'null', 'null']"
18:09:52 [OMDSDN] switchdump:
18:09:52 [OMDSDN]adding switch: "['D8-XX-XX-XX-XX-FE', '192.168.100.XXX', 'Switch', 'null', 'null']"
18:09:52 [OMDSDN] switch_macbyname: "{'Switch': 'D8-XX-XX-XX-XX-FE'}"
18:09:52 [OMDSDN] switches: "{'74-XX-XX-XX-XX-8A': ['74-XX-XX-XX-XX-8A', '192.168.100.XXX', 'Switch', 'null', 'null', 'Switch'], 'D8-XX-XX-XX-XX-FE': ['D8-XX-XX-XX-XX-FE', '192.168.100.XXX', 'Switch', 'null', 'null', 'Switch']}"
18:09:52 [OMDSDN] omada_clients_outputs rows: "18"
⬇️
18:09:52 [OMDSDN] TEST name from MAC: DESKTOP-2JHCHQU
18:09:52 [OMDSDN] could not find the mac adddress for: "ER605"
18:09:52 [OMDSDN] tokens: "['D8-XX-XX-XX-XX-84', '192.168.100.XXX', 'DESKTOP-2JHCHQU', 'Router', 'ER605', '74-XX-XX-XX-XX-8A']"
18:09:52 [OMDSDN] tokens_reordered: "['D8-XX-XX-XX-XX-84', '192.168.100.100', 'DESKTOP-2JHCHQU', 'ER605', 'Router', 'null']"
⬆️
...
18:09:52 [OMDSDN] TEST name from MAC: Lenovo_Tab_P11
18:09:52 [OMDSDN] could not find the mac adddress for: "SG2218"
18:09:52 [OMDSDN] tokens: "['78-XX-XX-XX-XX-4D', '192.168.110.107', 'Lenovo_Tab_P11', 'Switch', 'SG2218', 'D8-XX-XX-XX-XX-FE', '(7)']"
18:09:52 [OMDSDN] tokens_reordered: "['78-XX-XX-XX-XX-4D', '192.168.110.107', 'Lenovo_Tab_P11', 'SG2218', 'Switch', 'null']"
18:09:52 [OMDSDN] results are: "[]"
18:09:53 [DEBUG] Default Gateway IP: 192.168.100.XXX
18:09:53 [OMDSDN] switch_mac 'null' not found in device_data_bymac
18:09:53 [OMDSDN] New entries to create: "20"
18:09:53 [OMDSDN] main parsing device: "['74-XX-XX-XX-XX-8A', '192.168.100.XXX', 'Switch', 'Internet', 'null', 'Firewall']"
18:09:53 [OMDSDN] New entries: "74:xx:xx:xx:xx:8a , 192.168.100.XXX   , Switch                                                         , Internet          ,     , null                            , Firewall"
18:09:53 [OMDSDN] main parsing device: "['D8-XX-XX-XX-XX-FE', '192.168.100.XXX', 'Switch', 'null', 'null', 'Switch']"
18:09:53 [OMDSDN] New entries: "d8:xx:xx:xx:xx:fe , 192.168.100.XXX   , Switch                                                         , null              ,     , null                            , Switch"
⬇️
18:09:53 [OMDSDN] main parsing device: "['D8-XX-XX-XX-XX-84', '192.168.100.XXX', 'DESKTOP-2JHCHQU', 'ER605', 'Router', 'null']"
18:09:53 [OMDSDN] New entries: "d8:xx:xx:xx:xx:84 , 192.168.100.XXX , DESKTOP-2JHCHQU                                                , er605             ,     , Router                          , null"
⬆️
...
18:09:53 [OMDSDN] main parsing device: "['78-XX-XX-XX-XX-4D', '192.168.110.XXX', 'Lenovo_Tab_P11', 'SG2218', 'Switch', 'null']"
18:09:53 [OMDSDN] New entries: "78:xx:xx:xx:xx:4d , 192.168.110.XXX , Lenovo_Tab_P11                                                 , sg2218            ,     , Switch                          , null"
18:09:53 [OMDSDN] New entries: "20"
18:09:53 [OMDSDN] execution completed in 4.48 seconds

18:09:53 [Plugins] Processed and deleted file: /app/log/plugins/last_result.OMDSDN.log
18:09:53 [Plugins] SUCCESS, received 20 entries
18:09:53 [2025-02-18 18:09:53+01:00] END Run: OMDSDN

@jokob-sk
Copy link
Owner

Let me know if you need to build a new netalertx-dev image - happy to try to deploy your code changes.

Pinging @Leicas as well in case he has time and can help out.

@FlyingToto
Copy link
Contributor

so it looks like it is indeed treating your router as a standard switch and finding your laptop connected to it.
do you see your devices and your graph properly displayed?

@xfilo
Copy link
Contributor Author

xfilo commented Feb 18, 2025

The device list appears correct. However, if by Graph you meant the Network tab, the visualization seems off - I see two Switch-es, but no devices appear under them. Devices only show up after I manually assign them a Network Node Port. The Network Node itself is assigned automatically and appears correct. That said, this doesn't really bother me - I'm just glad the device list is correct 😄.

@FlyingToto
Copy link
Contributor

normally, the plugin should populate the network parent node and either the SSID or the port number that the device is connected to the switch automatically.
here is an example with the SSID:

Image

@xfilo
Copy link
Contributor Author

xfilo commented Feb 19, 2025

I ran the .py script again, and something went wrong. It correctly fetched the device list, but the Network Node, Network Node Port, and SSID values are incorrect. Everything is shown as connected to Internet, even though the ONT connects to the ER605 router, and all devices are either connected to the ER605 router or the SG2218 switch (which, in turn, is connected to the router).

Additionally, the SSID assignment is incorrect - these are wired connections, so no SSID should be assigned.

At this point, I have no idea what went wrong.

Device connected to the ER605 router:
Image

Device connected to the SG2218 switch:
Image

I also noticed that when two devices have the same name (in this case Switch), the network graph only displays one of them, even though both are listed. See the attached image.
Image

One more thing to mention - as seen in the images above, the Network Node Port is set to 0. If I clear this field and save the device, it reverts to 0 again. However, after doing this, when I reload the Network graph, the device appears under Internet (see image).
I'm not necessarily saying this is an issue, but if the default value is already 0, and clearing it results in 0 again, yet this action causes the device to show up in the Network graph, then something is most likely wrong.
Image

@FlyingToto
Copy link
Contributor

FlyingToto commented Feb 20, 2025

hum... that's weird... also is looks like SSID is actually the device type... almost like columns are misaligned. I can see it from the logs parsing the devices...

from checking your logs more carefully it looks like you get an extra column returned by the omada plugin

normally I would expect:

# sample omada clients input format:
#  0 MAC, 1 IP, 2 Name, 3 switch/AP, 4 port/SSID,
# 17:27:10 [<unique_prefix>] token: "['1A-2B-3C-4D-5E-6F', '192.168.0.217', '1A-2B-3C-4D-5E-6F', 'myssid_name2', '(office_Access_point)']"
# 17:27:10 [<unique_prefix>] token: "['1A-2B-3C-4D-5E-01', '192.168.0.153', 'frontyard_ESP_29E753', 'pantry12', '(48)']"
# 17:27:10 [<unique_prefix>] token: "['1A-2B-3C-4D-5E-02', '192.168.0.1', 'bastion', 'office24', '(23)']"
# 17:27:10 [<unique_prefix>] token: "['1A-2B-3C-4D-5E-03', '192.168.0.226', 'brick', 'myssid_name3', '(office_Access_point)']"

but it looks like you get an extra field thingy...
18:09:52 [OMDSDN] TEST name from MAC: DESKTOP-2JHCHQU
18:09:52 [OMDSDN] could not find the mac adddress for: "ER605"
18:09:52 [OMDSDN] tokens: "['D8-XX-XX-XX-XX-84', '192.168.100.XXX', 'DESKTOP-2JHCHQU', 'Router', 'ER605', '74-XX-XX-XX-XX-8A']"
18:09:52 [OMDSDN] tokens_reordered: "['D8-XX-XX-XX-XX-84', '192.168.100.100', 'DESKTOP-2JHCHQU', 'ER605', 'Router', 'null']"
⬆️
...
18:09:52 [OMDSDN] TEST name from MAC: Lenovo_Tab_P11
18:09:52 [OMDSDN] could not find the mac adddress for: "SG2218"
18:09:52 [OMDSDN] tokens: "['78-XX-XX-XX-XX-4D', '192.168.110.107', 'Lenovo_Tab_P11', 'Switch', 'SG2218', 'D8-XX-XX-XX-XX-FE', '(7)']"
18:09:52 [OMDSDN] tokens_reordered: "['78-XX-XX-XX-XX-4D', '192.168.110.107', 'Lenovo_Tab_P11', 'SG2218', 'Switch', 'null']"

@xfilo
Copy link
Contributor Author

xfilo commented Feb 20, 2025

The extra column makes sense to me now, as I'm using device names with spaces, such as Switch SG2218 or Router ER605. It seems likely that the system is splitting these names by spaces, resulting in an additional column. In your example, I notice that the device names use dashes instead of spaces. I'm talking about uplink device names.

@FlyingToto
Copy link
Contributor

oh ok! now that makes more sense! I didn 't realized that omada would let you use a space in the device name!
ok ok, so can your rename a couple of devices from "Switch SG22218" to "Switch-SG22218"? let's see if that does the trick

@jokob-sk
Copy link
Owner

@xfilo created a new OMDSDNOPENAPI using OpenAPI to integrade with OMADA devices - thanks for the contribution!

@FlyingToto , @Lucide - If you still own OMADA equipment it would be great if you could test this.

You know the drill by now :)

This should be fixed in the -dev image. It would be great if you could test this. Can you please switch to the netalertx-dev docker image (backup everything at first or, ideally spin up a separate container with a separate db and config), in about 15 minutes (or after the last action finishes) from now?

@xfilo
Copy link
Contributor Author

xfilo commented Feb 24, 2025

oh ok! now that makes more sense! I didn 't realized that omada would let you use a space in the device name! ok ok, so can your rename a couple of devices from "Switch SG22218" to "Switch-SG22218"? let's see if that does the trick

Hi @FlyingToto, coming back to this - I’ve renamed all my devices to remove spaces, and while the logs look better, there’s still a 'null' column, which is different from your example.

The parent node assignment appears correct, except for Switch_SG2218, which isn’t being assigned to Switch_ER605 (gateway). I can’t recall if this worked previously or not.

To be honest, this doesn’t bother me much anymore, but it would be great to resolve the issue (if there is one) for other users.

21:26:08 [2025-02-24 21:26:08+01:00] START Run: OMDSDN
21:26:09 [OMDSDN] starting execution
21:26:09 [OMDSDN] callomada:-t myomada target --url http://192.168.100.XXX:8088 --user XXX --password XXX --site XXX --set-default
21:26:09 [OMDSDN] login to omada result is: Set target myomada to controller Omada Controller_9FF42D and site XXX

21:26:09 [OMDSDN] callomada:-t myomada clients
21:26:10 [OMDSDN] clients found:"20"
D8-XX-XX-XX-XX-84 192.168.110.XXX DESKTOP-2JHCHQU      Switch_SG2218_D8-XX-XX-XX-XX-FE (9)
F2-XX-XX-XX-XX-2D 192.168.110.XXX Watch                Switch_SG2218_D8-XX-XX-XX-XX-FE (7)
..
78-XX-XX-XX-XX-B8 192.168.110.XXX Lenovo_Tab_P11_Plus  Switch_SG2218_D8-XX-XX-XX-XX-FE (8)
78-XX-XX-XX-XX-4D 192.168.110.XXX Lenovo_Tab_P11       Switch_SG2218_D8-XX-XX-XX-XX-FE (7)

21:26:10 [OMDSDN] callomada:-t myomada devices
21:26:10 [OMDSDN] omada devices (switches, access points) found:"2" 
  74-XX-XX-XX-XX-8A   192.168.100.XXX gateway CONNECTED        Router_ER605_74-XX-XX-XX-XX-8A ER605 v2.0
D8-XX-XX-XX-XX-FE   192.168.100.XXX  switch CONNECTED        Switch_SG2218_D8-XX-XX-XX-XX-FE SG2218 v1.20

🔻
21:26:10 [OMDSDN] omada devices (switches, access points) found and swapped routers as switches"2" 
  74-XX-XX-XX-XX-8A   192.168.100.XXX switch CONNECTED        Switch_ER605_74-XX-XX-XX-XX-8A ER605 v2.0
D8-XX-XX-XX-XX-FE   192.168.100.XXX  switch CONNECTED        Switch_SG2218_D8-XX-XX-XX-XX-FE SG2218 v1.20
🔺

21:26:10 [OMDSDN] ffsb
21:26:10 [OMDSDN] switches_and_aps rows: "2"
21:26:12 [OMDSDN] switch=74-XX-XX-XX-XX-8A details=
21:26:12 [OMDSDN] switch=D8-XX-XX-XX-XX-FE details=Name: Switch_SG2218_D8-XX-XX-XX-XX-FE
Address: D8-XX-XX-XX-XX-FE (192.168.100.XXX)
Status: CONNECTED (CONNECTED)
Ports: 18
Supports PoE: False
Model: SG2218 v1.20
LED Setting: SITE_SETTINGS
Uptime: 10h 2m 29s
🔻
Uplink switch: 74-XX-XX-XX-XX-8A Router_ER605_74-XX-XX-XX-XX-8A
🔺

21:26:12 [OMDSDN] switches details collected "2"
21:26:12 [OMDSDN] dump details collected "2"
21:26:12 [OMDSDN] switchdump: Name: Router_ER605_74-XX-XX-XX-XX-8A
Address: 74-XX-XX-XX-XX-8A (192.168.100.XXX)
Status: DISCONNECTED (DISCONNECTED)
LAN Ports: 0
Model: ER605 v2.0
LED Setting: SITE_SETTINGS
Uptime: None

21:26:12 [OMDSDN]adding switch: "['74-XX-XX-XX-XX-8A', '192.168.100.XXX', 'Switch_ER605_74-XX-XX-XX-XX-8A', 'null', 'null']"
21:26:12 [OMDSDN] switchdump: 
21:26:12 [OMDSDN]adding switch: "['D8-XX-XX-XX-XX-FE', '192.168.100.XXX', 'Switch_SG2218_D8-XX-XX-XX-XX-FE', 'null', 'null']"
21:26:12 [OMDSDN] switch_macbyname: "{'Switch_ER605_74-XX-XX-XX-XX-8A': '74-XX-XX-XX-XX-8A', 'Switch_SG2218_D8-XX-XX-XX-XX-FE': 'D8-XX-XX-XX-XX-FE'}"
21:26:12 [OMDSDN] switches: "{'74-XX-XX-XX-XX-8A': ['74-XX-XX-XX-XX-8A', '192.168.100.XXX', 'Switch_ER605_74-XX-XX-XX-XX-8A', 'null', 'null', 'Switch'], 'D8-XX-XX-XX-XX-FE': ['D8-XX-XX-XX-XX-FE', '192.168.100.XXX', 'Switch_SG2218_D8-XX-XX-XX-XX-FE', 'null', 'null', 'Switch']}"
21:26:12 [OMDSDN] omada_clients_outputs rows: "20"
21:26:12 [OMDSDN] TEST name from MAC: DESKTOP-2JHCHQU
21:26:12 [OMDSDN] tokens: "['D8-XX-XX-XX-XX-84', '192.168.110.XXX', 'DESKTOP-2JHCHQU', 'Switch_SG2218_D8-XX-XX-XX-XX-FE', '(9)']"
21:26:12 [OMDSDN] tokens_reordered: "['D8-XX-XX-XX-XX-84', '192.168.110.XXX', 'DESKTOP-2JHCHQU', 'D8-XX-XX-XX-XX-FE', '9', 'null']"
21:26:12 [OMDSDN] TEST name from MAC: Watch
21:26:12 [OMDSDN] tokens: "['F2-XX-XX-XX-XX-2D', '192.168.110.XXX', 'Watch', 'Switch_SG2218_D8-XX-XX-XX-XX-FE', '(7)']"
21:26:12 [OMDSDN] tokens_reordered: "['F2-XX-XX-XX-XX-2D', '192.168.110.XXX', 'Watch', 'D8-XX-XX-XX-XX-FE', '7', 'null']"
..
21:26:12 [OMDSDN] TEST name from MAC: Lenovo_Tab_P11_Plus
21:26:12 [OMDSDN] tokens: "['78-XX-XX-XX-XX-B8', '192.168.110.XXX', 'Lenovo_Tab_P11_Plus', 'Switch_SG2218_D8-XX-XX-XX-XX-FE', '(8)']"
21:26:12 [OMDSDN] tokens_reordered: "['78-XX-XX-XX-XX-B8', '192.168.110.XXX', 'Lenovo_Tab_P11_Plus', 'D8-XX-XX-XX-XX-FE', '8', 'null']"
21:26:12 [OMDSDN] TEST name from MAC: Lenovo_Tab_P11
21:26:12 [OMDSDN] tokens: "['78-XX-XX-XX-XX-4D', '192.168.110.XXX', 'Lenovo_Tab_P11', 'Switch_SG2218_D8-XX-XX-XX-XX-FE', '(7)']"
21:26:12 [OMDSDN] tokens_reordered: "['78-XX-XX-XX-XX-4D', '192.168.110.XXX', 'Lenovo_Tab_P11', 'D8-XX-XX-XX-XX-FE', '7', 'null']"
21:26:12 [OMDSDN] results are: "[]"
21:26:13 [DEBUG] Default Gateway IP: 192.168.100.XXX
🔻
21:26:13 [OMDSDN] switch_mac 'null' not found in device_data_bymac
🔺
21:26:13 [OMDSDN] New entries to create: "22"
21:26:13 [OMDSDN] main parsing device: "['74-XX-XX-XX-XX-8A', '192.168.100.XXX', 'Switch_ER605_74-XX-XX-XX-XX-8A', 'Internet', 'null', 'Firewall']"
21:26:13 [OMDSDN] New entries: "74:xx:xx:xx:xx:8a , 192.168.100.XXX   , Switch_ER605_74-XX-XX-XX-XX-8A                                 , Internet          ,     , null                            , Firewall"
21:26:13 [OMDSDN] main parsing device: "['D8-XX-XX-XX-XX-FE', '192.168.100.XXX', 'Switch_SG2218_D8-XX-XX-XX-XX-FE', 'null', 'null', 'Switch']"
21:26:13 [OMDSDN] New entries: "d8:xx:xx:xx:xx:fe , 192.168.100.XXX   , Switch_SG2218_D8-XX-XX-XX-XX-FE                                , null              ,     , null                            , Switch"
21:26:13 [OMDSDN] main parsing device: "['D8-XX-XX-XX-XX-84', '192.168.110.XXX', 'DESKTOP-2JHCHQU', 'D8-XX-XX-XX-XX-FE', '9', 'null']"
21:26:13 [OMDSDN] New entries: "d8:xx:xx:xx:xx:84 , 192.168.110.XXX , DESKTOP-2JHCHQU                                                , d8:xx:xx:xx:xx:fe , 9   ,                                 , null"
21:26:13 [OMDSDN] main parsing device: "['F2-XX-XX-XX-XX-2D', '192.168.110.XXX', 'Watch', 'D8-XX-XX-XX-XX-FE', '7', 'null']"
21:26:13 [OMDSDN] New entries: "f2:xx:xx:xx:xx:2d , 192.168.110.XXX , Watch                                                          , d8:xx:xx:xx:xx:fe , 7   ,                                 , null"
..
21:26:13 [OMDSDN] main parsing device: "['78-XX-XX-XX-XX-B8', '192.168.110.XXX', 'Lenovo_Tab_P11_Plus', 'D8-XX-XX-XX-XX-FE', '8', 'null']"
21:26:13 [OMDSDN] New entries: "78:xx:xx:xx:xx:b8 , 192.168.110.XXX , Lenovo_Tab_P11_Plus                                            , d8:xx:xx:xx:xx:fe , 8   ,                                 , null"
21:26:13 [OMDSDN] main parsing device: "['78-XX-XX-XX-XX-4D', '192.168.110.XXX', 'Lenovo_Tab_P11', 'D8-XX-XX-XX-XX-FE', '7', 'null']"
21:26:13 [OMDSDN] New entries: "78:xx:xx:xx:xx:4d , 192.168.110.XXX , Lenovo_Tab_P11                                                 , d8:xx:xx:xx:xx:fe , 7   ,                                 , null"
21:26:13 [OMDSDN] New entries: "22"
21:26:13 [OMDSDN] execution completed in 4.39 seconds
21:26:13 [2025-02-24 21:26:13+01:00] END Run: OMDSDN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working next release/in dev image🚀 This is coming in the next release or was already released if the issue is Closed. Waiting for reply⏳ Waiting for the original poster to respond, or discussion in progress.
Projects
None yet
Development

No branches or pull requests

3 participants