from .cfg_app import PpCfgAppError, PpConfigApplication
-__version__ = '0.8.5'
+__version__ = '0.8.6'
LOG = logging.getLogger(__name__)
# =============================================================================
self.src_connection = None
self.tgt_connection = None
+ self.domain_ids = {}
+
self._show_simulate_opt = True
super(ImportPdnsdataApp, self).__init__(
LOG.info("Importing all domains ...")
+ self.domain_ids = {}
+
src_sql = textwrap.dedent('''\
SELECT id, name, master, last_check, type, notified_serial, account
FROM domains
for result in results:
i += 1
+ dom_id = result['id']
+ self.domain_ids[dom_id] = result['name']
if self.is_local(result['name']):
LOG.debug("Setting zone {!r} to a local only zone.".format(result['name']))
cur_account = result['account']
result['auth'] = True
else:
result['auth'] = False
+ if result['ordername'] is None:
+ dom_id = result['domain_id']
+ if dom_id in self.domain_ids:
+ dom_name = self.domain_ids[dom_id]
+ if result['name'] == dom_name:
+ result['ordername'] = ''
+ else:
+ idx = result['name'].rfind('.' + dom_name)
+ if idx >= 0:
+ result['ordername'] = result['name'][:idx]
+ else:
+ result['ordername'] = ''
+ else:
+ result['ordername'] = ''
if not self.simulate:
tgt_cursor.execute(tgt_sql, result)
LOG.info("Imported {} records.".format(i))