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

DynamicGroups filter data migration from Site/Region to Location #3283

Merged
merged 4 commits into from
Feb 10, 2023

Conversation

HanlinMiao
Copy link
Contributor

Closes: #

What's Changed

TODO

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • Attached Screenshots, Payload Example
  • Unit, Integration Tests
  • Documentation Updates (when adding/changing features)
  • Example Plugin Updates (when adding/changing features)
  • Outline Remaining Work, Constraints from Design

Copy link
Contributor

@glennmatthews glennmatthews left a 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...

Comment on lines 245 to 250
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")
Copy link
Contributor

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"))

Comment on lines 247 to 248
if not dg.filter["location"]: # Remove the location key if the list is empty
dg.filter.pop("location")
Copy link
Contributor

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.

Copy link
Contributor Author

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!

@HanlinMiao HanlinMiao merged commit 728e7be into next Feb 10, 2023
@bryanculver bryanculver deleted the hanlin-dynamic-group-data-migration branch February 14, 2023 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants