netbox-community / netbox-topology-views

A netbox plugin that draws topology views
Apache License 2.0
747 stars 63 forks source link

fix AttributeError: 'CircuitTermination' object has no attribute 'device' #23

Closed mattieserver closed 1 year ago

mattieserver commented 4 years ago

when you enable the Circuit Termination you may see the following error: AttributeError: 'CircuitTermination' object has no attribute 'device' Also see #20

mattieserver commented 4 years ago

@martydingo , can you check if your issue is resolved?

mattieserver commented 4 years ago

24 added more NoneType checks

martydingo commented 4 years ago

Right, it's not erroring but I'm not seeing the circuit between a patch panel and a router, so it goes from router -> 24 LC patch panel (unnamed) then to a circuit, then lands at another DC on a router.

I had to redact a fair amount here, sorry.

image

I'm expecting the red to display, and this would then connect our sites up.

image

mattieserver commented 4 years ago

Thanks for the info, I understand that you have to redact some info. I believe the 'issue' now is that i did not include any checks for patch panels. I will check if i can add support for patch panels.

martydingo commented 4 years ago

Well people should be putting things like circuits into patch panels as standard, unless it's just the one circuit being used as a WAN, that I can understand.

Thanks very much!

On Wed, May 20, 2020 at 8:48 AM mattieserver notifications@github.com wrote:

Thanks for the info, I understand that you have to redact some info. I believe the 'issue' now is that i did not include any checks for patch panels. I will check what if i can add support for patch panels.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mattieserver/netbox-topology-views/issues/23#issuecomment-631301407, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL4NQAB44HUZ2DO6RKOB5NTRSODMTANCNFSM4NFKEEFA .

martydingo commented 4 years ago

Is there any progress on this?

mattieserver commented 4 years ago

I did not find the time yet.

Bah27 commented 3 years ago

Hello , what is the difference between the colors on the edges.

mattieserver commented 3 years ago

Nothing, it takes the colour you used for the cable in netbox itself. Same with the devices, it takes the colour of the device role.

Bah27 commented 3 years ago

thank you for your quick response

mskalecki commented 2 years ago

The plugin crashes with this exception if you have a cable with termination_a connected to a device and termination_b connected to a circuit.

This line is the culprit (it assumes that link.termination_b.device exists: https://github.com/mattieserver/netbox-topology-views/blob/0b6df3bd2807df301cb660f953ed860ba996144f/netbox_topology_views/views.py#L163

The fix is to add the check: elif link.termination_a.device.id in device_ids and hasattr(link.termination_b, 'device') and link.termination_b.device.id in device_ids:

candlerb commented 1 year ago

I still get this problem with NTV 2.0.1 under Netbox 3.2.9:

...
Oct 19 19:02:23 noc gunicorn[1795]:   File "/opt/netbox-3.2.9/venv/lib/python3.10/site-packages/netbox_topology_views/views.py", line 291
, in get
Oct 19 19:02:23 noc gunicorn[1795]:     topo_data = get_topology_data(self.queryset, hide_unconnected, intermediate_dev_role_ids, end2end
_connections)
Oct 19 19:02:23 noc gunicorn[1795]:   File "/opt/netbox-3.2.9/venv/lib/python3.10/site-packages/netbox_topology_views/views.py", line 156
, in get_topology_data
Oct 19 19:02:23 noc gunicorn[1795]:     elif link.termination_a.device.id in device_ids and link.termination_b.device.id in device_ids:
Oct 19 19:02:23 noc gunicorn[1795]: AttributeError: 'CircuitTermination' object has no attribute 'device'

The fix given by @mskalecki prevents the error, thank you!

(OTOH I am not seeing any devices at all, regardless of what filters I select; but that's a different problem) Oops, I had forgotten collectstatic

candlerb commented 1 year ago

Actually that fix doesn't work in the following scenario:

In this situation, with NTV 2.0.3, I find there is no link shown between device A and B, regardless of whether "Display end-to-end connections" is checked.

I'm not sure if such a circuit connection is expected to be shown, and if so, how it should be rendered. I notice the example image on the README.md page shows a dotted line, but I'm not sure if that's a circuit or something else.

dreng commented 1 year ago

@candlerb Since end-to-end connections has been reimplemented in the meantime, would you please check if the issue is solved for you now? If not, please provide the exact steps to reproduce this bug.

candlerb commented 1 year ago

I am testing git+https://github.com/mattieserver/netbox-topology-views@master now.

A few minor comments while I did this:

image image

But without "Hide unconnected" it's fine:

image

Now, back to the initial issue around circuits. With "Show circuit terminations" and "Show Cables" (or "Show Logical Connections"), it's now working:

image

In fact, "Show circuit terminations" without either Show Cables or Show Logical Connections is also fine:

image

So I think this issue is good to close now - thank you!

dreng commented 1 year ago

Thank you for your detailed feedback! I'm going to close this issue then.

All other things should be addressed in a seperate bug report, but just to give a quick feedback:

dreng commented 1 year ago
* When I select both "Hide unconnected" and "Show logical connections", for some reason the icons don't display:

I wasn't able to reproduce this. My result if I tick both options: topo_hide_uncon