1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00

refactor renumber ip space tool (#305, #304, #303)

This commit is contained in:
Stefan Pratter
2019-05-02 18:28:35 +00:00
parent 01d856e424
commit df8e54e5a8
7 changed files with 266 additions and 96 deletions

View File

@@ -2328,6 +2328,26 @@ class NetworkIXLan(pdb_models.NetworkIXLanBase):
if errors:
raise ValidationError(errors)
def ipaddr(self, version):
"""
Return the netixlan's ipaddr for ip version
"""
if version == 4:
return self.ipaddr4
elif version == 6:
return self.ipaddr6
raise ValueError("Invalid ip version {}".format(version))
def descriptive_name_ipv(self, version):
"""
Returns a descriptive label of the netixlan for logging purposes
Will only contain the ipaddress matching the specified version
"""
return "netixlan{} AS{} {}".format(
self.id, self.asn, self.ipaddr(version))
class User(AbstractBaseUser, PermissionsMixin):
"""