Skip to content

Conversation

@jeremystretch
Copy link
Member

Fixes: #12431

WIP

@kkthxbye-code
Copy link
Contributor

kkthxbye-code commented May 3, 2023

The following issues were found by using https://github.com/kkthxbye-code/netboxscriptexample as a testcase. The repo was added as a datasource, and ScriptModules were added one by one for all files, including __init__.py files.

First issue is that relative imports do not seem to work, changing:

https://github.com/kkthxbye-code/netboxscriptexample/blob/a09ad436ab50440723a9f20fc633c3daddc1bb18/nestedmodule/nested_script1.py#L3

To:

from scripts.nestedmodule.base_script import BaseScript

Makes it work.

After this the script page looks like this:

image

The first obvious issue is that non-script modules need to be imported to be available in the source path and will show up as empty. Not sure how to fix this, as it seems at odds with the new script system.

Taking the Scripts from the top.

nestedmodule:

  • Title should be "My Nested Scripts" which is defined in the __init__.py file.
  • Opening the Scripts generate a URL like /extras/scripts/nestedmodule/nestedmodule/nested_script2.NestedScript2/ which 404's. nestedmodule appears twice, removing it nets another error: get() returned more than one ScriptModule -- it returned 4!

nested_script1 and nested_script2:

Should not be shown, but since we have to add it as a ScriptModule it has to. Opening and running works, but using the Jobs or Source tab loads a 404 URL of this format /extras/scripts/nested_script1/NestedScript1/jobs/

root_script

Do not work, generates URLs like these: /extras/scripts//root_script/RootScript1/ - removing the extra slash makes it load and run. Source and jobs tabs do not work, generates URL's like these: /extras/scripts/root_script/RootScript1/source/. Also seems like the name does not function anymore.

For reference this is what the example repo looks like in netbox 3.4:

image

While I don't expect everything to work as it did in 3.4, the most important part for me personally, is the option to import utility functions and for having multiple scripts under the same card in the UI without having to have the scripts in the same source file. The latter witch is solved in 3.4 by using submodules and importing the scripts in the __init__.py file

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2023

This PR has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further action is taken.

@github-actions github-actions bot added the pending closure Requires immediate attention to avoid being closed for inactivity label Aug 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

This PR has been automatically closed due to lack of activity.

@github-actions github-actions bot closed this Sep 4, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2023
@jeremystretch jeremystretch deleted the 12431-managedfile-paths branch January 4, 2024 15:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

pending closure Requires immediate attention to avoid being closed for inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creating a report or script from a remote data source does not retain the origin's directory hierarchy

3 participants