Skip to content

How to modify an existing device using a custom script #6266

Answered by WhaleJ84
WhaleJ84 asked this question in Q&A
Discussion options

You must be logged in to vote

To answer my own question, I have discovered a few ways to go about it.

As Candlerb shows in great detail above, using transaction.atomic to wrap around the saving transactions can help prevent failures, but my testing found it cannot be used as an absolute solution; In my case it only allowed me to carry on one more save before having no effect (but as you can see from above, I'm probably still not understanding all it properly, so that's on me not working with Netbox scripts before :) ).

Next I started looking around for people's existing scripts and found one by Barbarossa. Inside you can see they write methods to both check if an attribute already exists within Netbox, and methods to …

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
6 replies
@candlerb
Comment options

@WhaleJ84
Comment options

@candlerb
Comment options

@WhaleJ84
Comment options

@candlerb
Comment options

Comment options

You must be logged in to vote
1 reply
@jeremystretch
Comment options

Answer selected by ryanmerolle
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