Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with merged fields from separate custom scripts #4710

Closed
mahomedh opened this issue Jun 2, 2020 · 4 comments
Closed

Problem with merged fields from separate custom scripts #4710

mahomedh opened this issue Jun 2, 2020 · 4 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@mahomedh
Copy link

mahomedh commented Jun 2, 2020

Environment

  • Python version: 3.6.9
  • NetBox version: 2.8.5

Steps to Reproduce

  1. Install the create_vm.py script and the add_services.py scripts (attached as .txt files)
    create_vm.py.txt
    add_services.py.txt

  2. click on create_vm

  3. enter some parameters

  4. click on Run Script

  5. it rejects the entry and displays a whole load of parameters from the add_service script

  6. viewing a fresh create_vm shows the merged fields

Only way to reset it is to restart the netbox service

Expected Behavior

Only the fields for that specific script should show

Observed Behavior

Running of either script results in merging of the fields of both scripts.

This has also been verified on the mailing list

@DanSheps
Copy link
Member

DanSheps commented Jun 4, 2020

I am able to reproduce this on https://master.netbox.dev, however you need to run one script and then the other script to get the reject. If you just focus on one script there is no issue.

@DanSheps DanSheps added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Jun 4, 2020
@DanSheps
Copy link
Member

DanSheps commented Jun 4, 2020

from extras.scripts import StringVar, Script
class Test1(Script):
    class Meta:
        name = "Test 1"
        description = "Test some stuff"
        field_order = [
            'vm_name',
        ]

    vm_name = StringVar(label="VM Name")
    def run(self, data, commit):
        self.log_success("Done Test 1")


class Test2(Script):
    class Meta:
        name = "Test 2"
        description = "Test some stuff"
        field_order = [
            'switch_name'
        ]

    switch_name = StringVar(label="Switch Name")

    def run(self, data, commit):
        self.log_success("Done Test 2")

Reproducible with the following code, to simplify testing.

@mahomedh
Copy link
Author

mahomedh commented Jun 4, 2020

however you need to run one script and then the other script to get the reject.

Just to add to the above comment, you simply need to navigate to another script, then it's a bit random but it takes between 1 - 5 refreshes (without actually having to run the second script) to see the extra fields. The definite first step though is that you have to run one script then you cannot run any other script after that without a restart.

Please let me know if there's anything I can do to assist (including testing)

@jeremystretch jeremystretch self-assigned this Jun 15, 2020
@jeremystretch
Copy link
Member

This seems to be a byproduct of the change implemented under #4525 to allow scripts to accept initial data.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants