Assign IPAddress to a Virtual interface issue #7047
-
Hello guys, I'm having trouble assigning an IP to a virtual interface via custom script and/or nbshell, the code returns this error: TypeError: Direct assignment to the reverse side of a related set is prohibited. Use interface.set() instead. This is the code: (netbox v2.10.8)
Sorry for my bad understand of django. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
As of Netbox v2.9.0, Interface was split into Hence there is no longer an Here is some working code: It creates a VirtualMachine, a VMInterface and an IPAddress, and links them together. |
Beta Was this translation helpful? Give feedback.
As of Netbox v2.9.0, Interface was split into
Interface
andVMInterface
.Hence there is no longer an
interface
attribute on IPAddress, there isassigned_object
. This is because an IPAddress can be linked to either an Interface or a VMInterface, and it uses a generic relation for this.Here is some working code:
https://github.com/netbox-community/reports/blob/master/scripts/create_vm.py#L88
It creates a VirtualMachine, a VMInterface and an IPAddress, and links them together.