support color attribute on module type and device type import and export #6762

Closed
opened 2025-12-29 19:45:08 +01:00 by adam · 4 comments
Owner

Originally created by @oasys on GitHub (Aug 2, 2022).

Originally assigned to: @oasys on GitHub.

NetBox version

v3.2.7

Feature type

Change to existing functionality

Proposed functionality

When importing module types via the web interface (Devices -> Module Types -> Import), allow specifying color attribute for front and rear ports. Also, when exporting module types via the web interface (Devices -> Module Types -> Export -> All Data (YAML)) include the color attribute for front and rear ports, if defined.

An example import file:

manufacturer: Generic
model: test-device
part_number: ''
comments: ''
front-ports:
- name: '1'
  type: lc
  rear_port: '1'
  rear_port_position: 1
  label: ''
  color: '3f51b5'
  description: ''
- name: '2'
  type: lc
  rear_port: '1'
  rear_port_position: 2
  label: ''
  color: '3f51b5'
  description: ''
rear-ports:
- name: '1'
  type: mpo
  positions: 2
  label: ''
  color: '000000'
  description: ''

Currently, it appears that the color field is ignored.

An export of that module type does not show the color.

manufacturer: Generic
model: test-device
part_number: ''
comments: ''
front-ports:
- name: '1'
  type: lc
  rear_port: '1'
  rear_port_position: 1
  label: ''
  description: ''
- name: '2'
  type: lc
  rear_port: '1'
  rear_port_position: 2
  label: ''
  description: ''
rear-ports:
- name: '1'
  type: mpo
  positions: 2
  label: ''
  description: ''

I see similar behavior with device types.

I'm not sure to consider this omission a bug or not, so am submitting as a FR.

Use case

It is useful to create a library of device type and module types outside of netbox for easy import into new installations. This would allow the inclusion of the color field in the objects in this library.

Database changes

none

External dependencies

none

Originally created by @oasys on GitHub (Aug 2, 2022). Originally assigned to: @oasys on GitHub. ### NetBox version v3.2.7 ### Feature type Change to existing functionality ### Proposed functionality When importing module types via the web interface (Devices -> Module Types -> Import), allow specifying `color` attribute for front and rear ports. Also, when exporting module types via the web interface (Devices -> Module Types -> Export -> All Data (YAML)) include the `color` attribute for front and rear ports, if defined. An example import file: ```yaml manufacturer: Generic model: test-device part_number: '' comments: '' front-ports: - name: '1' type: lc rear_port: '1' rear_port_position: 1 label: '' color: '3f51b5' description: '' - name: '2' type: lc rear_port: '1' rear_port_position: 2 label: '' color: '3f51b5' description: '' rear-ports: - name: '1' type: mpo positions: 2 label: '' color: '000000' description: '' ``` Currently, it appears that the `color` field is ignored. An export of that module type does not show the color. ```yaml manufacturer: Generic model: test-device part_number: '' comments: '' front-ports: - name: '1' type: lc rear_port: '1' rear_port_position: 1 label: '' description: '' - name: '2' type: lc rear_port: '1' rear_port_position: 2 label: '' description: '' rear-ports: - name: '1' type: mpo positions: 2 label: '' description: '' ``` I see similar behavior with device types. I'm not sure to consider this omission a bug or not, so am submitting as a FR. ### Use case It is useful to create a library of device type and module types outside of netbox for easy import into new installations. This would allow the inclusion of the color field in the objects in this library. ### Database changes none ### External dependencies none
adam added the status: acceptedtype: feature labels 2025-12-29 19:45:08 +01:00
adam closed this issue 2025-12-29 19:45:08 +01:00
Author
Owner

@oasys commented on GitHub (Aug 3, 2022):

I have some working changes.

https://github.com/oasys/netbox/tree/9906-support-color-on-frontrearport-import-export

If you want to assign to me, I will submit a PR.

@oasys commented on GitHub (Aug 3, 2022): I have some working changes. https://github.com/oasys/netbox/tree/9906-support-color-on-frontrearport-import-export If you want to assign to me, I will submit a PR.
Author
Owner

@oasys commented on GitHub (Aug 3, 2022):

#9911 submitted.

Should I also look at the other components, such as power ports (which I don't currently use) and others and add missing attributes? Or should we keep this change to only the color field for the front/rear ports as I originally submitted?

@oasys commented on GitHub (Aug 3, 2022): #9911 submitted. Should I also look at the other components, such as power ports (which I don't currently use) and others and add missing attributes? Or should we keep this change to only the color field for the front/rear ports as I originally submitted?
Author
Owner

@jeremystretch commented on GitHub (Aug 3, 2022):

Thanks @oasys! Let's keep this one confined to the color fields for front/rear ports. IIRC that's all that has been added recently, but if you find anything else missing an additional bug report would be much appreciated!

@jeremystretch commented on GitHub (Aug 3, 2022): Thanks @oasys! Let's keep this one confined to the color fields for front/rear ports. IIRC that's all that has been added recently, but if you find anything else missing an additional bug report would be much appreciated!
Author
Owner

@oasys commented on GitHub (Aug 3, 2022):

Agreed. FWIW, I just checked the to_yaml return values for the other component templates (ConsolePorts, ConsoleServerPorts, PowerPorts, PowerOutlets, and Interfaces), and I don't see anything else missing.

@oasys commented on GitHub (Aug 3, 2022): Agreed. FWIW, I just checked the `to_yaml` return values for the other component templates (ConsolePorts, ConsoleServerPorts, PowerPorts, PowerOutlets, and Interfaces), and I don't see anything else missing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6762