How to organize shared code in NetBox custom scripts #20932
Unanswered
krasotinpa
asked this question in
Help Wanted!
Replies: 2 comments
-
|
Hi - I've found one ugly hack to load module with my utilities from git to scripts dir.
from extras.scripts import Script
class DummyScript(Script):
class Meta:
name = "Dummy script to load utils"
description = "It exists only to load utils"
commit_default = False
scheduling_enabled = False
def my_cool_util:
pass
from scripts.my_utils import my_cool_util
...
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I'd try putting it in
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
A similar question may have been asked before, but I wanted to clarify in our context.
We have built up a large library of custom scripts for NetBox, which we load from our Git repository. We would like to refactor the repeating code into a shared module (e.g.,
my_utils.py).Question: Is it possible to store and import such a utility module from the same Git repository where the custom scripts are stored?
My attempt: I tried creating a my_utils.py file (without a
Scriptclass) in the repo, but without success.my_utils.py does not appear in the script directory and script fails on import.
Could you please advise on the correct approach or structure for shared code in NetBox custom scripts?
Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions