Skip to content

Commit f68ee41

Browse files
committed
Updated README.md
1 parent 8c3159d commit f68ee41

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

README.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ The plugin can be used in addition to the built-in script support and does not d
1515
* Exceptions caused by errors in script files are displayed in the UI.
1616
* Log messages are saved and displayed when the script is running allowing live output for long running scripts.
1717
* 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.
1918
* Changelog entries are listed in a tab when viewing a finished script execution.
2019
* 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.
2221

2322
## What is not supported
2423

@@ -33,15 +32,53 @@ The plugin can be used in addition to the built-in script support and does not d
3332
|----------------|----------------|
3433
| 3.5 | 0.1.0 |
3534

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+
class MyCustomScript(Script):
45+
...
46+
```
47+
48+
Netbox Script Manager Script:
49+
50+
```python
51+
from netbox_script_manager.scripts import CustomScript
52+
53+
class MyCustomScript(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+
3673
## Script folder
3774

3875
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.
3976

4077
A folder structure like this is required (`SCRIPT_ROOT` pointing to the `netboxscripts` folder):
4178

4279
```bash
43-
├── netboxscripts
44-
│ ├── customscripts
80+
├── netboxscripts # SCRIPT_ROOT
81+
│ ├── customscripts # Scripts will be discovered in this module, must be present
4582
│ │ ├── __init__.py
4683
│ │ ├── nestedmodule
4784
│ │ ├── root_script.py
@@ -74,3 +111,18 @@ PLUGINS_CONFIG = {
74111
},
75112
}
76113
```
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.
124+
125+
126+
## Screenshots
127+
128+
TODO

0 commit comments

Comments
 (0)