Add 'role' to Inventory Items #2528

Closed
opened 2025-12-29 18:19:40 +01:00 by adam · 14 comments
Owner

Originally created by @candlerb on GitHub (Apr 18, 2019).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.5.4
  • NetBox version: 2.3.6

Proposed Functionality

Add a "role" field to Inventory Items.

Use Case

  • To classify inventory items by function, e.g. "OS disk", "data disk", "hot spare"; and/or
  • To classify inventory items by type, e.g. "motherboard", "CPU", "RAM", "NIC"

Inventory items already have Tags, but the idea of using Tags for this was rejected in #3082

Database Changes

Add a "role_id" column to Inventory Item, which references device role. Make it nullable for backwards compatibility.

Probably want to add a new flag to dcim_devicerole to say whether it's usable on an inventory item (comparable to existing vm_role flag)

At this point it may also be worth having a flag to say whether the role is usable on Device (since I can imagine roles which are relevant to Inventory Item but not Device, and vice versa)

External Dependencies

None

Originally created by @candlerb on GitHub (Apr 18, 2019). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: 3.5.4 * NetBox version: 2.3.6 ### Proposed Functionality Add a "role" field to Inventory Items. ### Use Case * To classify inventory items by function, e.g. "OS disk", "data disk", "hot spare"; and/or * To classify inventory items by type, e.g. "motherboard", "CPU", "RAM", "NIC" Inventory items already have Tags, but the idea of using Tags for this was rejected in #3082 ### Database Changes Add a "role_id" column to Inventory Item, which references device role. Make it nullable for backwards compatibility. Probably want to add a new flag to `dcim_devicerole` to say whether it's usable on an inventory item (comparable to existing `vm_role` flag) At this point it may also be worth having a flag to say whether the role is usable on Device (since I can imagine roles which are relevant to Inventory Item but not Device, and vice versa) ### External Dependencies None
adam added the status: acceptedtype: feature labels 2025-12-29 18:19:40 +01:00
adam closed this issue 2025-12-29 18:19:40 +01:00
Author
Owner

@a31amit commented on GitHub (Apr 19, 2019):

This will be very useful but there would be a need to filter them by role in inventory items list view

@a31amit commented on GitHub (Apr 19, 2019): This will be very useful but there would be a need to filter them by role in inventory items list view
Author
Owner

@mmahacek commented on GitHub (Apr 19, 2019):

Reading the request, I was initially in support of this, but have since grown mixed feelings. I am abstaining from voting on this. Not against this idea, but wouldn't expect to use it on my server.

@mmahacek commented on GitHub (Apr 19, 2019): Reading the request, I was initially in support of this, but have since grown mixed feelings. I am abstaining from voting on this. Not against this idea, but wouldn't expect to use it on my server.
Author
Owner

@jeremystretch commented on GitHub (Apr 27, 2019):

Add a "role_id" column to Inventory Item, which references device role.

Wouldn't InventoryItem roles and Device roles generally by mutually exclusive of one another? E.g. a "router" can't be an InventoryItem and a "hard disk" can't be a Device.

Edit:

since I can imagine roles which are relevant to Inventory Item but not Device, and vice versa

Missed that. Can you provide some examples?

@jeremystretch commented on GitHub (Apr 27, 2019): > Add a "role_id" column to Inventory Item, which references device role. Wouldn't InventoryItem roles and Device roles generally by mutually exclusive of one another? E.g. a "router" can't be an InventoryItem and a "hard disk" can't be a Device. Edit: > since I can imagine roles which are relevant to Inventory Item but not Device, and vice versa Missed that. Can you provide some examples?
Author
Owner

@candlerb commented on GitHub (Apr 27, 2019):

I was just saying what you said more clearly: that in many (most? all?) cases, Inventory Item roles would not be relevant to Device, or vice versa.

So there could be a separate Inventory Item Roles list - but doing so would mean code duplication (e.g. for editing them, setting colours etc) and some menu clutter.

Are there any examples where the same role would apply to both? Probably not. Maybe "hot spare" - on a device that might be better managed by Status, although there isn't one exactly that matches that (there are "offline" and "planned")

@candlerb commented on GitHub (Apr 27, 2019): I was just saying what you said more clearly: that in many (most? all?) cases, Inventory Item roles would not be relevant to Device, or vice versa. So there could be a separate Inventory Item Roles list - but doing so would mean code duplication (e.g. for editing them, setting colours etc) and some menu clutter. Are there any examples where the same role would apply to both? Probably not. Maybe "hot spare" - on a device that might be better managed by Status, although there isn't one exactly that matches that (there are "offline" and "planned")
Author
Owner

@a31amit commented on GitHub (Apr 27, 2019):

Or this can be exposed only in ADMIN panel and Netbox Administrator can create them in advance.

@a31amit commented on GitHub (Apr 27, 2019): Or this can be exposed only in ADMIN panel and Netbox Administrator can create them in advance.
Author
Owner

@wols commented on GitHub (Jun 5, 2019):

My wish: add Inventory to 'Device Type - Status' = 'Parent/Child/Inventory status'

Reuse the 'Device Bay' logic...
...and update 'Editing device role' with 'VM Role/Inventory Role'.

So I could map the following:

  1. 'Add a new device type': select Manufacturer / Power Supply / Part number / 0U / Status Inventory
  2. Go to (non-racked/racked server) 'Device - Inventory - Add Inventory Item'
  3. 'Add a new inventory item': Name Power Supply 1 / select Manufacturer / Part from step '1.' / Serial number
  4. 'Add a new inventory item': Name Power Supply 2 / select Manufacturer / Part from step '1.' / Serial number

...two Power Supplies added to the server inventory - no more CopyPaste Part Numbers.

@candlerb The 'Inventory Item' dialog needs the 'Inventory Role' now. For my Power Supplies eg. master/slave, left/right, primary/secondary or top/bottom...

@wols commented on GitHub (Jun 5, 2019): My wish: add **Inventory** to 'Device Type - Status' = 'Parent/Child/**Inventory** status' Reuse the 'Device Bay' logic... ...and update 'Editing device role' with 'VM Role/**Inventory Role**'. So I could map the following: 1. 'Add a new device type': select Manufacturer / `Power Supply` / Part number / 0U / Status **Inventory** 2. Go to (non-racked/racked server) 'Device - Inventory - Add Inventory Item' 3. 'Add a new inventory item': Name `Power Supply 1` / select Manufacturer / Part from step '1.' / Serial number 4. 'Add a new inventory item': Name `Power Supply 2` / select Manufacturer / Part from step '1.' / Serial number ...two Power Supplies added to the server inventory - no more CopyPaste `Part Numbers`. @candlerb The 'Inventory Item' dialog needs the '_Inventory Role_' now. For my Power Supplies eg. `master/slave`, `left/right`, `primary/secondary` or `top/bottom`...
Author
Owner

@candlerb commented on GitHub (Jun 6, 2019):

I think what you want is instead to have Inventory Item Type (analagous to Device Type). This seems like a reasonable idea to me.

Devices cannot contain other Devices as Inventory Items, they are completely distinct types of objects.

@candlerb commented on GitHub (Jun 6, 2019): I think what you want is instead to have Inventory Item Type (analagous to Device Type). This seems like a reasonable idea to me. Devices cannot contain other Devices as Inventory Items, they are completely distinct types of objects.
Author
Owner

@a31amit commented on GitHub (Jun 14, 2019):

I believe making device roles to more generic could be good and another boolean similar to VM Role.

As of now, Devices and VirtualMachines are different models but shares the same Device Roles. We could have something similar flag inventory_item which can be assigned only to inventory items.

As in original request, it was proposed that roles could be a function or physical type.

@a31amit commented on GitHub (Jun 14, 2019): I believe making device roles to more generic could be good and another boolean similar to VM Role. As of now, Devices and VirtualMachines are different models but shares the same Device Roles. We could have something similar flag inventory_item which can be assigned only to inventory items. As in original request, it was proposed that roles could be a function or physical type.
Author
Owner

@hSaria commented on GitHub (Jan 2, 2020):

@jeremystretch I think this ticket can be closed as it is a duplicate of #3333

@hSaria commented on GitHub (Jan 2, 2020): @jeremystretch I think this ticket can be closed as it is a duplicate of #3333
Author
Owner

@jeremystretch commented on GitHub (Jan 2, 2020):

@hSaria The two proposals are related but different. Similar to the difference between the DeviceRole and DeviceType models.

@jeremystretch commented on GitHub (Jan 2, 2020): @hSaria The two proposals are related but different. Similar to the difference between the DeviceRole and DeviceType models.
Author
Owner

@hSaria commented on GitHub (Jan 2, 2020):

Ah. That makes more sense.

On 2 Jan 2020, at 6:12 pm, Jeremy Stretch notifications@github.com wrote:


@hSaria The two proposals are related but different. Similar to the difference between the DeviceRole and DeviceType models.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

@hSaria commented on GitHub (Jan 2, 2020): Ah. That makes more sense. > On 2 Jan 2020, at 6:12 pm, Jeremy Stretch <notifications@github.com> wrote: > >  > @hSaria The two proposals are related but different. Similar to the difference between the DeviceRole and DeviceType models. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub, or unsubscribe.
Author
Owner

@ibivibiv commented on GitHub (Apr 10, 2020):

FYI, both the typing and the role have been implemented in a fork here:

80943c7ab9

If we can get an actual issue up for this and get it accepted we can get this ball rolling? If we are deadlocked then maybe we build out something else in a companion app? I think it would be better to have this functionality built in rather than having to go around it just to track what a component inside a server is and its role?

@ibivibiv commented on GitHub (Apr 10, 2020): FYI, both the typing and the role have been implemented in a fork here: https://github.com/nmereddi/netbox/commit/80943c7ab9e07570be44d5e384917ddc9e04c4e1 If we can get an actual issue up for this and get it accepted we can get this ball rolling? If we are deadlocked then maybe we build out something else in a companion app? I think it would be better to have this functionality built in rather than having to go around it just to track what a component inside a server is and its role?
Author
Owner

@PieterL75 commented on GitHub (Oct 18, 2021):

Can we have the 'Inventory' also made part of the 'Device template' ?
At least to create the 'items' that can be in the inventory of a device, but also the option to put 'default' parts in the inventory.
Ex: MY switches have 4 fans. 2 psu and 2 empty slots... So the template would create 8 inventory items, with the fan and power models already populates but with the slots just empty items

@PieterL75 commented on GitHub (Oct 18, 2021): Can we have the 'Inventory' also made part of the 'Device template' ? At least to create the 'items' that can be in the inventory of a device, but also the option to put 'default' parts in the inventory. Ex: MY switches have 4 fans. 2 psu and 2 empty slots... So the template would create 8 inventory items, with the fan and power models already populates but with the slots just empty items
Author
Owner

@jeremystretch commented on GitHub (Dec 23, 2021):

Can we have the 'Inventory' also made part of the 'Device template' ?

FYI @PieterL75 opened #8118 for this. We may take this on as part of the related work already scheduled for v3.2.

@jeremystretch commented on GitHub (Dec 23, 2021): > Can we have the 'Inventory' also made part of the 'Device template' ? FYI @PieterL75 opened #8118 for this. We may take this on as part of the related work already scheduled for v3.2.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2528