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:
@ -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,
|
||||
])
|
||||
|
||||
|
Reference in New Issue
Block a user