-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
'VMInterface' object has no attribute 'get' #18887
Comments
@variable , I think you've confused which direction your custom field is relating things. You write: new_prefix.custom_fields['workflow_associated_prefix_to_interface_mapping'] = nb_interface.id
new_prefix.save() This indicates that you're trying set a custom field on an instance of In [1]: import pynetbox
In [2]: api_key = '7c9f778294daca657d14cd87d63923480ad38a62'
In [3]: nb = pynetbox.api('http://127.0.0.1:8000', token=api_key)
In [4]: interfaces = list(nb.virtualization.interfaces.all())
In [5]: vmi0 = interfaces[0]
In [6]: vmi0.custom_fields
Out[6]: {'workflow_associated_prefix_to_interface_mapping': None}
In [7]: p0 = nb.ipam.prefixes.get(id=1)
In [8]: vmi0.custom_fields['workflow_associated_prefix_to_interface_mapping'] = p0.id
In [9]: vmi0.custom_fields
Out[9]: {'workflow_associated_prefix_to_interface_mapping': 1}
In [10]: vmi0.updates()
Out[10]: {'custom_fields': {'workflow_associated_prefix_to_interface_mapping': 1}}
In [11]: vmi0.save()
Out[11]: True This is behaving as intended. |
@jnovinger Is the image not showing what was described? The object type on the right hand side is IPAM | prefix and the type of the linked object is Vminterface. I am having the same issue currently while using custom fields to link one vminterface to another which was working just fine on 3.4 but has been failing since updating to 4.2.4 last week. I tested directly via the swagger-ui page on my local netbox setup. |
Oof, you are correct @srigby345s . I was definitely the one misreading things in this case. Thanks for keeping me honest! I'm going to re-open this issue and put it back in triage, with the intention of revisiting it later today. |
@variable , my apologies for misunderstanding the bug report! |
No worries! |
Deployment Type
Self-hosted
NetBox Version
4.2.2
Python Version
3.11
Steps to Reproduce
I am trying to associate a VM interface to a prefix via custom field, using Pynetbox
This is the custom field
If I comment out the custom_field statement, save is fine. I also tried saving via UI with the relationship, UI worked fine.
Expected Behavior
Saving works.
Observed Behavior
And I got this error
It appears this is the line that threw the error:
Somehow... data is already a VMInterface object
The text was updated successfully, but these errors were encountered: