From: JINMEI Tatuya Date: Fri, 11 Jan 2013 23:04:04 +0000 (-0800) Subject: [2576] use the generic delete_zone in b10-loadzone instead of sqlite3 hack X-Git-Tag: bind10-1.0.0-rc-release~100^2~5^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=58df436a73f5b3cbe6177aea37383c3ec00ca76a;p=thirdparty%2Fkea.git [2576] use the generic delete_zone in b10-loadzone instead of sqlite3 hack --- diff --git a/src/bin/loadzone/loadzone.py.in b/src/bin/loadzone/loadzone.py.in index 294df55e1f..0cd68db2c2 100755 --- a/src/bin/loadzone/loadzone.py.in +++ b/src/bin/loadzone/loadzone.py.in @@ -200,29 +200,6 @@ class LoadZoneRunner: logger.info(LOADZONE_SQLITE3_USING_DEFAULT_CONFIG, default_db_file) return '{"database_file": "' + default_db_file + '"}' - def __cancel_create(self): - '''sqlite3-only hack: delete the zone just created on load failure. - - This should eventually be done via generic datasrc API, but right now - we don't have that interface. Leaving the zone in this situation - is too bad, so we handle it with a workaround. - - ''' - if self._datasrc_type is not 'sqlite3': - return - - import sqlite3 # we need the module only here - import json - - # If we are here, the following should basically succeed; since - # this is considered a temporary workaround we don't bother to catch - # and recover rare failure cases. - dbfile = json.loads(self._datasrc_config)['database_file'] - with sqlite3.connect(dbfile) as conn: - cur = conn.cursor() - cur.execute("DELETE FROM zones WHERE name = ?", - [self._zone_name.to_text()]) - def _report_progress(self, loaded_rrs): '''Dump the current progress report to stdout. @@ -274,10 +251,10 @@ class LoadZoneRunner: self.__loaded_rrs >= self._report_interval): sys.stdout.write('\n') except Exception as ex: - # release any remaining lock held in the client/loader - loader, datasrc_client = None, None + # release any remaining lock held in the loader + loader = None if created: - self.__cancel_create() + datasrc_client.delete_zone(self._zone_name) logger.error(LOADZONE_CANCEL_CREATE_ZONE, self._zone_name, self._zone_class) raise LoadFailure(str(ex))