Skip to content

Updating a Cable Termination over the API results in a missing connection/trace #15390

@Hedius

Description

@Hedius

Deployment Type

Self-hosted

NetBox Version

v3.7.3

Python Version

3.11

Steps to Reproduce

I only was able to identify issue #14200, #14137 (closed/rejected) as a similar problem.

The following steps are made for a clean empty netbox installation.

Initial setup

  1. Create a manufacturer (HPE in this case).

  2. Create a device type for that one. (ProLiant DL360 Gen11 in this case).

  3. Create a device/VM role (Server in this case).

  4. Create a site (DC1).

  5. Create 2 Servers with that role, site and type. (server001, server002).
    image

  6. Assign an interface (eth0 in this case) to both servers.

Create a cable between both

{
  "a_terminations": [
    {
      "object_type": "dcim.interface",
      "object_id": 1
    }
  ],
  "b_terminations": [
    {
      "object_type": "dcim.interface",
      "object_id": 2
    }
  ],
  "status": "connected"
}
curl -X 'POST' \
  'http://127.0.0.1:8000/api/dcim/cables/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "a_terminations": [
    {
      "object_type": "dcim.interface",
      "object_id": 1
    }
  ],
  "b_terminations": [
    {
      "object_type": "dcim.interface",
      "object_id": 2
    }
  ],
  "status": "connected"
}'

After this POST the interfaces are cabled and you can see the connection and link peers. 2 Terminations with the IDs (1,2) exist after this.
image

image

Add more interfaces to servers and change the cable in the GUI.

  1. Add eth1 to server002 (same config.
  2. Change the B termination for the cable from eth0 to eth1.
    image

The old termination is deleted, replaced with a new one, the connection is updated and you can trace the cable.
image

Now over the API, Delete termination B

  1. There is a similar issue from december: Path Status "Not Reachable" after edit cable terminaison by API #14137 (got closed, though)
  2. The person there updated the termination by patching the cable over api/dcim/cables.
  3. Both the changelog screenshot from above and @jeremystretch ´s comment show that the correct way is to delete the termination and create a new one.
  4. So delete the termination for cable 1 (server002 -> eth1) with a DELETE to /api/dcim/cable-terminations/3/
  5. curl -X 'DELETE' 'http://127.0.0.1:8000/api/dcim/cable-terminations/3/'

Create a new B termination for server002 -> eth0

post data

{
  "cable": 1,
  "cable_end": "B",
  "termination_type": "dcim.interface",
  "termination_id": 2
}
curl -X 'POST' \
  'http://127.0.0.1:8000/api/dcim/cable-terminations/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "cable": 1,
  "cable_end": "B",
  "termination_type": "dcim.interface",
  "termination_id": 2
}'

image

Cable and terminations have correct data (Skip this... issue after this one :) )

Data for both terminations and the cable looks correct.... nothing special.

{
    "count": 2,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "url": "http://127.0.0.1:8000/api/dcim/cable-terminations/1/",
            "display": "Cable #1 to eth0",
            "cable": 1,
            "cable_end": "A",
            "termination_type": "dcim.interface",
            "termination_id": 1,
            "termination": {
                "id": 1,
                "url": "http://127.0.0.1:8000/api/dcim/interfaces/1/",
                "display": "eth0",
                "device": {
                    "id": 1,
                    "url": "http://127.0.0.1:8000/api/dcim/devices/1/",
                    "display": "server001",
                    "name": "server001"
                },
                "name": "eth0",
                "cable": 1,
                "_occupied": true
            },
            "created": "2024-03-09T18:12:52.063515Z",
            "last_updated": "2024-03-09T18:12:52.063527Z"
        },
        {
            "id": 4,
            "url": "http://127.0.0.1:8000/api/dcim/cable-terminations/4/",
            "display": "Cable #1 to eth0",
            "cable": 1,
            "cable_end": "B",
            "termination_type": "dcim.interface",
            "termination_id": 2,
            "termination": {
                "id": 2,
                "url": "http://127.0.0.1:8000/api/dcim/interfaces/2/",
                "display": "eth0",
                "device": {
                    "id": 2,
                    "url": "http://127.0.0.1:8000/api/dcim/devices/2/",
                    "display": "server002",
                    "name": "server002"
                },
                "name": "eth0",
                "cable": 1,
                "_occupied": true
            },
            "created": "2024-03-09T18:33:25.250711Z",
            "last_updated": "2024-03-09T18:33:25.250729Z"
        }
    ]
}
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "url": "http://127.0.0.1:8000/api/dcim/cables/1/",
            "display": "#1",
            "type": "",
            "a_terminations": [
                {
                    "object_type": "dcim.interface",
                    "object_id": 1,
                    "object": {
                        "id": 1,
                        "url": "http://127.0.0.1:8000/api/dcim/interfaces/1/",
                        "display": "eth0",
                        "device": {
                            "id": 1,
                            "url": "http://127.0.0.1:8000/api/dcim/devices/1/",
                            "display": "server001",
                            "name": "server001"
                        },
                        "name": "eth0",
                        "cable": 1,
                        "_occupied": true
                    }
                }
            ],
            "b_terminations": [
                {
                    "object_type": "dcim.interface",
                    "object_id": 2,
                    "object": {
                        "id": 2,
                        "url": "http://127.0.0.1:8000/api/dcim/interfaces/2/",
                        "display": "eth0",
                        "device": {
                            "id": 2,
                            "url": "http://127.0.0.1:8000/api/dcim/devices/2/",
                            "display": "server002",
                            "name": "server002"
                        },
                        "name": "eth0",
                        "cable": 1,
                        "_occupied": true
                    }
                }
            ],
            "status": {
                "value": "connected",
                "label": "Connected"
            },
            "tenant": null,
            "label": "",
            "color": "",
            "length": null,
            "length_unit": null,
            "description": "",
            "comments": "",
            "tags": [],
            "custom_fields": {},
            "created": "2024-03-09T18:12:52.049438Z",
            "last_updated": "2024-03-09T18:19:21.528022Z"
        }
    ]
}

Connection is missing

However, in the server -> interfaces view, the connection is not listed anymore.
image

And you can no longer trace the cable.
image

image

Tracing over the API is also not possible at this point.

Summary

Correct me if I did smth wrong... But GUI actions cause the same actions and you suggested in #14200 to do it like this. Is this the correct way for updating cables?

Expected Behavior

  1. A cable should have a connection after deleting/creating its terminations over the API. (See the description from above.)

Observed Behavior

  1. After deleting and creating a new termination for a cable, it does not have a connection anymore.
    Both terminations are interfaces. Furthermore, you cannot trace the path anymore.

Metadata

Metadata

Assignees

Labels

netboxseverity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtopic: cablingtype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions