aboutsummaryrefslogtreecommitdiff
path: root/rpkid/rpki/sql.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2013-04-19 20:33:14 +0000
committerRob Austein <sra@hactrn.net>2013-04-19 20:33:14 +0000
commit05eaca3a52b1049ec69b7788deb4872df1c0d7c5 (patch)
treebb5303470d2dba45850b6af6f4a6c69c3994b723 /rpkid/rpki/sql.py
parentddfb8c4eb8139b94e1031c6f8555aee4b6287afb (diff)
Throw exception when asked to issue a certificate with notAfter <=
notBefore. Don't stomp ghostbuster_obj if we've just reused it. Clean up properly when deleting a ca_detail. Don't reissue expiring certificate if IRDB valid_until field says it's supposed to expire. svn path=/trunk/; revision=5302
Diffstat (limited to 'rpkid/rpki/sql.py')
-rw-r--r--rpkid/rpki/sql.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/rpkid/rpki/sql.py b/rpkid/rpki/sql.py
index d4426680..871524e1 100644
--- a/rpkid/rpki/sql.py
+++ b/rpkid/rpki/sql.py
@@ -3,7 +3,7 @@ SQL interface code.
$Id$
-Copyright (C) 2009-2012 Internet Systems Consortium ("ISC")
+Copyright (C) 2009-2013 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
@@ -130,7 +130,8 @@ class session(object):
Write any dirty objects out to SQL.
"""
for s in self.dirty.copy():
- rpki.log.debug("Sweeping %r" % s)
+ #if s.sql_cache_debug:
+ rpki.log.debug("Sweeping (%s) %r" % ("deleting" if s.sql_deleted else "storing", s))
if s.sql_deleted:
s.sql_delete()
else:
@@ -183,6 +184,11 @@ class sql_persistent(object):
sql_debug = False
+ ## @var sql_cache_debug
+ # Enable debugging of SQL cache actions
+
+ sql_cache_debug = False
+
@classmethod
def sql_fetch(cls, gctx, id): # pylint: disable=W0622
"""
@@ -272,14 +278,19 @@ class sql_persistent(object):
"""
Mark this object as needing to be written back to SQL.
"""
+ if self.sql_cache_debug and not self.sql_is_dirty:
+ rpki.log.debug("Marking %r SQL dirty" % self)
self.gctx.sql.dirty.add(self)
def sql_mark_clean(self):
"""
Mark this object as not needing to be written back to SQL.
"""
+ if self.sql_cache_debug and self.sql_is_dirty:
+ rpki.log.debug("Marking %r SQL clean" % self)
self.gctx.sql.dirty.discard(self)
+ @property
def sql_is_dirty(self):
"""
Query whether this object needs to be written back to SQL.
@@ -300,14 +311,14 @@ class sql_persistent(object):
args = self.sql_encode()
if not self.sql_in_db:
if self.sql_debug:
- rpki.log.debug("sql_fetch_store(%r, %r)" % (self.sql_template.insert, args))
+ rpki.log.debug("sql_store(%r, %r)" % (self.sql_template.insert, args))
self.gctx.sql.execute(self.sql_template.insert, args)
setattr(self, self.sql_template.index, self.gctx.sql.lastrowid())
self.gctx.sql.cache[(self.__class__, self.gctx.sql.lastrowid())] = self
self.sql_insert_hook()
else:
if self.sql_debug:
- rpki.log.debug("sql_fetch_store(%r, %r)" % (self.sql_template.update, args))
+ rpki.log.debug("sql_store(%r, %r)" % (self.sql_template.update, args))
self.gctx.sql.execute(self.sql_template.update, args)
self.sql_update_hook()
key = (self.__class__, getattr(self, self.sql_template.index))
@@ -322,7 +333,7 @@ class sql_persistent(object):
if self.sql_in_db:
id = getattr(self, self.sql_template.index) # pylint: disable=W0622
if self.sql_debug:
- rpki.log.debug("sql_fetch_delete(%r, %r)" % (self.sql_template.delete, id))
+ rpki.log.debug("sql_delete(%r, %r)" % (self.sql_template.delete, id))
self.sql_delete_hook()
self.gctx.sql.execute(self.sql_template.delete, id)
key = (self.__class__, id)