|
@@ -200,29 +200,6 @@ class LoadZoneRunner:
|
|
logger.info(LOADZONE_SQLITE3_USING_DEFAULT_CONFIG, default_db_file)
|
|
logger.info(LOADZONE_SQLITE3_USING_DEFAULT_CONFIG, default_db_file)
|
|
return '{"database_file": "' + 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):
|
|
def _report_progress(self, loaded_rrs):
|
|
'''Dump the current progress report to stdout.
|
|
'''Dump the current progress report to stdout.
|
|
|
|
|
|
@@ -274,10 +251,10 @@ class LoadZoneRunner:
|
|
self.__loaded_rrs >= self._report_interval):
|
|
self.__loaded_rrs >= self._report_interval):
|
|
sys.stdout.write('\n')
|
|
sys.stdout.write('\n')
|
|
except Exception as ex:
|
|
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:
|
|
if created:
|
|
- self.__cancel_create()
|
|
|
|
|
|
+ datasrc_client.delete_zone(self._zone_name)
|
|
logger.error(LOADZONE_CANCEL_CREATE_ZONE, self._zone_name,
|
|
logger.error(LOADZONE_CANCEL_CREATE_ZONE, self._zone_name,
|
|
self._zone_class)
|
|
self._zone_class)
|
|
raise LoadFailure(str(ex))
|
|
raise LoadFailure(str(ex))
|