diff options
Diffstat (limited to 'rpkid')
-rw-r--r-- | rpkid/portal-gui/scripts/rpkigui-reset-demo.py | 9 | ||||
-rw-r--r-- | rpkid/rpki/gui/app/glue.py | 26 | ||||
-rw-r--r-- | rpkid/setup.py | 8 |
3 files changed, 39 insertions, 4 deletions
diff --git a/rpkid/portal-gui/scripts/rpkigui-reset-demo.py b/rpkid/portal-gui/scripts/rpkigui-reset-demo.py index e1ff6134..0a3a1537 100644 --- a/rpkid/portal-gui/scripts/rpkigui-reset-demo.py +++ b/rpkid/portal-gui/scripts/rpkigui-reset-demo.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012, 2013 SPARTA, Inc. a Parsons Company +# Copyright (C) 2012, 2013, 2014 SPARTA, Inc. a Parsons Company # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -39,3 +39,10 @@ for n in xrange(1, 33): conf.clear_alerts() print '... updating resource certificate cache' list_received_resources(sys.stdout, conf) + + # Remove delegated resources (see https://trac.rpki.net/ticket/544) + # Note that we do not remove the parent-child relationship, just the + # resources. + for child in conf.children(): + child.asns.delete() + child.address_ranges.delete() diff --git a/rpkid/rpki/gui/app/glue.py b/rpkid/rpki/gui/app/glue.py index f6ec4344..a9f6441e 100644 --- a/rpkid/rpki/gui/app/glue.py +++ b/rpkid/rpki/gui/app/glue.py @@ -28,12 +28,13 @@ from datetime import datetime from rpki.resource_set import (resource_set_as, resource_set_ipv4, resource_set_ipv6, resource_range_ipv4, resource_range_ipv6) -from rpki.left_right import list_received_resources_elt +from rpki.left_right import list_received_resources_elt, report_error_elt from rpki.irdb.zookeeper import Zookeeper from rpki.gui.app import models from rpki.exceptions import BadIPResource from django.contrib.auth.models import User +from django.db.transaction import commit_on_success def ghostbuster_to_vcard(gbr): @@ -65,6 +66,19 @@ def ghostbuster_to_vcard(gbr): return vcard.serialize() +class LeftRightError(Exception): + """Class for wrapping report_error_elt errors from Zookeeper.call_rpkid(). + + It expects a single argument, which is the associated report_error_elt instance.""" + + def __str__(self): + return 'Error occurred while communicating with rpkid: handle=%s code=%s text=%s' % ( + self.args[0].self_handle, + self.args[0].error_code, + self.args[0].error_text) + + +@commit_on_success def list_received_resources(log, conf): """ Query rpkid for this resource handle's received resources. @@ -77,11 +91,19 @@ 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)) + # pdus is sometimes None (see https://trac.rpki.net/ticket/681) + if pdus is None: + print >>log, 'error: call_rpkid() returned None for handle %s when fetching received resources' % conf.handle + return models.ResourceCert.objects.filter(conf=conf).delete() for pdu in pdus: - if isinstance(pdu, list_received_resources_elt): + if isinstance(pdu, report_error_elt): + # this will cause the db to be rolled back so the above delete() + # won't clobber existing resources + raise LeftRightError, pdu + elif isinstance(pdu, list_received_resources_elt): if pdu.parent_handle != conf.handle: parent = models.Parent.objects.get(issuer=conf, handle=pdu.parent_handle) diff --git a/rpkid/setup.py b/rpkid/setup.py index 7850d6d4..39aad552 100644 --- a/rpkid/setup.py +++ b/rpkid/setup.py @@ -26,10 +26,16 @@ except ImportError: "Fake autoconf object to let --help work without autoconf." sbindir = libexecdir = datarootdir = sysconfdir = CFLAGS = LDFLAGS = LIBS = "" +try: + from rpki.version import VERSION + +except ImportError: + VERSION = "0.0" + # pylint: disable=W0622 setup(name = "rpkitoolkit", - version = "1.0", + version = VERSION, description = "RPKI Toolkit", license = "BSD", url = "http://rpki.net/", |