NetBox version
2.11.2
Describe the bug
Unable to create BGP Session object using pynetbox, when peer_group is supplied in the args.
To Reproduce
nb_staging in the output below is my instance of pynetbox.api
In [943]: object_dict
Out[943]:
{'import_policies': [51, 66, 18],
'export_policies': [60, 18],
'description': 'LEVEL3',
'peer_group': 8,
'local_address': {'address': '4.71.253.6/30'},
'remote_address': {'address': '4.71.253.5/30'},
'local_as': {'number': 12345},
'remote_as': {'number': 3356},
'name': '3356_TRANSIT_LEVEL3_mydevice',
'device': {'name': 'mydevice'}}
In [944]: nb_staging.plugins.bgp.session.create(object_dict)
RequestError Traceback (most recent call last)
<ipython-input-944-5e86e2d8ef9b> in <module>()
----> 1 nb_staging.plugins.bgp.session.create(object_dict)
/netbox_dev/nsot-ipython.runfiles/__main__/pip/pynetbox/pynetbox-cpython-38/lib/pynetbox/core/endpoint.py in create(self, *args, **kwargs)
302 """
303
--> 304 req = Request(
305 base=self.url,
306 token=self.token,
/netbox_dev/nsot-ipython.runfiles/__main__/pip/pynetbox/pynetbox-cpython-38/lib/pynetbox/core/query.py in post(self, data)
385 :Returns: Dict containing the response from NetBox's API.
386 """
--> 387 return self._make_call(verb="post", data=data)
388
389 def delete(self):
/netbox_dev/nsot-ipython.runfiles/__main__/pip/pynetbox/pynetbox-cpython-38/lib/pynetbox/core/query.py in _make_call(self, verb, url_override, add_par
ams, data)
280 raise ContentError(req)
281 else:
--> 282 raise RequestError(req)
283
284 def concurrent_get(self, ret, page_size, page_offsets):
RequestError: The request failed with code 500 Internal Server Error: {'error': "argument of type 'BGPPeerGroup' is not iterable", 'exception': 'TypeError', 'netbox_
version': '2.11.2', 'python_version': '3.8.8+'}
Expected behavior
The BGP Session object gets created
Screenshots
n/a - the traceback above should be sufficient.
Additional context
I have also tried changing
object_dict['peer_group'] = {'name': 'TRANSIT'}
but I still get the same error. Neither referencing related object by a dictionary of attributes nor by its ID seem to work.
If I remove the 'peer_group' key from object_dict altogether, the BGP session object gets created successfully. However, thats not what I would like. I'd like to relate the session to a peer group.
bug