-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix custom_filed KeyError traceback #518
Fix custom_filed KeyError traceback #518
Conversation
pynetbox/core/response.py
Outdated
return { | ||
k: v if not isinstance(v, dict) else v["value"] for k, v in custom_dict.items() | ||
} | ||
return {k: v for k, v in custom_dict.items()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This really seems like a NOOP to me. Perhaps it would be better to eliminate calls to flatten_custom altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need it for Objects and Multiple Objects custom fields (although it needs to be adapted too) |
Okay, so it should return something like. Object:
Response {
"id":5023,
"url":"https://NETBOX-INSTANCE/api/dcim/inventory-items/5023/",
"display":"0/6/1",
"device":61,
"parent":"None",
"name":"0/6/1",
"label":"",
"role":5,
"manufacturer":"None",
"part_id":"",
"asset_tag":"None",
"discovered":true,
"description":"",
"component_type":"None",
"component_id":"None",
"component":"None",
"tags":[
],
"custom_fields":{
"test_json_custom_field":{
"x":1,
"y":2
},
"test_list_custom_field":[
"x",
"y"
],
"test_multiple_objects_custom_field":[
{
"id":1,
"url":"https://NETBOX-INSTANCE/api/dcim/devices/1/",
"display":"DEV1",
"name":"DEV1"
},
{
"id":119,
"url":"https://NETBOX-INSTANCE/api/dcim/devices/119/",
"display":"DEV2",
"name":"DEV2"
},
],
"abra_discovered":false,
"asset_numbers":"T5060",
"inventarizace":{
"x":1,
"y":2
},
"inventory_monitor_active":true,
"inventory_monitor_last_probe":"2022-11-23",
"inventory_monitor_probe":{
"id":1648,
"url":"https://NETBOX-INSTANCE/api/plugins/inventory-monitor/probes/1648/",
"display":"Object",
"name":"0/6/1",
"time":"2022-11-23T01:16:47.492262Z"
},
"inventory_monitor_probed":true
},
"created":"2022-09-06T10:03:36.248425Z",
"last_updated":"2022-11-23T08:46:57.907296Z",
"_depth":0
} Or it just should return the ids {
"id":5023,
"url":"https://NETBOX_URL/api/dcim/inventory-items/5023/",
"display":"0/6/1",
"device":61,
"parent":"None",
"tags":[
],
"custom_fields":{
"test_json_custom_field":{
"x":1,
"y":2
},
"test_list_custom_field":[
"x",
"y"
],
"test_multiple_objects_custom_field":[
1,
119,
252
],
"abra_discovered":false,
"asset_numbers":"T5060",
"inventarizace":{
"x":1,
"y":2
},
"inventory_monitor_active":true,
"inventory_monitor_last_probe":"2022-11-23",
"inventory_monitor_probe":1648,
"inventory_monitor_probed":true
},
"created":"2022-09-06T10:03:36.248425Z",
"last_updated":"2022-11-23T08:46:57.907296Z",
"_depth":0
} Uploaded version
|
7eea279
to
75ab3ae
Compare
Is there any chance this pull request can be reviewed and merged into an upstream version of pynetbox? We're hitting the same bug when trying to create netbox_prefix via ansible with custom_fields. |
Will take a look into it, probably Wed or Thursday before I can get to it. |
No description provided.