IPAM model to create and delete host. #14849
-
I'm trying to create a custom script/form to create and delete host.
The netbox gui does not accept this as in the it just throws the error in the web: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Your script has a syntax error which prevents it being loaded, but unfortunately Netbox doesn't show you what the actual error is, unless you enable logging (see #12766) Try adding the following to the very top of your script:
Then run it again using:
This ought to be a FAQ. |
Beta Was this translation helpful? Give feedback.
-
Thank you!
But I was going to run it from netbox web GUI -- > Customization -->
Scripts --> New-Form
This looks like its set to run CLI way?
…On Thu, Jan 18, 2024 at 6:20 PM Brian Candler ***@***.***> wrote:
Your script has a syntax error which prevents it being loaded, but
unfortunately Netbox doesn't show you what the actual error is, unless you
enable logging (see #12766
<#12766>)
Try adding the following to the very top of your script:
import django, os, sys
sys.path.append('/opt/netbox/netbox')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'netbox.settings')
django.setup()
Then run it again using:
/opt/netbox/venv/bin/python /usr/local/netbox/custom/new-form.py
This ought to be a FAQ.
—
Reply to this email directly, view it on GitHub
<#14849 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGLMHE7EGOOLRX7KU6KNBRDYPGU4NAVCNFSM6AAAAABCAU6AJKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DCNZVGA4DK>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
You have to run it this way to see the syntax error. Once you've fixed the syntax error, delete or comment out those extra lines, then you can run it from the GUI. (The script won't actually run from the command line this way anyway. It will just load all the classes, then terminate).