Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tenant and group uniqueness constraint if tenant belongs to a group #10374

Closed
abhi1693 opened this issue Sep 15, 2022 · 5 comments
Closed
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Milestone

Comments

@abhi1693
Copy link
Member

NetBox version

v3.2.2

Feature type

Change to existing functionality

Proposed functionality

Add unique_together for name and group on the Tenant model

Use case

I have a few end-users that have exact same name but they belong to different companies. We have modelled the companies as tenant groups on NetBox. I'd like to add two different people both named Tim to Company1 and Company2. In future, I could have another Tim who does not belong to any groups.

In all cases, I would like the validation by the group (if associated) just how contacts work.

We also use the tenant in our invoicing so adding a name like Tim 1 does not work for us as this would be reflected on the bill sent to the customer.

Adding the uniqueness constraint should not break anything existing either since it was not possible to have two Tims in the system anyhow.

Previously raised as bug #10373 but closed

Database changes

Add unique_together for name and group on the Tenant model

External dependencies

No response

@abhi1693 abhi1693 added the type: feature Introduction of new functionality to the application label Sep 15, 2022
@jeremystretch jeremystretch added the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Sep 15, 2022
@abhi1693
Copy link
Member Author

@ITJamie I'm not asking to disallow global unique. I'm instead asking to make the tenant scope limited to the group only if it has one. If the tenant does not have a group, then it should work the same way it is working now.

@kprince28
Copy link
Contributor

I have a similar issue where I'm trying to import data from our existing CMDB to our new NetBox installation. Today, I ran into the same issue wherein couple of my tenants though belong to different groups with different resources are not being added. I'm using REST APIs for perfomring the calls. I like the idea to limit the scope of the tenant into the group but also keep them unique if do not belong to any group.

If it's not possible, atleast remove the name uniqueness so that I can create my custom validator to implement my business logic.

@jeremystretch
Copy link
Member

jeremystretch commented Oct 3, 2022

Just a quick implementation note: Per #10361 all uniqueness constraints in NetBox v3.4+ are now being done using UniqueConstraint classes rather than unique_together. This actually makes it much easier to implement conditional logic, as we no longer need to add a custom validation method to the model.

@abhi1693
Copy link
Member Author

@jeremystretch Would the new implementation help in solving this issue in any way? If the core does not implement a solution, will I be able to override the conditional logic?

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions github-actions bot added the pending closure Requires immediate attention to avoid being closed for inactivity label Dec 11, 2022
@jeremystretch jeremystretch added needs milestone Awaiting prioritization for inclusion with a future NetBox release and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation pending closure Requires immediate attention to avoid being closed for inactivity labels Dec 27, 2022
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed needs milestone Awaiting prioritization for inclusion with a future NetBox release labels Jan 5, 2023
@jeremystretch jeremystretch added this to the v3.5 milestone Jan 5, 2023
@jeremystretch jeremystretch self-assigned this Mar 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

3 participants