Custom Link to Custom Script #18498
Replies: 3 comments
-
I figured out that the base url can be derived from {{ object.base_url }}. I believe the script ID will still need to be set statically. |
Beta Was this translation helpful? Give feedback.
-
You don't need to specify the base (probably, might depend on the proxy in front of netbox). You can just use the URL fragment like this as the URL:
As for the script ID needing to be set statically, it appears this is the case. In the API they mention referring to the script by name (https://netboxlabs.com/docs/netbox/en/stable/customization/custom-scripts/#via-the-api) which uses filename_without_dotpy.ClassNameFromScript as the identifier. But I tried that with the web GUI and this doesn't work. Hopefully your scripts don't move around too much so you can use whatever the ID number is as a permanent reference. It does make it harder if you want to setup the same scripts and custom links in multiple environments though. This might be something to request as a feature in the future. |
Beta Was this translation helpful? Give feedback.
-
I've actually been going through that now. Since I store custom link templates in GH, I've gone through and done this
I have a supplemental function(s) I run in nbshell that retrieves all the script ID' and just updates the defined custom link objects in NetBox, when it matches a pattern. Something like this. Note that I had to modify it a bit to simplify since my functions were doing other things. So this version is not tested.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to figure out a way to create a custom link to a custom script in a programmatic way. Something like this.
{{ baseurl }}/extras/scripts/{{ script_id }}
It looks like only the reference object is available, so this may not be possible. Any help is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions