-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Cannot add or remove scripts from Custom Scripts after updating to 3.5.0 #12416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's not clear from your description exactly what steps you're taking. How are you adding the new script? What script are you removing? Please edit your post above to provide clear instructions so that someone else can attempt to replicate the behavior. |
Apologies. I have tried to make the steps to reproduce more clear, basically I already had a custom script in /opt/netbox/netbox/scripts long before upgrading to 3.5.0 and I can see that script in the "scripts" tab in NetBox. If I try to add more scripts into /opt/netbox/netbox/scripts they do not show up in the "scripts" tab in NetBox. It only just shows that one script that was present before the upgrade. But also, if I remove that script that existed in /opt/netbox/netbox/scripts before upgrading to 3.5.0 (meaning there is no custom scripts present in /opt/netbox/netbox/scripts at all) and I go to the "scripts" tab in NetBox, I get the following error: <class 'FileNotFoundError'> [Errno 2] No such file or directory: '/opt/netbox/netbox/scripts/<script_name>.py' Python version: 3.8.10 |
I think the issue here is that scripts and reports work significantly different in 3.5.0 than before, and to be honest it's not really documented very well in the release notes. There's now a concrete database representation of an "installed" script in the database, see: #12068 The reason your scripts were there after the upgrade, is that a migration runs, importing the scripts from the script folder. The new way of working with scripts consist of using the Add script button on the script page and either uploading the script directly, or using the new data sync feature. Deleting scripts is done by using the delete script button. To be honest, I haven't had a lot of time myself to play around with the new script/report setup in 3.5.0, so another maintainer might be able to shine more light on the intended workflow. |
To clarify the reproduction steps here: "Access Scripts tab on Web UI, newly added script that was put into /opt/netbox/netbox/scripts does not show up" This is by design. To add scripts in 3.5 you need to add them in the UI. For the second issue, to reproduce:
|
Correct, yes - to fix this, I re-added the script via CLI back into /opt/netbox/netbox/scripts, then deleted it via the UI. Then, re-added it via the UI and all looks good. However, I have ran into another error that I will open a different bug report for. If you upload a script that by chance has an error, such as an indentation error, or in this example an undefined variable, you will get the following error message for after the upload: <class 'NameError'> name 'StringVar' is not defined Python version: 3.8.10 Then if you access the Scripts tab in the UI you will be presented with that error, so there is no way to delete it or view other scripts. The fix is to either edit and fix the script in /opt/netbox/netbox/scripts or remove all the contents from the script itself and then you should be able to access the scripts tab again. |
@parkerschoenig I've got a pending PR in that should hopefully fix both these issues. |
NetBox version
v.3.5.0
Python version
3.8
Steps to Reproduce
OR
Originally I thought this was due to a bug with the netbox-secrets plugin (not supported on 3.5.0 yet, hence why the Changelog doesn't work) so I have removed the netbox-secrets plugin and dropped the related tables from the psql DB according to the Remove a Plugin documentation and restarted NetBox, however the issue with the custom scripts.Expected Behavior
New scripts should be present in the "Scripts" tab in NetBox, removed script should not be present / not error.
Observed Behavior
Server Error
There was a problem with your request. Please contact an administrator.
The complete exception is provided below:
<class 'FileNotFoundError'>
[Errno 2] No such file or directory: '/opt/netbox/netbox/scripts/add_device_type_components.py'
Python version: 3.8.10
NetBox version: 3.5.0
The text was updated successfully, but these errors were encountered: