|
@@ -62,6 +62,8 @@ class LoadZoneRunner:
|
|
|
'''
|
|
|
def __init__(self, command_args):
|
|
|
self.__command_args = command_args
|
|
|
+ self.__load_iteration_limit = 100000 # arbitrary choice for now
|
|
|
+ self.__loaded_rrs = 0
|
|
|
|
|
|
# These are essentially private, and defined as "protected" for the
|
|
|
# convenience of tests inspecting them
|
|
@@ -72,6 +74,12 @@ class LoadZoneRunner:
|
|
|
self._datasrc_type = None
|
|
|
|
|
|
def _parse_args(self):
|
|
|
+ '''Parse command line options and other arguments.
|
|
|
+
|
|
|
+ This is essentially private, but defined as "protected" for tests.
|
|
|
+
|
|
|
+ '''
|
|
|
+
|
|
|
usage_txt = 'usage: %prog [options] zonename zonefile'
|
|
|
parser = OptionParser(usage=usage_txt)
|
|
|
set_cmd_options(parser)
|
|
@@ -123,6 +131,11 @@ class LoadZoneRunner:
|
|
|
[self._zone_name.to_text()])
|
|
|
|
|
|
def _do_load(self):
|
|
|
+ '''Main part of the load logic.
|
|
|
+
|
|
|
+ This is essentially private, but defined as "protected" for tests.
|
|
|
+
|
|
|
+ '''
|
|
|
created = False
|
|
|
try:
|
|
|
datasrc_client = DataSourceClient(self._datasrc_type,
|
|
@@ -133,8 +146,10 @@ class LoadZoneRunner:
|
|
|
self._zone_class)
|
|
|
loader = ZoneLoader(datasrc_client, self._zone_name,
|
|
|
self._zone_file)
|
|
|
- loader.load()
|
|
|
- return
|
|
|
+ while not loader.load_incremental(self.__load_iteration_limit):
|
|
|
+ self.__loaded_rrs += self.__load_iteration_limit
|
|
|
+ logger.info(LOADZONE_LOADING, self.__loaded_rrs,
|
|
|
+ self._zone_name, self._zone_class)
|
|
|
except Exception as ex:
|
|
|
# release any remaining lock held in the client/loader
|
|
|
loader, datasrc_client = None, None
|
|
@@ -145,9 +160,12 @@ class LoadZoneRunner:
|
|
|
raise LoadFailure(str(ex))
|
|
|
|
|
|
def run(self):
|
|
|
+ '''Top-level method, simply calling other helpers'''
|
|
|
+
|
|
|
try:
|
|
|
self._parse_args()
|
|
|
self._do_load()
|
|
|
+ logger.info(LOADZONE_DONE, self._zone_name, self._zone_class)
|
|
|
return 0
|
|
|
except BadArgument as ex:
|
|
|
logger.error(LOADZONE_ARGUMENT_ERROR, ex)
|