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

Nautobot Status and other persisted objects should use uuid.uuid5 to generate ids #1809

Closed
retnuh opened this issue May 25, 2022 · 2 comments · Fixed by #2221
Closed

Nautobot Status and other persisted objects should use uuid.uuid5 to generate ids #1809

retnuh opened this issue May 25, 2022 · 2 comments · Fixed by #2221
Labels
type: feature Introduction of new or enhanced functionality to the application type: housekeeping Changes to the application which do not directly impact the end user

Comments

@retnuh
Copy link

retnuh commented May 25, 2022

Environment

  • Python version: N/A
  • Nautobot version: All 1.x

Steps to Reproduce

  1. Use nautobot-server dumpdata to create a fixture
  2. Watch your fixture explode on already existing Status objects!

Expected Behaviour

It would be great if Status and other pre-populated objects in Nautobot used uud.uuid5 to generate the IDs in a deterministic way. It would be double nice if there were a migration to update existing DBs to the new UUID but maintain existing relationships.

Here's a small example of what uuid.uuid5 might look like:

>>> import uuid
>>> uuid.uuid5(uuid.NAMESPACE_URL, "urn:x-nautobot-uuid:Status:Active")
UUID('aedc8cd9-d0d2-5ad7-8fc3-11615d39402e')

Obviously the specifics of the name and namespace used are up to you guys. I don't think you'd have to go to the trouble of registering a urn namespace or anything, what's important is avoiding clashes with other applications.

The advantage of this would be that dump'd db's for test fixtures would be consistent without having to jump through hoops (for example, we delete the existing pre-populated objects in an override of setUpClass in test classes).

cc @jvanderaa @PhillSimonds

@glennmatthews glennmatthews added type: housekeeping Changes to the application which do not directly impact the end user type: feature Introduction of new or enhanced functionality to the application labels May 25, 2022
@glennmatthews
Copy link
Contributor

Thanks for the request!

An alternate approach we've discussed in the past would be to add support for natural_key and get_by_natural_key to Status and various other classes - with this added we could probably use dumpdata --natural-foreign --natural-primary to avoid the UUID issue altogether.

@retnuh
Copy link
Author

retnuh commented May 25, 2022

That sounds good too!

@bryanculver bryanculver mentioned this issue Aug 8, 2022
1 task
jathanism added a commit that referenced this issue Aug 19, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature Introduction of new or enhanced functionality to the application type: housekeeping Changes to the application which do not directly impact the end user
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants