Create a Child Prefix in Custom Script Without Using the API #18128
Replies: 2 comments 6 replies
-
Have you looked at other custom scripts to build your own ? You can use the netbox (django) models directly in the custom scripts and leverage all the availlable methods. |
Beta Was this translation helpful? Give feedback.
-
You didn't show which REST API endpoint you are invoking, but I'm guessing it's a POST to If so, then the URL is matched here. The implementation is a bit tricky because it's quite general to support allocation of various types of objects; you should look at AvailablePrefixesView here, AvailableObjectsView here, which calls back to get_available_objects and prep_object_data. In short, I think what it's doing is creating an IPSet to represent the unallocated space, calling |
Beta Was this translation helpful? Give feedback.
-
Hello Everyone,
I’m working on a task to create a child prefix of a specified length from an existing prefix. I’ve managed to accomplish this using the API with the following Python script:
While this works fine, I’m looking for a way to achieve the same result directly within a NetBox custom script, without relying on API calls.
Does anyone have insights or examples of how to perform this directly through Script? Any advice or solutions would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions