You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+56-4Lines changed: 56 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,9 @@ The plugin can be used in addition to the built-in script support and does not d
15
15
* Exceptions caused by errors in script files are displayed in the UI.
16
16
* Log messages are saved and displayed when the script is running allowing live output for long running scripts.
17
17
* It's possible to filter log lines by message and/or log level.
18
-
* Script executions are listed in a tab when viewing a script.
19
18
* Changelog entries are listed in a tab when viewing a finished script execution.
20
19
* It's possible to save script artifacts during the execution of a script. These artifacts will show up as downloadable files.
21
-
*Possibility to re-run scripts.
20
+
*It's possible to re-run scripts.
22
21
23
22
## What is not supported
24
23
@@ -33,15 +32,53 @@ The plugin can be used in addition to the built-in script support and does not d
33
32
|----------------|----------------|
34
33
| 3.5 | 0.1.0 |
35
34
35
+
## Migrating scripts
36
+
37
+
The most important change is to change the import and name of the base `Script` class.
38
+
39
+
Netbox Script:
40
+
41
+
```python
42
+
from extras.scripts import Script
43
+
44
+
classMyCustomScript(Script):
45
+
...
46
+
```
47
+
48
+
Netbox Script Manager Script:
49
+
50
+
```python
51
+
from netbox_script_manager.scripts import CustomScript
52
+
53
+
classMyCustomScript(CustomScript):
54
+
...
55
+
```
56
+
57
+
It is strongly recommended to do relative imports in your scripts, when using a nested structure or utility code.
58
+
59
+
```python
60
+
from .util import my_utility_method
61
+
from ..subfolder import myCustomScript
62
+
```
63
+
64
+
The alternative is to do an absolute import:
65
+
66
+
```python
67
+
from customscripts.nested_folder.util import my_utility_method
68
+
from customscripts.subfolder import myCustomScript
69
+
```
70
+
71
+
Please see the `Script folder` section for instructions regarding folder structure.
72
+
36
73
## Script folder
37
74
38
75
The loading of scripts is a little different with netbox-script-manager. The `SCRIPT_ROOT` plugin setting must be set to define the path of the custom scripts, however the scripts must be located in a folder named `customscripts` in this path.
39
76
40
77
A folder structure like this is required (`SCRIPT_ROOT` pointing to the `netboxscripts` folder):
41
78
42
79
```bash
43
-
├── netboxscripts
44
-
│ ├── customscripts
80
+
├── netboxscripts# SCRIPT_ROOT
81
+
│ ├── customscripts# Scripts will be discovered in this module, must be present
45
82
│ │ ├── __init__.py
46
83
│ │ ├── nestedmodule
47
84
│ │ ├── root_script.py
@@ -74,3 +111,18 @@ PLUGINS_CONFIG = {
74
111
},
75
112
}
76
113
```
114
+
115
+
## Confiugration
116
+
117
+
The following options are required:
118
+
119
+
*`SCRIPT_ROOT`: Path to the script folder containing the customscripts module.
120
+
121
+
The following options are optional:
122
+
123
+
*`DEFAULT_QUEUE`: Specifies what queue scripts are run in by default. Defaults to the `default` queue.
0 commit comments