Introduce a clone() method on NetBoxModel #6509

Closed
opened 2025-12-29 19:41:45 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (May 24, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.2.3

Feature type

New functionality

Proposed functionality

Add a clone() method to the base NetBoxModel class (or a new mixin) to replace the current approach of defining clone_fields on a model. This will return a dictionary of field names mapped to values to be used in the creation of a cloned object. Document this method as a supported component for plugins.

Use case

The switch from a static list of fields to a method allows us to apply arbitrary logic when determining the values for the cloned object. For example, when cloning an IP address, we can automatically calculate the next available address (#8171).

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (May 24, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.2.3 ### Feature type New functionality ### Proposed functionality Add a `clone()` method to the base NetBoxModel class (or a new mixin) to replace the current approach of defining `clone_fields` on a model. This will return a dictionary of field names mapped to values to be used in the creation of a cloned object. Document this method as a supported component for plugins. ### Use case The switch from a static list of fields to a method allows us to apply arbitrary logic when determining the values for the cloned object. For example, when cloning an IP address, we can automatically calculate the next available address (#8171). ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: featuretopic: plugins labels 2025-12-29 19:41:45 +01:00
adam closed this issue 2025-12-29 19:41:45 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6509