aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Elkins <melkins@tislabs.com>2012-11-08 00:58:12 +0000
committerMichael Elkins <melkins@tislabs.com>2012-11-08 00:58:12 +0000
commit2666ee252bb137cc230de17755237fa78caa4aa3 (patch)
treea0012665e00d8904a83aa9a3bb0fd180c6e25c58
parent07d445862b681755d87a693c70d25e6bc75c8f78 (diff)
to_bytes -> toBytes, from_bytes -> fromBytes to match the rpki.POW.IPAddress API
pep8 formatting fixes svn path=/branches/tk274/; revision=4809
-rw-r--r--rpkid/rpki/gui/models.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/rpkid/rpki/gui/models.py b/rpkid/rpki/gui/models.py
index 3f601f7c..d9fc4e81 100644
--- a/rpkid/rpki/gui/models.py
+++ b/rpkid/rpki/gui/models.py
@@ -18,13 +18,12 @@ PERFORMANCE OF THIS SOFTWARE.
Common classes for reuse in apps.
"""
-import struct
-
from django.db import models
import rpki.resource_set
import rpki.POW
+
class IPv6AddressField(models.Field):
"Field large enough to hold a 128-bit unsigned integer."
@@ -36,10 +35,11 @@ class IPv6AddressField(models.Field):
def to_python(self, value):
if isinstance(value, rpki.POW.IPAddress):
return value
- return rpki.POW.IPAddress.from_bytes(value)
+ return rpki.POW.IPAddress.fromBytes(value)
def get_db_prep_value(self, value, connection, prepared):
- return value.to_bytes()
+ return value.toBytes()
+
class IPv4AddressField(models.Field):
"Wrapper around rpki.POW.IPAddress."
@@ -52,11 +52,12 @@ class IPv4AddressField(models.Field):
def to_python(self, value):
if isinstance(value, rpki.POW.IPAddress):
return value
- return rpki.POW.IPAddress(value)
+ return rpki.POW.IPAddress(value, version=4)
def get_db_prep_value(self, value, connection, prepared):
return long(value)
+
class Prefix(models.Model):
"""Common implementation for models with an IP address range.
@@ -84,10 +85,11 @@ class Prefix(models.Model):
class Meta:
abstract = True
-
+
# default sort order reflects what "sh ip bgp" outputs
ordering = ('prefix_min',)
+
class PrefixV4(Prefix):
"IPv4 Prefix."
@@ -99,6 +101,7 @@ class PrefixV4(Prefix):
class Meta(Prefix.Meta):
abstract = True
+
class PrefixV6(Prefix):
"IPv6 Prefix."
@@ -110,6 +113,7 @@ class PrefixV6(Prefix):
class Meta(Prefix.Meta):
abstract = True
+
class ASN(models.Model):
"""Represents a range of ASNs.