Skip to content

Not possible to use custom scripts in nested packages #10258

@kkthxbye-code

Description

@kkthxbye-code

NetBox version

v3.3.2

Python version

3.10

Steps to Reproduce

Create the following folder structure:

./scripts/__init__.py
./scripts/testscript.py
./scripts/subscriptfolder/__init__.py 
./scripts/subscriptfolder/myscript1.py
./scripts/subscriptfolder/myscript2.py

testscript.py contains script class TestScript(Script):

myscript1.py contains script class MyScript1(Script):

myscript2.py contains script class MyScript2(Script):

__init__.py contains:

from myscript1 import MyScript1
from myscript2 import MyScript2

Expected Behavior

Three scripts should be shown on the script page:

TestScript under the testscript heading and MyScript1 and MyScript2 under the subscriptfolder heading.

All scripts should work as expected.

Observed Behavior

All scripts show in the list as expected, but clicking on the subscriptsfolder scripts will cause a 404 error as the URL points to subscriptsfolder.myscript1.MyScript1 but the returned dict from get_scripts() is in the following format:

{
  "subscriptsfolder": {"MyScript1": MyScript1() }
}

Noticably missing the myscript1 part of the module path.

This makes it hard to organize scripts as there is no way to get scripts under the same heading without having them in the same file.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions