1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Initial work on #93: Primary IPv4/IPv6 support

This commit is contained in:
Jeremy Stretch
2016-07-11 16:24:46 -04:00
parent f617828712
commit 4e4bb01a55
16 changed files with 203 additions and 45 deletions

View File

@ -314,12 +314,20 @@ class IPAddress(CreatedUpdatedModel):
super(IPAddress, self).save(*args, **kwargs)
def to_csv(self):
# Determine if this IP is primary for a Device
is_primary = False
if self.family == 4 and getattr(self, 'primary_ip4_for', False):
is_primary = True
elif self.family == 6 and getattr(self, 'primary_ip6_for', False):
is_primary = True
return ','.join([
str(self.address),
self.vrf.rd if self.vrf else '',
self.device.identifier if self.device else '',
self.interface.name if self.interface else '',
'True' if getattr(self, 'primary_for', False) else '',
'True' if is_primary else '',
self.description,
])