Update jobs.py to support Dynamic Groups#378
Conversation
Added support for Dynamic Groups into the Sync Data from Network Job.
|
Thank you for your contribution! We plan to review and merge this shortly. As an alternative to Dynamic Groups that you have added, we are also considering a change of default behavior: to sync devices from all the child locations of a location, which may also address your requirement. |
|
Thanks scetron, Hold this for a day or so. I found an issue I need to address last night and haven't had time to fix it. The Child Locations would help as well. I can see a reason to support both. I could see where you might have dynamic groups of locations w/ specific types of devices or other criteria than just location. |
|
Hello @jdpfda ! Were you able to get a fix in for the issue you found? If not, you can provide the issue and we can also take a look. |
| device_filter["platform"] = platform | ||
| if device_filter: # prevent all devices from being returned by an empty filter | ||
| self.filtered_devices = Device.objects.filter(**device_filter) | ||
| if self.dynamic_group: |
There was a problem hiding this comment.
@scetron I think this needs to set self.filtered_devices instead of device_filter
There was a problem hiding this comment.
Actually maybe it should be moved up 2 lines
Added support for Dynamic Groups into the Sync Data from Network Job.
Closes: #375
What's Changed
Added the ability to use a dynamic group for the Sync Data from Network job.
Changes:
32 + DynamicGroup,
...
646 + dynamic_group = ObjectVar(
647 + model=DynamicGroup,
648 + required=False,
649 + description="Only update devices that belong to this Dynamic Group.",
650 + )
...
677 + dynamic_group,
...
697 + self.dynamic_group = dynamic_group
...
738 + if self.dynamic_group:
739 + # Get all Device IDs in that DynamicGroup
740 + group_device_ids = self.dynamic_group.members.values_list("id", flat=True)
741 + # Overwrite (or set) the id__in filter so we only get devices in that group
742 + device_filter["id__in"] = list(group_device_ids)
To Do
N/A