Fix a crash when missing rack id #172

Merged
cyrinux merged 6 commits from fix_a_crash into master 2021-07-20 21:55:47 +02:00
cyrinux commented 2020-10-20 16:27:02 +02:00 (Migrated from github.com)

In some case, i miss id and this make crash the agent, i'm not sure its the ideal solution but this first the crash and I can register my device.

    Traceback (most recent call last):
      File "/usr/bin/netbox_agent", line 33, in <module>
        sys.exit(load_entry_point('netbox-agent==0.6.2', 'console_scripts', 'netbox_agent')())
      File "/opt/venvs/netbox-agent/lib/python3.6/site-packages/netbox_agent/cli.py", line 44, in main
        return run(config)
      File "/opt/venvs/netbox-agent/lib/python3.6/site-packages/netbox_agent/cli.py", line 39, in run
        server.netbox_create_or_update(config)
      File "/opt/venvs/netbox-agent/lib/python3.6/site-packages/netbox_agent/server.py", line 391, in netbox_create_or_update
        ret, server = self.update_netbox_location(server)
      File "/opt/venvs/netbox-agent/lib/python3.6/site-packages/netbox_agent/server.py", line 82, in update_netbox_location
        if rack and server.rack and server.rack.id != nb_rack.id:
    AttributeError: 'NoneType' object has no attribute 'id'
In some case, i miss id and this make crash the agent, i'm not sure its the ideal solution but this first the crash and I can register my device. ``` Traceback (most recent call last): File "/usr/bin/netbox_agent", line 33, in <module> sys.exit(load_entry_point('netbox-agent==0.6.2', 'console_scripts', 'netbox_agent')()) File "/opt/venvs/netbox-agent/lib/python3.6/site-packages/netbox_agent/cli.py", line 44, in main return run(config) File "/opt/venvs/netbox-agent/lib/python3.6/site-packages/netbox_agent/cli.py", line 39, in run server.netbox_create_or_update(config) File "/opt/venvs/netbox-agent/lib/python3.6/site-packages/netbox_agent/server.py", line 391, in netbox_create_or_update ret, server = self.update_netbox_location(server) File "/opt/venvs/netbox-agent/lib/python3.6/site-packages/netbox_agent/server.py", line 82, in update_netbox_location if rack and server.rack and server.rack.id != nb_rack.id: AttributeError: 'NoneType' object has no attribute 'id' ```
cyrinux commented 2021-06-16 14:14:15 +02:00 (Migrated from github.com)

Hi @Solvik, I realize i still need this patch to be merged. Can you check it please?

Hi @Solvik, I realize i still need this patch to be merged. Can you check it please?
ramnes (Migrated from github.com) reviewed 2021-07-09 11:05:04 +02:00
@ -79,7 +78,11 @@ class ServerBase():
update = True
ramnes (Migrated from github.com) commented 2021-07-09 11:05:04 +02:00

Seems overly complicated, why not just something like this?

            and server.rack
            and nb_rack
Seems overly complicated, why not just something like this? ```suggestion and server.rack and nb_rack ```
cyrinux commented 2021-07-09 11:22:45 +02:00 (Migrated from github.com)

Sure ... :-)

Sure ... :-)
ramnes commented 2021-07-09 11:33:29 +02:00 (Migrated from github.com)

We can probably remove the rack check as well. Needs a rebase on master anyway. :)

We can probably remove the `rack` check as well. Needs a rebase on master anyway. :)
cyrinux commented 2021-07-09 12:13:58 +02:00 (Migrated from github.com)

We can probably remove the rack check as well. Needs a rebase on master anyway. :)

I just rebase. Are you sure about this 🤔

> We can probably remove the `rack` check as well. Needs a rebase on master anyway. :) I just rebase. Are you sure about this 🤔
cyrinux commented 2021-07-16 09:11:09 +02:00 (Migrated from github.com)

Hi @ramnes @Solvik I make some tests, this should be ok like this, could you confirm and merge please?
Regards

Hi @ramnes @Solvik I make some tests, this should be ok like this, could you confirm and merge please? Regards
ramnes commented 2021-07-20 21:55:59 +02:00 (Migrated from github.com)

Thanks!

Thanks!
Sign in to join this conversation.
No description provided.