Skip to content

Commit

Permalink
Limit filtering match-all filter to DynamicGroups of group_type dynam… (
Browse files Browse the repository at this point in the history
#822)

* Limit filtering match-all filter to DynamicGroups of group_type dynamic-filter

Dynamic Groups of type dynamic-set have an empty filter, and were not being applied previously

* fix(helper.py): update dynamic group type filter to use DynamicGroupTypeChoices
  • Loading branch information
johanek authored Feb 4, 2025
1 parent e04e6c1 commit 260f4f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/706.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed filtering when using a dynamic group of groups
3 changes: 2 additions & 1 deletion nautobot_golden_config/utilities/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from nautobot.dcim.filters import DeviceFilterSet
from nautobot.dcim.models import Device
from nautobot.extras.models import Job
from nautobot.extras.choices import DynamicGroupTypeChoices
from nornir_nautobot.exceptions import NornirNautobotException

from nautobot_golden_config import config as app_config
Expand Down Expand Up @@ -70,7 +71,7 @@ def get_job_filter(data=None):

raw_qs = Q()
# If scope is set to {} do not loop as all devices are in scope.
if not models.GoldenConfigSetting.objects.filter(dynamic_group__filter__iexact="{}").exists():
if not models.GoldenConfigSetting.objects.filter(dynamic_group__filter__iexact="{}", dynamic_group__group_type=DynamicGroupTypeChoices.TYPE_DYNAMIC_FILTER).exists():
for obj in models.GoldenConfigSetting.objects.all():
raw_qs = raw_qs | obj.dynamic_group.generate_query()

Expand Down

0 comments on commit 260f4f5

Please sign in to comment.