API: Power Outlet Template Bug #3389

Closed
opened 2025-12-29 18:28:39 +01:00 by adam · 1 comment
Owner

Originally created by @minitriga on GitHub (Feb 24, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.7
  • NetBox version: 2.7.7

When creating a device type with the API adding a power outlet template to the device type produces errors.

Steps to Reproduce

  1. Create Device Type
  2. Add Power Port
  3. Adding a power outlet template via API with the minimum amount of information required works (name, device_type) but this does not create a power outlet that is related to a power port.
{
  "device_type": 297,
  "name": "1"
}
  1. Trying again on a new outlet number adding in the power_port information fails. Using the minimum amount of information required by the swagger API docs.
{
  "device_type": 297,
  "name": "2",
  "power_port": {
    "name": "Power Port",
    "device_type": {
      "model": "Test PDU",
      "slug": "test-pdu"
    }
  }
}

This produces the following error:

{
  "power_port": {
    "non_field_errors": [
      "The fields device_type, name must make a unique set."
    ]
  }
}

Expected Behavior

That a power outlet template is added to the database that is linked to a power port template for a device type.

Observed Behavior

Adding a power outlet fails as with the description following error:

{
  "power_port": {
    "non_field_errors": [
      "The fields device_type, name must make a unique set."
    ]
  }
}

I wonder if we could just use the ID of the power_port and make sure the power port is linked to the same device_type.

Thank you.

Originally created by @minitriga on GitHub (Feb 24, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: 3.7 * NetBox version: 2.7.7 When creating a device type with the API adding a power outlet template to the device type produces errors. <!-- 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. Create Device Type 2. Add Power Port 3. Adding a power outlet template via API with the minimum amount of information required works (name, device_type) but this does not create a power outlet that is related to a power port. ``` { "device_type": 297, "name": "1" } ``` 4. Trying again on a new outlet number adding in the power_port information fails. Using the minimum amount of information required by the swagger API docs. ``` { "device_type": 297, "name": "2", "power_port": { "name": "Power Port", "device_type": { "model": "Test PDU", "slug": "test-pdu" } } } ``` This produces the following error: ``` { "power_port": { "non_field_errors": [ "The fields device_type, name must make a unique set." ] } } ``` <!-- What did you expect to happen? --> ### Expected Behavior That a power outlet template is added to the database that is linked to a power port template for a device type. <!-- What happened instead? --> ### Observed Behavior Adding a power outlet fails as with the description following error: ``` { "power_port": { "non_field_errors": [ "The fields device_type, name must make a unique set." ] } } ``` I wonder if we could just use the ID of the power_port and make sure the power port is linked to the same device_type. Thank you.
adam added the type: bugstatus: accepted labels 2025-12-29 18:28:39 +01:00
adam closed this issue 2025-12-29 18:28:39 +01:00
Author
Owner

@jeremystretch commented on GitHub (Feb 24, 2020):

{
  "device_type": 297,
  "name": "2",
  "power_port": {
    "name": "Power Port"
  }
}

The above should be all you need to create a new power outlet template on a device type. (Note that you could optionally use a dictionary specifying the device type manufacturer and model instead of its primary key if you prefer.) The commit pushed above should resolve this.

@jeremystretch commented on GitHub (Feb 24, 2020): ``` { "device_type": 297, "name": "2", "power_port": { "name": "Power Port" } } ``` The above should be all you need to create a new power outlet template on a device type. (Note that you could optionally use a dictionary specifying the device type manufacturer and model instead of its primary key if you prefer.) The commit pushed above should resolve this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3389