from .cfg_app import PpCfgAppError, PpConfigApplication
-__version__ = '0.4.4'
+__version__ = '0.5.1'
LOG = logging.getLogger(__name__)
# =============================================================================
self.src_connection = None
self.tgt_connection = None
+ self._show_simulate_opt = True
+
super(ImportPdnsdataApp, self).__init__(
appname=appname, version=version, description=description,
cfg_stems='import-pdnsdata'
sql = 'TRUNCATE TABLE {} RESTART IDENTITY CASCADE'.format(table)
if self.verbose > 1:
LOG.debug("SQL: {}".format(sql))
- tgt_cursor.execute(sql)
+ if not self.simulate:
+ tgt_cursor.execute(sql)
LOG.debug("Commiting changes ...")
self.tgt_connection.commit()
if self.verbose > 1:
LOG.debug("Target SQL:\n{}".format(tgt_sql))
-
with self.tgt_connection.cursor() as tgt_cursor:
with self.src_connection.cursor() as src_cursor:
for result in results:
i += 1
- tgt_cursor.execute(tgt_sql, result)
+ if not self.simulate:
+ tgt_cursor.execute(tgt_sql, result)
LOG.info("Imported {} domains.".format(i))
LOG.debug("Get max. Domain Id ...")
LOG.debug("Setting curval of domains_id_seq to {} ...".format(max_id))
if self.verbose > 1:
LOG.debug("SQL: {}".format(sql))
- tgt_cursor.execute(sql, (max_id, ))
+ if not self.simulate:
+ tgt_cursor.execute(sql, (max_id, ))
LOG.debug("Commiting changes ...")
self.tgt_connection.commit()
result['active'] = True
else:
result['active'] = False
- tgt_cursor.execute(tgt_sql, result)
+ if not self.simulate:
+ tgt_cursor.execute(tgt_sql, result)
LOG.info("Imported {} cryptokeys.".format(i))
LOG.debug("Get max. CryptoKey Id ...")
LOG.debug("Setting curval of cryptokeys_id_seq to {} ...".format(max_id))
if self.verbose > 1:
LOG.debug("SQL: {}".format(sql))
- tgt_cursor.execute(sql, (max_id, ))
+ if not self.simulate:
+ tgt_cursor.execute(sql, (max_id, ))
LOG.debug("Commiting changes ...")
self.tgt_connection.commit()
for result in results:
i += 1
- tgt_cursor.execute(tgt_sql, result)
+ if not self.simulate:
+ tgt_cursor.execute(tgt_sql, result)
LOG.info("Imported {} domainmetadata.".format(i))
LOG.debug("Get max. DomainMetadata Id ...")
LOG.debug("Setting curval of domainmetadata_id_seq to {} ...".format(max_id))
if self.verbose > 1:
LOG.debug("SQL: {}".format(sql))
- tgt_cursor.execute(sql, (max_id, ))
+ if not self.simulate:
+ tgt_cursor.execute(sql, (max_id, ))
LOG.debug("Commiting changes ...")
self.tgt_connection.commit()
result['auth'] = True
else:
result['auth'] = False
- tgt_cursor.execute(tgt_sql, result)
+ if not self.simulate:
+ tgt_cursor.execute(tgt_sql, result)
LOG.info("Imported {} records.".format(i))
LOG.debug("Get max. records Id ...")
LOG.debug("Setting curval of records_id_seq to {} ...".format(max_id))
if self.verbose > 1:
LOG.debug("SQL: {}".format(sql))
- tgt_cursor.execute(sql, (max_id, ))
+ if not self.simulate:
+ tgt_cursor.execute(sql, (max_id, ))
LOG.debug("Commiting changes ...")
self.tgt_connection.commit()
if self.verbose > 1:
LOG.debug("Target SQL:\n{}".format(tgt_sql))
-
with self.tgt_connection.cursor() as tgt_cursor:
with self.src_connection.cursor() as src_cursor:
for result in results:
i += 1
- tgt_cursor.execute(tgt_sql, result)
+ if not self.simulate:
+ tgt_cursor.execute(tgt_sql, result)
LOG.info("Imported {} supermasters.".format(i))
LOG.debug("Commiting changes ...")
for result in results:
i += 1
- tgt_cursor.execute(tgt_sql, result)
+ if not self.simulate:
+ tgt_cursor.execute(tgt_sql, result)
LOG.info("Imported {} tsigkeys.".format(i))
LOG.debug("Get max. TsigKey Id ...")
LOG.debug("Setting curval of tsigkeys_id_seq to {} ...".format(max_id))
if self.verbose > 1:
LOG.debug("SQL: {}".format(sql))
- tgt_cursor.execute(sql, (max_id, ))
+ if not self.simulate:
+ tgt_cursor.execute(sql, (max_id, ))
LOG.debug("Commiting changes ...")
self.tgt_connection.commit()