Update fhrp.py

add Descriotion to the fhrp Group Name
This commit is contained in:
jlebherz 2022-01-23 22:35:44 +01:00 committed by GitHub
parent 69eb6b11d0
commit 64dea8a780
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,13 +59,18 @@ class FHRPGroup(PrimaryModel):
name = f'{self.get_protocol_display()}: {self.group_id}'
# Append the first assigned IP addresses (if any) to serve as an additional identifier
# If present add the Description
if self.pk:
ip_address = self.ip_addresses.first()
if ip_address:
if self.description:
return f"{name} ({self.description}) ({ip_address})"
return f"{name} ({ip_address})"
if self.description:
return f"{name} ({self.description})"
return name
def get_absolute_url(self):
return reverse('ipam:fhrpgroup', args=[self.pk])