pynautobot icon indicating copy to clipboard operation
pynautobot copied to clipboard

Termination sub-attribute not found

Open TitouanS31 opened this issue 7 months ago • 8 comments

I found a bug by trying to get the name of a device at the end of a cable. Here is the cable trace from the Nautobot demo.

image

I wanted to get the device name lhr01-edge-01 from the cable 73a65bf1-333e-4a09-9023-e77e05487151 using the termination_a attribute. Here is the code I wrote to achieve this.

import pynautobot

nautobot = pynautobot.api(
    url="https://demo.nautobot.com",
    token="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
)

cable = nautobot.dcim.cables.get("73a65bf1-333e-4a09-9023-e77e05487151")

# print(cable.termination_a)
# cable.termination_a.full_details()
print(cable.termination_a.device.name)

I expected to get lhr01-edge-01 as output. I instead got the following exception.

Traceback (most recent call last):
  File "c:\Users\foo\Documents\misc\termination_bug.py", line 16, in <module>
    print(cable.termination_a.device.name)
AttributeError: type object 'Devices' has no attribute 'name'

The most surprising thing is that if I print the termination first, it works. I guess there is a full_details call missing since calling this method seems to be a workaround ; but I don't think that behaviour is intended.

Nautobot version: 2.2.8 Pynautobot version: 2.2.0

TitouanS31 avatar Jul 25 '24 14:07 TitouanS31