aboutsummaryrefslogtreecommitdiff
path: root/rpkid/rpki/gui/app/glue.py
diff options
context:
space:
mode:
authorMichael Elkins <melkins@tislabs.com>2012-11-10 03:45:29 +0000
committerMichael Elkins <melkins@tislabs.com>2012-11-10 03:45:29 +0000
commitf414cd6e8abdab6824fa9f7334db87f8e6effdde (patch)
tree16e439e225d9780b2f2103038565c557df34870e /rpkid/rpki/gui/app/glue.py
parent9a9ddea7d897912fa2b3c35b9ffdae0fdf26fc18 (diff)
add ResourceCert.conf and make .parent optinally null
svn path=/branches/tk316/; revision=4827
Diffstat (limited to 'rpkid/rpki/gui/app/glue.py')
-rw-r--r--rpkid/rpki/gui/app/glue.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/rpkid/rpki/gui/app/glue.py b/rpkid/rpki/gui/app/glue.py
index 6d168b26..bf68170e 100644
--- a/rpkid/rpki/gui/app/glue.py
+++ b/rpkid/rpki/gui/app/glue.py
@@ -78,19 +78,23 @@ def list_received_resources(log, conf):
z = Zookeeper(handle=conf.handle)
pdus = z.call_rpkid(list_received_resources_elt.make_pdu(self_handle=conf.handle))
- models.ResourceCert.objects.filter(parent__issuer=conf).delete()
+ models.ResourceCert.objects.filter(conf=conf).delete()
for pdu in pdus:
if isinstance(pdu, list_received_resources_elt):
- parent = models.Parent.objects.get(issuer=conf,
- handle=pdu.parent_handle)
+ if pdu.parent_handle != conf.handle:
+ parent = models.Parent.objects.get(issuer=conf,
+ handle=pdu.parent_handle)
+ else:
+ # root cert, self-signed
+ parent = None
not_before = datetime.strptime(pdu.notBefore, "%Y-%m-%dT%H:%M:%SZ")
not_after = datetime.strptime(pdu.notAfter, "%Y-%m-%dT%H:%M:%SZ")
- cert = models.ResourceCert.objects.create(parent=parent,
- not_before=not_before, not_after=not_after,
- uri=pdu.uri)
+ cert = models.ResourceCert.objects.create(
+ conf=conf, parent=parent, not_before=not_before,
+ not_after=not_after, uri=pdu.uri)
for asn in resource_set_as(pdu.asn):
cert.asn_ranges.create(min=asn.min, max=asn.max)