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]: Cable Connection Not created #927

Closed
joaofeteira opened this issue Jan 19, 2023 · 8 comments
Closed

[Bug]: Cable Connection Not created #927

joaofeteira opened this issue Jan 19, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@joaofeteira
Copy link

Ansible NetBox Collection version

v3,9,0

Ansible version

ansible [core 2.13.7]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/xxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/xxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
  jinja version = 3.0.3
  libyaml = True

NetBox version

v3.4.2

Python version

3.10

Steps to Reproduce

Hi,

I am trying to create a cable connection between two devices with this code:

- name: Creating Netbox Cable Connections
  netbox.netbox.netbox_cable:
    netbox_url: "{{ netbox_url }}"
    netbox_token: "{{ netbox_api_token }}"
    data:
      termination_a_type: "{{ item.termination_a_type }}"
      termination_a:
        device: "{{ item.termination_a_device }}"
        name: "{{ item.termination_a_interface_name }}"
      termination_b_type: "{{ item.termination_b_type }}"
      termination_b:
        device: "{{ item.termination_b_device }}"
        name: "{{ item.termination_b_interface_name }}"
      type: "{{ item.type }}"
  loop:
    - { termination_a_type: dcim.interface, termination_a_device: DEVICE1, termination_a_interface_name: fast0/33, termination_b_type: dcim.interface, termination_b_device: DEVICE2, termination_b_interface_name: oc3-s2-p1, type: cat6 }

But the cable connection is not created and instead throwing this error:

failed: [localhost] (item={'termination_a_type': 'dcim.interface', 'termination_a_device': 'DEVICE1', 'termination_a_interface_name': 'fast0/33',
│ 'termination_b_type': 'dcim.interface', 'termination_b_device': 'DEVICE2', 'termination_b_interface_name': 'oc3-s2-p1', 'type': 'cat6'}) => {"ansible_loop_var":
│ "item", "changed": false, "item": {"termination_a_device": "DEVICE1", "termination_a_interface_name": "fast0/33", "termination_a_type": "dcim.interface",
│ "termination_b_device": "DEVICE2", "termination_b_interface_name": "oc3-s2-p1", "termination_b_type": "dcim.interface", "type": "cat6"}, "msg": "\n<!DOCTYPE
│ html>\n<html lang=\"en\">\n\n<head>\n    <title>Server Error</title>\n    <link rel=\"stylesheet\" href=\"/static/netbox-light.css\" />\n    <meta
│ charset=\"UTF-8\">\n</head>\n\n<body>\n    <div class=\"container-fluid\">\n        <div class=\"row\">\n            <div class=\"col col-md-6 offset-md-3\">\n                <div
│ class=\"card border-danger mt-5\">\n                    <h5 class=\"card-header\">\n                        <i class=\"mdi mdi-alert\"></i> Server Error\n
│ </h5>\n                    <div class=\"card-body\">\n                        \n                            <p>\n                                There was a problem with your
│ request. Please contact an administrator.\n                            </p>\n                        \n                        <hr />\n                        <p>\n
│ The complete exception is provided below:\n                        </p>\n<pre class=\"block\"><strong>&lt;class &#x27;ValueError&#x27;&gt;</strong><br />\n&#x27;Cable&#x27;
│ instance needs to have a primary key value before this relationship can be used.\n\nPython version: 3.10.6\nNetBox version: 3.4.2</pre>\n                        <p>\n
│ If further assistance is required, please post to the <a href=\"https://github.com/netbox-community/netbox/discussions\">NetBox discussion forum</a> on GitHub.\n
│ </p>\n                        <div class=\"text-end\">\n                            <a href=\"/\" class=\"btn btn-primary\">Home Page</a>\n                        </div>\n
│ </div>\n                </div>\n            </div>\n        </div>\n    </div>\n</body>\n\n</html>\n"}
│ 

Any tips?

Thanks
BR

Expected Behavior

Expeceted the cable connection to be created.

Observed Behavior

Error

@joaofeteira joaofeteira added the bug Something isn't working label Jan 19, 2023
@sc68cal
Copy link
Contributor

sc68cal commented Jan 19, 2023

This might be a bug in Netbox 3.4.2 - there is a fix for this error in upstream that has not been released yet, but I am not 100% sure so I am not linking directly to it https://github.com/netbox-community/netbox/pull/11231

@joaofeteira joaofeteira changed the title [Bug]: [Bug]: Cable Connection Not created Jan 20, 2023
@joaofeteira
Copy link
Author

thanks for the tip, is there any way for me to quickly test it since i am using the docker compose method to launch it:

version: '3.4'
services:
netbox:
restart: unless-stopped
ports:
- 8000:8080
netbox-worker:
restart: unless-stopped
netbox-housekeeping:
restart: unless-stopped
postgres:
restart: unless-stopped
redis:
restart: unless-stopped
redis-cache:
restart: unless-stopped

@sc68cal
Copy link
Contributor

sc68cal commented Jan 20, 2023

If you are using the netbox-docker repo there is a way to build it via the included build.sh script and apply the PR

@ThomasADavis
Copy link
Contributor

Cable creation api changed from v3.2 to v3.3 and new netbox instances. To the best of my knowledge, the netbox_cable module has not been updated to use the newer api.

@joaofeteira
Copy link
Author

thanks !

@sc68cal
Copy link
Contributor

sc68cal commented Jan 24, 2023

Cable creation api changed from v3.2 to v3.3 and new netbox instances. To the best of my knowledge, the netbox_cable module has not been updated to use the newer api.

Correct, it is a breaking API change that requires us to do some work to support both the old API and new API in the module, based on which netbox API version the module is talking to

andrii-konts added a commit to thg-openstack/netbox_ansible_modules that referenced this issue Feb 10, 2023
andrii-konts added a commit to thg-openstack/netbox_ansible_modules that referenced this issue Feb 10, 2023
andrii-konts added a commit to thg-openstack/netbox_ansible_modules that referenced this issue Feb 10, 2023
@rodvand
Copy link
Contributor

rodvand commented Feb 12, 2023

Should be fixed in collection 3.11.0.

@rodvand rodvand closed this as completed Feb 12, 2023
@joaofeteira
Copy link
Author

It is indeed. Thanks a lot.

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

4 participants