netbox-topology-views icon indicating copy to clipboard operation
netbox-topology-views copied to clipboard

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

Open mattieserver opened this issue 5 years ago • 11 comments

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

mattieserver avatar May 19 '20 20:05 mattieserver

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

mattieserver avatar May 20 '20 06:05 mattieserver

#24 added more NoneType checks

mattieserver avatar May 20 '20 06:05 mattieserver

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

martydingo avatar May 20 '20 07:05 martydingo

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.

mattieserver avatar May 20 '20 07:05 mattieserver

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 [email protected] 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 avatar May 20 '20 10:05 martydingo

Is there any progress on this?

martydingo avatar Jun 01 '20 06:06 martydingo

I did not find the time yet.

mattieserver avatar Jun 01 '20 16:06 mattieserver

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

Bah27 avatar Jul 09 '21 11:07 Bah27

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.

mattieserver avatar Jul 09 '21 11:07 mattieserver

thank you for your quick response

Bah27 avatar Jul 09 '21 11:07 Bah27

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:

mskalecki avatar Aug 11 '22 15:08 mskalecki

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 avatar Oct 19 '22 19:10 candlerb

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

  • Device A interface A'
  • --- cable --->
  • CircuitTermination (A side)
  • --- circuit C --->
  • CircuitTermination (Z side)
  • --- cable --->
  • Device B interface B'

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.

candlerb avatar Oct 19 '22 19:10 candlerb

@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.

dreng avatar Jan 07 '23 15:01 dreng

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

A few minor comments while I did this:

  • I was a bit surprised at first to see all devices floating and unconnected. This is because neither "Show cables" nor "Show logical connections" is selected by default. I think one of them should be active by default (probably "Show cables"). Some ideas:
    • It would perhaps be reasonable to invert this to "Hide cables", given that there's already "Hide unconnected".
    • Is it useful in practice to be able to show both cables and logical connections simultaneously, or topology without either type of connection? If not, then this could simplify to a radio button pair. Or even a single checkbox "show logical connections" which means "show logical connections instead of cables".
    • Otherwise, if you're keeping two checkboxes, I think it would be good if "Show cables" and "Show logical connections" were adjacent to each other
  • When I select both "Hide unconnected" and "Show logical connections", for some reason the icons don't display:

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!

candlerb avatar Jan 07 '23 19:01 candlerb

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:

  • Unconnected devices: This has been reported already regarding the topology button in "Sites" (#237 ). We could provide a very quick fix, but I'm planning to change some related parts anyway and therefore I leave it like it is for now.
  • Hide cables: Disagree. I'd rather change "hide unconnected" to "show unconnected" in order to have the same logic in all checkboxes. See also #238.
  • Show both: We discussed this in the PR #188 and finally left the decision to the user. Each combination might be useful. There's also a config file option "hide_single_cable_logical_conns" which prevents redundancy with cables and logical connections.

dreng avatar Jan 07 '23 20:01 dreng

* 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

dreng avatar Jan 07 '23 20:01 dreng