custom script example NewBranchScript can not select switch_model #3100

Closed
opened 2025-12-29 18:25:38 +01:00 by adam · 4 comments
Owner

Originally created by @bybai on GitHub (Dec 30, 2019).

Environment

  • Python version: 3.6
  • NetBox version: 2.6.9

Steps to Reproduce

  1. copy example NewBranchScript in /opt/netbox/netbox/scripts
  2. open http://127.0.0.1:11111/extras/scripts/example/NewBranchScript/
  3. I cannot select switch model, the switch model is "--------------"

Expected Behavior

expect show correct switch model.

Observed Behavior

屏幕快照 2019-12-30 下午3 32 09
Originally created by @bybai on GitHub (Dec 30, 2019). <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.6 * NetBox version: 2.6.9 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a wrapper like pynetbox. --> ### Steps to Reproduce 1. copy example NewBranchScript in /opt/netbox/netbox/scripts 2. open http://127.0.0.1:11111/extras/scripts/example/NewBranchScript/ 3. I cannot select switch model, the switch model is "--------------" <!-- What did you expect to happen? --> ### Expected Behavior expect show correct switch model. <!-- What happened instead? --> ### Observed Behavior <img width="1074" alt="屏幕快照 2019-12-30 下午3 32 09" src="https://user-images.githubusercontent.com/6743951/71572453-31086800-2b1a-11ea-8e18-365d917206d6.png">
adam closed this issue 2025-12-29 18:25:38 +01:00
Author
Owner

@MathijsVanWilligen commented on GitHub (Dec 30, 2019):

did you have modified the "manufacturer_name" and the "model_in" parameters to your manufacturer/models?

switch_model = ObjectVar(
    description="Access switch model",
    queryset = DeviceType.objects.filter(
        manufacturer__name='<your manufacturer name>',
        model__in=['<your models>']
    )
)
@MathijsVanWilligen commented on GitHub (Dec 30, 2019): did you have modified the "manufacturer_name" and the "model_in" parameters to your manufacturer/models? switch_model = ObjectVar( description="Access switch model", queryset = DeviceType.objects.filter( manufacturer__name='<your manufacturer name>', model__in=['<your models>'] ) )
Author
Owner

@bybai commented on GitHub (Dec 30, 2019):

Hi @MathijsVanWilligen,
My code is

    switch_model = ObjectVar(
        description="Access switch model",
        queryset = DeviceType.objects.filter(
            manufacturer__name='Cisco',
            model__in=['Catalyst 3560X-48T', 'Catalyst 3750X-48T']
        )
    )

I used example from https://netbox.readthedocs.io/en/stable/additional-features/custom-scripts/

@bybai commented on GitHub (Dec 30, 2019): Hi @MathijsVanWilligen, My code is ``` switch_model = ObjectVar( description="Access switch model", queryset = DeviceType.objects.filter( manufacturer__name='Cisco', model__in=['Catalyst 3560X-48T', 'Catalyst 3750X-48T'] ) ) ``` I used example from https://netbox.readthedocs.io/en/stable/additional-features/custom-scripts/
Author
Owner

@MathijsVanWilligen commented on GitHub (Dec 30, 2019):

hi @bybai,
I apologize if I don't understand your question correctly but when you don't have an "Cisco" manufacturer type in your netbox envrionment with one of these models: "Catalyst 3560X-48T", "Catalyst 3750X-48T", you can't select other types. (i think)

for example: if you have an Cisco C1117-4P router you have to create this type in netbox under the Cisco manufacturer type, and add "C1117-4P" into the 'model__in' parameter ->
model__in=['Catalyst 3560X-48T', 'Catalyst 3750X-48T', 'C1117-4P'].

i hope this helps you.

@MathijsVanWilligen commented on GitHub (Dec 30, 2019): hi @bybai, I apologize if I don't understand your question correctly but when you don't have an "Cisco" manufacturer type in your netbox envrionment with one of these models: "Catalyst 3560X-48T", "Catalyst 3750X-48T", you can't select other types. (i think) for example: if you have an Cisco C1117-4P router you have to create this type in netbox under the Cisco manufacturer type, and add "C1117-4P" into the 'model__in' parameter -> ` model__in=['Catalyst 3560X-48T', 'Catalyst 3750X-48T', 'C1117-4P']`. i hope this helps you.
Author
Owner

@bybai commented on GitHub (Dec 30, 2019):

@MathijsVanWilligen,
It works, after I added 'device type'. Now I knew 'device type' is 'model__in'. Thanks.

@bybai commented on GitHub (Dec 30, 2019): @MathijsVanWilligen, It works, after I added 'device type'. Now I knew 'device type' is 'model__in'. Thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3100