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

[Bug]: netbox_cable fails on circuits with multiple terminations #1328

Open
DustinWi opened this issue Sep 26, 2024 · 0 comments
Open

[Bug]: netbox_cable fails on circuits with multiple terminations #1328

DustinWi opened this issue Sep 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@DustinWi
Copy link

DustinWi commented Sep 26, 2024

Ansible NetBox Collection version

v3.19.1

Ansible version

ansible [core 2.17.4]
  config file = None
  configured module search path = ['/home/dustin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']        
  ansible python module location = /home/dustin/projects/netbox/.venv/lib/python3.12/site-packages/ansible
  ansible collection location = /home/dustin/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/dustin/projects/netbox/.venv/bin/ansible
  python version = 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] (/home/dustin/projects/netbox/.venv/bin/python3)
  jinja version = 3.1.4
  libyaml = True

NetBox version

v4.0.11 netbox-enterprise

Python version

3.11

Steps to Reproduce

  • Create a circuit
  • Create "A" side termination for the circuit to a Site
  • Create "Z" side termination for the circuit to a Provider Network
  • Try to use use netbox_cable module to create a cable from a Device interface to circuit

Sample Playbook

---
- name: ========================= SETUP NETBOX
  hosts: netbox
  gather_facts: no
  connection: local
  vars:
    netbox_token: "{{ lookup('ansible.builtin.env', 'NETBOX_TOKEN') }}" 
  
  tasks:
    - name: ========================= CIRCUIT
      netbox.netbox.netbox_circuit:
        netbox_url: "https://{{ inventory_hostname }}"
        netbox_token: "{{ netbox_token }}"
        data:
          cid: Circuit1
          circuit_type: Residential ISP
          commit_rate: 200000
          description: ISP Connection
          provider: Breezeline
          status: Active
        validate_certs: no
        state: present
    - name: ========================= CIRCUIT TERMINATION WALL JACK
      netbox.netbox.netbox_circuit_termination:
        netbox_url: "https://{{ inventory_hostname }}"
        netbox_token: "{{ netbox_token }}"
        data: 
          circuit: Circuit1
          description: Patch Panel
          port_speed: 200000
          pp_info: Attic Wall jack
          site: Site1
          term_side: A
          upstream_speed: 20000
        validate_certs: no
        state: present
    - name: ========================= CIRCUIT TERMINATION PROVIDER NETWORK
      netbox.netbox.netbox_circuit_termination:
        netbox_url: "https://{{ inventory_hostname }}"
        netbox_token: "{{ netbox_token }}"
        data: 
          circuit: Circuit1
          description: ISP
          port_speed: 200000
          term_side: Z
          upstream_speed: 20000
          provider_network: Breezeline Residential
        validate_certs: no
        state: present
    - name: ========================= CIRCUIT TERMINATION CABLE TO DEVICE
      netbox.netbox.netbox_cable:
        netbox_url: "https://{{ inventory_hostname }}"
        netbox_token: "{{ netbox_token }}"
        data:
          description: Router 1 - Gi0/0/1
          type: cat5e
          status: connected
          termination_a_type: dcim.interface
          termination_a:
            device: Router 1
            name: GigabitEthernet0/0/1
          termination_b_type: circuits.circuittermination
          termination_b:
            circuit: Circuit1
        validate_certs: no
        state: present

Expected Behavior

All tasks complete OK or CHANGED and a cable is created in Netbox.

Observed Behavior

Results

PLAY [========================= SETUP NETBOX ] ******************************************************************************************************************

TASK [========================= CIRCUIT ] ***********************************************************************************************************************
ok: [netbox.local]

TASK [========================= CIRCUIT TERMINATION WALL JACK ] *************************************************************************************************
ok: [netbox.local]

TASK [========================= CIRCUIT TERMINATION PROVIDER NETWORK ] ******************************************************************************************
ok: [netbox.local]

TASK [========================= CIRCUIT TERMINATION CABLE TO DEVICE ] *******************************************************************************************
fatal: [netbox.local]: FAILED! => {"changed": false, "msg": "More than one result returned for termination_b"}

PLAY RECAP *******************************************************************************************************************************************************************************
netbox.local : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Final task with verbosity enabled

The full traceback is:
  File "/tmp/ansible_netbox.netbox.netbox_cable_payload_kpl3s3dx/ansible_netbox.netbox.netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", l
ine 797, in _nb_endpoint_get
    response = nb_endpoint.get(**query_params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dustin/projects/netbox/.venv/lib/python3.12/site-packages/pynetbox/core/endpoint.py", line 167, in get
    raise ValueError(
fatal: [netbox.local]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "cert": null,
            "data": {
                "color": null,
                "comments": null,
                "custom_fields": null,
                "description": "Router 1 - Gi0/0/1",
                "label": null,
                "length": null,
                "length_unit": null,
                "status": "connected",
                "tags": null,
                "tenant": null,
                "termination_a": {
                    "device": "Router 1",
                    "name": "GigabitEthernet0/0/1"
                },
                "termination_a_type": "dcim.interface",
                "termination_b": {
                    "circuit": "Circuit1"
                },
                "termination_b_type": "circuits.circuittermination",
                "type": "cat5e"
            },
            "netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "netbox_url": "https://netbox.local",
            "query_params": null,
            "state": "present",
            "validate_certs": false
        }
    },
    "msg": "More than one result returned for termination_b"
}
@DustinWi DustinWi added the bug Something isn't working label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant