aboutsummaryrefslogtreecommitdiff
path: root/rpkid/rpki/gui/models.py
diff options
context:
space:
mode:
authorMichael Elkins <melkins@tislabs.com>2012-01-17 05:02:58 +0000
committerMichael Elkins <melkins@tislabs.com>2012-01-17 05:02:58 +0000
commit6383348fbfd65877ba2957c70d461ee466a86bac (patch)
tree8d0017c362eda19f419e33539655f166680244b0 /rpkid/rpki/gui/models.py
parent4d426fd55bc2ef3b45b498d181a2316732d15f7a (diff)
refactor cacheview app to use common rpki.gui.models
svn path=/branches/tk161/; revision=4165
Diffstat (limited to 'rpkid/rpki/gui/models.py')
-rw-r--r--rpkid/rpki/gui/models.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/rpkid/rpki/gui/models.py b/rpkid/rpki/gui/models.py
index 323d43e6..933fe5ee 100644
--- a/rpkid/rpki/gui/models.py
+++ b/rpkid/rpki/gui/models.py
@@ -54,12 +54,17 @@ class Prefix(models.Model):
def prefixlen(self):
"Returns the prefix length for the prefix in this object."
- return self.as_range().prefixlen()
+ return self.as_resource_range().prefixlen()
def get_prefix_display(self):
- "Returns a string version of the prefix in this object."
+ "Return a string representatation of this IP prefix."
return str(self.as_resource_range())
+ def __unicode__(self):
+ """This method may be overridden by subclasses. The default
+ implementation calls get_prefix_display(). """
+ return self.get_prefix_display()
+
class Meta:
abstract = True
@@ -74,7 +79,7 @@ class PrefixV4(Prefix):
prefix_min = IPv4AddressField(db_index=True, null=False)
prefix_max = IPv4AddressField(db_index=True, null=False)
- class Meta:
+ class Meta(Prefix.Meta):
abstract = True
class PrefixV6(Prefix):
@@ -85,7 +90,7 @@ class PrefixV6(Prefix):
prefix_min = IPv6AddressField(db_index=True, null=False)
prefix_max = IPv6AddressField(db_index=True, null=False)
- class Meta:
+ class Meta(Prefix.Meta):
abstract = True
# vim:sw=4 ts=8 expandtab
} /* Literal.String.Doc */ .highlight .s2 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Double */ .highlight .se { color: #04D; background-color: #FFF0F0 } /* Literal.String.Escape */ .highlight .sh { color: #D20; background-color: #FFF0F0 } /* Literal.String.Heredoc */ .highlight .si { color: #33B; background-color: #FFF0F0 } /* Literal.String.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
"""
Generate config for a test RPKI root certificate for resources
specified in asns.csv and prefixes.csv.

This script is separate from arin-to-csv.py so that we can convert on
the fly rather than having to pull the entire database into memory.

$Id$

Copyright (C) 2009  Internet Systems Consortium ("ISC")

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""

import csv, myrpki, sys

holder = "arin"

if len(sys.argv) == 2:
  holder = sys.argv[1]
elif len(sys.argv) > 1:
  raise RuntimeError, "Usage: %s [holder]" % sys.argv[0]

print '''\
[req]
default_bits                    = 2048
default_md                      = sha256
distinguished_name              = req_dn
prompt                          = no
encrypt_key                     = no

[req_dn]
CN                              = Pseudo-%(HOLDER)s testbed root RPKI certificate

[x509v3_extensions]
basicConstraints                = critical,CA:true
subjectKeyIdentifier            = hash
keyUsage                        = critical,keyCertSign,cRLSign
subjectInfoAccess               = 1.3.6.1.5.5.7.48.5;URI:rsync://%(holder)s.rpki.net/%(holder)s/,1.3.6.1.5.5.7.48.10;URI:rsync://%(holder)s.rpki.net/%(holder)s/root.mnf
certificatePolicies             = critical,1.3.6.1.5.5.7.14.2
sbgp-autonomousSysNum           = critical,@rfc3779_asns
sbgp-ipAddrBlock                = critical,@rfc3997_addrs

[rfc3779_asns]
''' % { "holder" : holder.lower(),
        "HOLDER" : holder.upper() }

for i, asn in enumerate(asn for handle, asn in myrpki.csv_open("asns.csv")):
  print "AS.%d = %s" % (i, asn)

print '''\

[rfc3997_addrs]

'''

for i, prefix in enumerate(prefix for handle, prefix in myrpki.csv_open("prefixes.csv")):
  v = 6 if ":" in prefix else 4
  print "IPv%d.%d = %s" % (v, i, prefix)