1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Move script attributes under a Meta class

This commit is contained in:
Jeremy Stretch
2019-08-12 13:16:18 -04:00
parent ab504439fb
commit 19eb4c510c
4 changed files with 22 additions and 17 deletions

View File

@ -39,20 +39,22 @@ Returning output from your script is optional. Any raw output generated by the s
## Script Attributes
### script_name
Script attributes are defined under a class named `Meta` within the script. These are optional, but encouraged.
### `name`
This is the human-friendly names of your script. If omitted, the class name will be used.
### script_description
### `description`
A human-friendly description of what your script does (optional).
A human-friendly description of what your script does.
### script_fields
### `fields`
The order in which the variable fields should appear. This is optional, however on Python 3.5 and earlier the fields will appear in random order. (Declarative ordering is preserved on Python 3.6 and above.) For example:
```
script_fields = ['var1', 'var2', 'var3']
fields = ['var1', 'var2', 'var3']
```
## Logging
@ -124,9 +126,11 @@ from extras.scripts import *
class NewBranchScript(Script):
script_name = "New Branch"
script_description = "Provision a new branch site"
script_fields = ['site_name', 'switch_count', 'switch_model']
class Meta:
name = "New Branch"
description = "Provision a new branch site"
fields = ['site_name', 'switch_count', 'switch_model']
site_name = StringVar(
description="Name of the new site"