FrontPort count gets wrong when doing bulk create #10464

Closed
opened 2025-12-29 21:31:49 +01:00 by adam · 1 comment
Owner

Originally created by @blipnet on GitHub (Nov 11, 2024).

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.4

Python Version

3.12

Steps to Reproduce

  1. Create a DeviceType with FrontPorts
  2. Create a Device using the DeviceType
  3. Delete all FrontPorts, there are now zero FrontPorts
  4. Add the add_device_type_components.py script as custom script, https://github.com/netbox-community/customizations/blob/master/scripts/add_device_type_components.py
  5. Import DeviceType component via custom script.
  6. Check the Device, there is no tab for FronPorts due to "front_port_count" is 0
  7. If editing URL to get FrontPorts by appending /front-ports/ to URL you will see them
  8. If now deleting them again the number of FronPorts will now be a minus number

Expected Behavior

I expect the front_port_count should be related to the number of front ports on the device

Observed Behavior

Below is output from API for device

After running script

{
  < snip snip >

   "created": "2024-11-11T13:49:51.948244Z",
    "last_updated": "2024-11-11T13:49:51.948265Z",
    "console_port_count": 0,
    "console_server_port_count": 0,
    "power_port_count": 0,
    "power_outlet_count": 0,
    "interface_count": 0,
    "front_port_count": 0,
    "rear_port_count": 1,
    "device_bay_count": 0,
    "module_bay_count": 0,
    "inventory_item_count": 0
}

After deleting the front ports again

{
  < snip snip >

    "created": "2024-11-11T13:49:51.948244Z",
    "last_updated": "2024-11-11T13:49:51.948265Z",
    "console_port_count": 0,
    "console_server_port_count": 0,
    "power_port_count": 0,
    "power_outlet_count": 0,
    "interface_count": 0,
    "front_port_count": -16,
    "rear_port_count": 1,
    "device_bay_count": 0,
    "module_bay_count": 0,
    "inventory_item_count": 0
}

image

Originally created by @blipnet on GitHub (Nov 11, 2024). ### Deployment Type Self-hosted ### Triage priority N/A ### NetBox Version v4.1.4 ### Python Version 3.12 ### Steps to Reproduce 1. Create a DeviceType with FrontPorts 2. Create a Device using the DeviceType 3. Delete all FrontPorts, there are now zero FrontPorts 4. Add the add_device_type_components.py script as custom script, https://github.com/netbox-community/customizations/blob/master/scripts/add_device_type_components.py 5. Import DeviceType component via custom script. 6. Check the Device, there is no tab for FronPorts due to "front_port_count" is 0 7. If editing URL to get FrontPorts by appending /front-ports/ to URL you will see them 8. If now deleting them again the number of FronPorts will now be a minus number ### Expected Behavior I expect the front_port_count should be related to the number of front ports on the device ### Observed Behavior Below is output from API for device After running script ``` { < snip snip > "created": "2024-11-11T13:49:51.948244Z", "last_updated": "2024-11-11T13:49:51.948265Z", "console_port_count": 0, "console_server_port_count": 0, "power_port_count": 0, "power_outlet_count": 0, "interface_count": 0, "front_port_count": 0, "rear_port_count": 1, "device_bay_count": 0, "module_bay_count": 0, "inventory_item_count": 0 } ``` After deleting the front ports again ``` { < snip snip > "created": "2024-11-11T13:49:51.948244Z", "last_updated": "2024-11-11T13:49:51.948265Z", "console_port_count": 0, "console_server_port_count": 0, "power_port_count": 0, "power_outlet_count": 0, "interface_count": 0, "front_port_count": -16, "rear_port_count": 1, "device_bay_count": 0, "module_bay_count": 0, "inventory_item_count": 0 } ``` ![image](https://github.com/user-attachments/assets/195bcba4-c101-4d21-a32a-4a32110c278d)
adam closed this issue 2025-12-29 21:31:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 12, 2024):

We are unable to accept bug reports which rely on custom scripting to reproduce, as this does not necessarily indicate a bug in NetBox. If you'd like assistance with developing a custom script to avoid unwanted behavior, please open a discussion instead.

@jeremystretch commented on GitHub (Nov 12, 2024): We are unable to accept bug reports which rely on custom scripting to reproduce, as this does not necessarily indicate a bug in NetBox. If you'd like assistance with developing a custom script to avoid unwanted behavior, please open a [discussion](https://github.com/netbox-community/netbox/discussions/new?category=help-wanted) instead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10464