]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Bugfixing pp_lib/import_pdnsdata.py
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 6 Nov 2017 10:46:14 +0000 (11:46 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 6 Nov 2017 10:46:14 +0000 (11:46 +0100)
pp_lib/import_pdnsdata.py

index c9ae4623f39b9dcae406c00715ceff6d3b07ec27..2788b69e6967464645615c2738ed8dbca215f627 100644 (file)
@@ -553,38 +553,39 @@ class ImportPdnsdataApp(PpConfigApplication):
                     if not self.simulate:
                         tgt_cursor.execute(sql)
 
-                LOG.debug("Get max. Zone Template Permission Id ...")
-                sql = "SELECT MAX(id) AS max_id FROM perm_templ_items"
-                if self.verbose > 1:
-                    LOG.debug("SQL: {}".format(sql))
-                tgt_cursor.execute(sql)
-                result = tgt_cursor.fetchone()
-                if self.verbose > 3:
-                    LOG.debug("Got max Zone Template Permission Id:\n{}".format(pp(result)))
-                if result[0] is not None:
-                    max_id = int(result[0])
-                else:
-                    max_id = 0
-                sql = "SELECT SETVAL('perm_templ_items_id_seq', %s)"
-                LOG.debug("Setting curval of perm_templ_items_id_seq to {} ...".format(max_id))
-                if self.verbose > 1:
-                    LOG.debug("SQL: {}".format(sql))
-                if not self.simulate:
-                    tgt_cursor.execute(sql, (max_id, ))
+                if self.tgt_db_is_poweradmin:
+                    LOG.debug("Get max. Zone Template Permission Id ...")
+                    sql = "SELECT MAX(id) AS max_id FROM perm_templ_items"
+                    if self.verbose > 1:
+                        LOG.debug("SQL: {}".format(sql))
+                    tgt_cursor.execute(sql)
+                    result = tgt_cursor.fetchone()
+                    if self.verbose > 3:
+                        LOG.debug("Got max Zone Template Permission Id:\n{}".format(pp(result)))
+                    if result[0] is not None:
+                        max_id = int(result[0])
+                    else:
+                        max_id = 0
+                    sql = "SELECT SETVAL('perm_templ_items_id_seq', %s)"
+                    LOG.debug("Setting curval of perm_templ_items_id_seq to {} ...".format(max_id))
+                    if self.verbose > 1:
+                        LOG.debug("SQL: {}".format(sql))
+                    if not self.simulate:
+                        tgt_cursor.execute(sql, (max_id, ))
 
-                sql = "SELECT SETVAL('zone_templ_records_id_seq', 0)"
-                LOG.debug("Setting curval of zone_templ_records_id_seq to {} ...".format(0))
-                if self.verbose > 1:
-                    LOG.debug("SQL: {}".format(sql))
-                if not self.simulate:
-                    tgt_cursor.execute(sql, (max_id, ))
+                    sql = "SELECT SETVAL('zone_templ_records_id_seq', 0)"
+                    LOG.debug("Setting curval of zone_templ_records_id_seq to {} ...".format(0))
+                    if self.verbose > 1:
+                        LOG.debug("SQL: {}".format(sql))
+                    if not self.simulate:
+                        tgt_cursor.execute(sql, (max_id, ))
 
-                sql = "SELECT SETVAL('zones_id_seq', 0)"
-                LOG.debug("Setting curval of zones_id_seq to {} ...".format(0))
-                if self.verbose > 1:
-                    LOG.debug("SQL: {}".format(sql))
-                if not self.simulate:
-                    tgt_cursor.execute(sql, (max_id, ))
+                    sql = "SELECT SETVAL('zones_id_seq', 0)"
+                    LOG.debug("Setting curval of zones_id_seq to {} ...".format(0))
+                    if self.verbose > 1:
+                        LOG.debug("SQL: {}".format(sql))
+                    if not self.simulate:
+                        tgt_cursor.execute(sql, (max_id, ))
 
         LOG.debug("Commiting changes ...")
         self.tgt_connection.commit()