Error when creating a power outlet template via API #2853

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

Originally created by @tkupari on GitHub (Sep 5, 2019).

Environment

  • Python version: 3.7.4
  • NetBox version: 2.6.2

Steps to Reproduce

  1. Add device type "Model 1" in Netbox for "Some Manufacturer"
  2. Create power port named "pp1" for device type
  3. Attempt to create power outlet on device type by sending a POST request to /dcim/power-outlet-templates/ API

Data for creating a power outlet with reference to an existing power port:

{
  "device_type": 64,
  "name": "power outlet 1",
  "power_port": {
    "device_type": {
      "manufacturer": {
        "name": "Some Manufacturer",
        "slug": "some-manufacturer"
      },
      "model": "Model 1",
      "slug": "model-1"
    },
    "name": "pp1",
    "maximum_draw": 100,
    "allocated_draw": 100
  },
  "feed_leg": 1
}

Data for creating a power outlet with a reference to non-existing power port:

{
  "device_type": 64,
  "name": "power outlet 1",
  "power_port": {
    "device_type": {
      "manufacturer": {
        "name": "Some Manufacturer",
        "slug": "some-manufacturer"
      },
      "model": "Model 1",
      "slug": "model-1"
    },
    "name": "pp2",
    "maximum_draw": 100,
    "allocated_draw": 100
  },
  "feed_leg": 1
}

Expected Behavior

Power outlet template is created

Observed Behavior

When using existing power port name, status code 400 with following error

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

When using non-existing power port name, status code 500 with following error

<class 'ValueError'>

Cannot assign "OrderedDict([('device_type', <DeviceType: Model 1>), ('name', 'pp2'), ('maximum_draw', 100), ('allocated_draw', 100)])": "PowerOutletTemplate.power_port" must be a "PowerPortTemplate" instance.
Originally created by @tkupari on GitHub (Sep 5, 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.7.4 <!-- Example: 3.5.4 --> * NetBox version: 2.6.2 <!-- Example: 2.5.2 --> <!-- 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. Add device type "Model 1" in Netbox for "Some Manufacturer" 2. Create power port named "pp1" for device type 3. Attempt to create power outlet on device type by sending a POST request to /dcim/power-outlet-templates/ API Data for creating a power outlet with reference to an existing power port: ``` { "device_type": 64, "name": "power outlet 1", "power_port": { "device_type": { "manufacturer": { "name": "Some Manufacturer", "slug": "some-manufacturer" }, "model": "Model 1", "slug": "model-1" }, "name": "pp1", "maximum_draw": 100, "allocated_draw": 100 }, "feed_leg": 1 } ``` Data for creating a power outlet with a reference to non-existing power port: ``` { "device_type": 64, "name": "power outlet 1", "power_port": { "device_type": { "manufacturer": { "name": "Some Manufacturer", "slug": "some-manufacturer" }, "model": "Model 1", "slug": "model-1" }, "name": "pp2", "maximum_draw": 100, "allocated_draw": 100 }, "feed_leg": 1 } ``` <!-- What did you expect to happen? --> ### Expected Behavior Power outlet template is created <!-- What happened instead? --> ### Observed Behavior When using existing power port name, status code 400 with following error ``` { "power_port": { "non_field_errors": [ "The fields device_type, name must make a unique set." ] } } ```` When using non-existing power port name, status code 500 with following error ``` <class 'ValueError'> Cannot assign "OrderedDict([('device_type', <DeviceType: Model 1>), ('name', 'pp2'), ('maximum_draw', 100), ('allocated_draw', 100)])": "PowerOutletTemplate.power_port" must be a "PowerPortTemplate" instance. ```
adam closed this issue 2025-12-29 18:22:48 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 5, 2019):

Your description doesn't make sense. Are you trying to create a power port or a power outlet? They are different objects. Please post the exact steps you are taking.

@jeremystretch commented on GitHub (Sep 5, 2019): Your description doesn't make sense. Are you trying to create a power port or a power outlet? They are different objects. Please post the **exact** steps you are taking.
Author
Owner

@tkupari commented on GitHub (Sep 5, 2019):

I'm trying to create a power outlet that is connected to an existing power port template on the device type.

Here's a screen capture what I'm trying to do, but instead of using the UI, I'm using the API

image

@tkupari commented on GitHub (Sep 5, 2019): I'm trying to create a power outlet that is connected to an existing power port template on the device type. Here's a screen capture what I'm trying to do, but instead of using the UI, I'm using the API ![image](https://user-images.githubusercontent.com/631762/64350910-19a0ee80-d002-11e9-89c2-8151179044b1.png)
Author
Owner

@tkupari commented on GitHub (Sep 10, 2019):

Is there still something that can be done to clarify this issue?

@tkupari commented on GitHub (Sep 10, 2019): Is there still something that can be done to clarify this issue?
Author
Owner

@jeremystretch commented on GitHub (Sep 25, 2019):

Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided here. For general discussion, questions, or assistance with installation issues, please post to our mailing list instead.

@jeremystretch commented on GitHub (Sep 25, 2019): Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided [here](https://github.com/digitalocean/netbox/issues/new/choose). For general discussion, questions, or assistance with installation issues, please post to our [mailing list](https://groups.google.com/forum/#!forum/netbox-discuss) instead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2853