ArnesSI / netbox-inventory

Manage your hardware inventory in NetBox
MIT License
215 stars 21 forks source link

Use ContactsMixin for Assets #162

Open alehaa opened 6 months ago

alehaa commented 6 months ago

Currently, an asset can only be assigned to one contact. In practice, however, an asset may have more than one contact, i.e. someone who is responsible for an asset and multiple users who have access to it. Thus, a contact-asset relationship can also have multiple types.

Therefore I ask to switch to the use of ContactsMixin, which has a consistent contact assignment as for the NetBox core models. This mixin class is not part of the official NetBox plugin API, but is already used in this plugin anyway, so there seems to be no overhead for maintenance.

NOTE: This feature request will result in an API breaking change, as an existing field will be removed. Also, it can't be migrated automatically, as required fields for contact mapping are currently missing and can't be determined automatically.

matejv commented 4 months ago

I agree this would make sense.

For migration I suppose we could create a ContactRole called something like InventoryAssetMigrated and use it for all existing asset contacts. Users can then go and rename this role or use bulk edit to assign a different one. Also role creation should only happen if any assets have contacts assigned at time of migration so we don't pollute ContactRoles if not needed...

Another breaking change is CSV import of assets. Currently import of assets can assign a contact as well (contact — name Contact using this asset. It must exist before import.). Also API will change.

rizlas commented 4 months ago

Therefore I ask to switch to the use of ContactsMixin, which has a consistent contact assignment as for the NetBox core models.

I had the same thought during the development of #185 . Add a tab with contacts, and handle contacts via assignment, will be the same user experience as other NetBox core parts.