From: haikuo zhang Date: Fri, 8 Jun 2012 03:49:29 +0000 (+0800) Subject: [1514] polished codes, added execption operation for DDNS_SOA X-Git-Tag: trac2351_base~226^2~59^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f5ebca253e112f149d67b171ce1c86cbd3d4a1a;p=thirdparty%2Fkea.git [1514] polished codes, added execption operation for DDNS_SOA --- diff --git a/src/lib/python/isc/ddns/session.py b/src/lib/python/isc/ddns/session.py index 1f7cde2751..e98381049b 100644 --- a/src/lib/python/isc/ddns/session.py +++ b/src/lib/python/isc/ddns/session.py @@ -132,7 +132,8 @@ class DDNS_SOA: def soa_update_check(self, origin_soa, new_soa): '''Check whether the new soa is valid. If the serial number is bigger than the old one, it is valid, then return True, otherwise, return - False. + False. Make sure the origin_soa and new_soa parameters are not none + before invoke soa_update_check. Parameters: origin_soa, old SOA resource record. new_soa, new SOA resource record. @@ -149,7 +150,7 @@ class DDNS_SOA: def update_soa(self, origin_soa, inc_number = 1): ''' Update the soa number incrementally as RFC 2136. Please make sure - that the origin_soa exists and not null before invoke this function. + that the origin_soa exists and not none before invoke this function. Parameters: origin_soa, the soa resource record which will be updated. inc_number, the number which will be added into the serial number of @@ -728,6 +729,11 @@ class UpdateSession: result, old_soa, _ = self.__finder.find(self.__zname, RRType.SOA(), ZoneFinder.NO_WILDCARD | ZoneFinder.FIND_GLUE_OK) + # We may implement recovering from missing SOA data at some point, but + # for now servfail on such a broken state + if result != ZoneFinder.SUCCESS: + raise UpdateError("Error finding SOA record in datasource.", + self.__zname, self.__zclass, Rcode.SERVFAIL()) serial_operation = DDNS_SOA() if self.__added_soa is not None and\ serial_operation.soa_update_check(old_soa, self.__added_soa):