Open maznu opened 2 years ago
This does not appear to be a problem when creating a cable, only when updating an existing one.
This is also an issue when GETting cables. a_terminations and b_terminations are returned as empty lists.
e: a_terminations and b_terminations are not in fact empty lists. They just show up as empty lists in the cable string representation. As a workaround, cable.termination_a.device.id
can be replaced like this: cable.a_terminations[0].object.device.id
Any ideas on workaround for this? Getting works fine for me, but updates are failing using pynetbox library
I've got this on my list to work on next, but will take a while before I can get it updated. If you see any other APIs broken for 3.3, please let me know.
Any updates here?
@karolyczovek @maznu @jcollie would any of you be able to get the feature branch and test it out for the cabling a_terminations changes? The feature branch will only work for NetBox 3.3 due to the changes. I'd like to get it tested more if possible before cutting a new release.
So far so good. Not much time to do anything serious with it yet. Tomorrow I should be able to do some more testing. One unrelated thing that I noticed tonight is that the link peers on a cable termination are not cast to a specific model but are left as a generic record.
Thanks @jcollie The link_peers looks like a bit of a different issue, I'll open a separate issue for it but will probably want to change the API in NetBox (probably 3.5 release) as the return for these types of things currently isn't consistent.
Things seem to be working well today so far. One thing that would be nice would be the ability to create a cable just by passing the whole object (like in the commented-out code) vs passing a dict.
cable = nb.dcim.cables.create(
# a_terminations=[remote_interface],
# b_terminations=[local_interface],
a_terminations=[
{
"object_type": "dcim.interface",
"object_id": local_interface.id,
}
],
b_terminations=[
{
"object_type": "dcim.interface",
"object_id": remote_interface.id,
}
],
)
I just upgraded to 7.0.1 and now I don't get the object_type or object_id parameters any more (they're still present in the NetBox API). I'm specifically working with the dcim.cables endpoint. What happened?
I'm using NetBox 3.3.10 and I upgraded from pynetbox 6.6.2
6.6.2:
{'a_terminations': [{'object': {'_occupied': True,
'cable': 57,
'device': {'display': 'ESC2-MI-RT-CN-01-01',
'id': 547,
'name': 'ESC2-MI-RT-CN-01-01',
'url': 'https://netbox.XXXXXXXX.com/api/dcim/devices/547/'},
'display': '1',
'id': 9670,
'name': '1',
'url': 'https://netbox.XXXXXXXX.com/api/dcim/interfaces/9670/'},
'object_id': 9670,
'object_type': 'dcim.interface'}],
'b_terminations': [{'object': {'_occupied': True,
'cable': 57,
'device': {'display': 'ESC2-MI-OL-CX-01-01',
'id': 836,
'name': 'ESC2-MI-OL-CX-01-01',
'url': 'https://netbox.XXXXXXXX.com/api/dcim/devices/836/'},
'display': '1/1/x1',
'id': 9923,
'name': '1/1/x1',
'url': 'https://netbox.XXXXXXXX.com/api/dcim/interfaces/9923/'},
'object_id': 9923,
'object_type': 'dcim.interface'}]
}
7.0.1:
{'a_terminations': [{'_occupied': True,
'cable': 57,
'device': {'display': 'ESC2-MI-RT-CN-01-01',
'id': 547,
'name': 'ESC2-MI-RT-CN-01-01',
'url': 'https://netbox.XXXXXXXX.com/api/dcim/devices/547/'},
'display': '1',
'id': 9670,
'name': '1',
'url': 'https://netbox.XXXXXXXX.com/api/dcim/interfaces/9670/'}],
'b_terminations': [{'_occupied': True,
'cable': 57,
'device': {'display': 'ESC2-MI-OL-CX-01-01',
'id': 836,
'name': 'ESC2-MI-OL-CX-01-01',
'url': 'https://netbox.XXXXXXXX.com/api/dcim/devices/836/'},
'display': '1/1/x1',
'id': 9923,
'name': '1/1/x1',
'url': 'https://netbox.XXXXXXXX.com/api/dcim/interfaces/9923/'}]
}
Looks like one level of attributes are missing:
When talking to NetBox v3.3, pynetbox v6.6.2 chokes when POSTing to
dcim.cable
by raising exception AttributeError: object has no attribute "id"This is because in NetBox v3.2 and earlier:
Whereas NetBox v3.3 has a list of dicts: