Closed HarishankarYellapragada closed 1 year ago
You code doesn't make any sense: You are calling .update()
on a VLAN object, but there is no tagged_vlans
attribute in a VLAN object:
>>> vlan = netbox.ipam.vlans.get(4)
>>> vlan
TestVLAN2
>>> vlan.tagged_vlans
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/markku/temp/pynetbox-venv/lib/python3.9/site-packages/pynetbox/core/response.py", line 308, in __getattr__
raise AttributeError('object has no attribute "{}"'.format(k))
AttributeError: object has no attribute "tagged_vlans"
>>> import pprint
>>> pprint.pprint(dict(vlan))
{'comments': '',
'created': '2023-06-17T14:08:47.562558+03:00',
'custom_fields': {},
'description': '',
'display': 'TestVLAN2 (2)',
'group': {'display': 'Group1',
'id': 1,
'name': 'Group1',
'slug': 'group1',
'url': 'http://netbox-test.lein.io/api/ipam/vlan-groups/1/'},
'id': 4,
'l2vpn_termination': None,
'last_updated': '2023-06-17T14:08:47.562583+03:00',
'name': 'TestVLAN2',
'prefix_count': 0,
'role': None,
'site': None,
'status': {'label': 'Active', 'value': 'active'},
'tags': [],
'tenant': None,
'url': 'http://netbox-test.lein.io/api/ipam/vlans/4/',
'vid': 2}
>>>
This works as expected:
>>> interface = netbox.dcim.interfaces.get(device="Test", name="eth0")
>>> interface.tagged_vlans
[TestVLAN2]
>>> interface.update({"tagged_vlans":[5,6]})
True
>>> interface = netbox.dcim.interfaces.get(device="Test", name="eth0")
>>> interface.tagged_vlans
[TestVLAN3, TestVLAN4]
>>>
Unable to update using update. Manually updated MG interface. So, I can see that
output: