Skip to content

Commit

Permalink
in netbox 3.6 device.device_role changed to device.role
Browse files Browse the repository at this point in the history
  • Loading branch information
matejv committed Oct 24, 2023
1 parent f2d49f3 commit b22319d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion netbox_powerdns_sync/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def get_addresses(self):
query_zone |= Q(interface__device__tags__in=self.zone.match_device_tags.all())
query_zone |= Q(vminterface__virtual_machine__tags__in=self.zone.match_device_tags.all())
query_zone |= Q(fhrpgroup__tags__in=self.zone.match_fhrpgroup_tags.all())
query_zone |= Q(interface__device__device_role__in=self.zone.match_device_roles.all())
query_zone |= Q(interface__device__role__in=self.zone.match_device_roles.all())
query_zone |= Q(vminterface__virtual_machine__role__in=self.zone.match_device_roles.all())
results = IPAddress.objects.filter(query_zone)
if self.zone.match_interface_mgmt_only:
Expand Down
9 changes: 2 additions & 7 deletions netbox_powerdns_sync/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,10 @@ def filter_mgmt_only(zones, ip):
zones = filter_mgmt_only(zones, ip)
if zones:
return zones
# role or device_role
host = get_ip_host(ip)
role = None
# try: Device.device_role, VirtualMachine.role
for role_name in ("device_role", "role"):
try:
role = getattr(host, role_name)
except AttributeError:
continue
if host:
role = host.role
if role:
zones = cls.objects.filter(match_device_roles__in=[role])
zones = filter_mgmt_only(zones, ip)
Expand Down

0 comments on commit b22319d

Please sign in to comment.