Skip to content
Discussion options

You must be logged in to vote

When you're not sure how to interact with an object, first reference the model's source code: More of than not it will have all the clues you need. You can find the source for the IPAddress model in ipam/models/ip.py.

You can see that there's no interface field on the IPAddress model.* Instead, we see a generic foreign key named assigned_object. This field can be set to assign an IP address to a device interface, a VM interface, or an FHRP group.

new_ip.assigned_object = new_int
new_ip.save()

Hope that helps!

*IIRC there was an interface field on the IPAddress model some time ago, but it was replaced with a generic foreign key when we split device and VM interfaces into separate models (…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jscooksey
Comment options

@candlerb
Comment options

Answer selected by jscooksey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants