-
Notifications
You must be signed in to change notification settings - Fork 263
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
DynamicGroups filter data migration from Site/Region to Location #3283
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks valid to me.
This makes me think that it would be a good feature for us to introduce something like a nautobot-server audit_dynamic_groups
command which would iterate over all DGs and make sure their filters are valid. Because we're not currently fixing up DGs to account for all of the other filtering changes that we're making in 2.0...
if "location" not in dg.filter.keys(): | ||
dg.filter["location"] = [] | ||
dg.filter["location"] += dg.filter.get("region", []) | ||
dg.filter.pop("region", None) | ||
if not dg.filter["location"]: # Remove the location key if the list is empty | ||
dg.filter.pop("location") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe?
if "region" in dg.filter:
dg.filter.setdefault("location", []).extend(dg.filter.pop("region"))
if not dg.filter["location"]: # Remove the location key if the list is empty | ||
dg.filter.pop("location") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these two lines be removed? Same question below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right right they should, I was thinking that "location" key might be an empty list, but we are already checking the "region" key to ensure the list wont be empty. Sorry!
Closes: #
What's Changed
TODO