--- /dev/null
+SET FOREIGN_KEY_CHECKS = 0;
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET AUTOCOMMIT = 0;
+START TRANSACTION;
+SET time_zone = "+02:00";
+
+-- User 'pdns'
+GRANT USAGE ON *.* TO 'pdns'@'%' IDENTIFIED BY PASSWORD '*7FB5687DEFF0A845B3D64D1D3504F88D48D5206E';
+GRANT USAGE ON *.* TO 'pdns'@'localhost' IDENTIFIED BY PASSWORD '*7FB5687DEFF0A845B3D64D1D3504F88D48D5206E';
+
+--
+-- Datenbank: `pdns`
+--
+CREATE DATABASE IF NOT EXISTS `pdns` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
+
+GRANT ALL PRIVILEGES ON `pdns`.* TO 'pdns'@'%';
+GRANT ALL PRIVILEGES ON `pdns`.* TO 'pdns'@'localhost';
+
+USE `pdns`;
+
+-- --------------------------------------------------------
+
+--
+-- Tabellenstruktur für Tabelle `comments`
+--
+
+DROP TABLE IF EXISTS `comments`;
+CREATE TABLE `comments` (
+ `id` int(11) NOT NULL,
+ `domain_id` int(11) NOT NULL,
+ `name` varchar(255) NOT NULL,
+ `type` varchar(10) NOT NULL,
+ `modified_at` int(11) NOT NULL,
+ `account` varchar(40) NOT NULL,
+ `comment` text NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Tabellenstruktur für Tabelle `cryptokeys`
+--
+
+DROP TABLE IF EXISTS `cryptokeys`;
+CREATE TABLE `cryptokeys` (
+ `id` int(11) NOT NULL,
+ `domain_id` int(11) NOT NULL,
+ `flags` int(11) NOT NULL,
+ `active` tinyint(1) DEFAULT NULL,
+ `content` text DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Tabellenstruktur für Tabelle `domainmetadata`
+--
+
+DROP TABLE IF EXISTS `domainmetadata`;
+CREATE TABLE `domainmetadata` (
+ `id` int(11) NOT NULL,
+ `domain_id` int(11) NOT NULL,
+ `kind` varchar(32) DEFAULT NULL,
+ `content` text DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Tabellenstruktur für Tabelle `domains`
+--
+
+DROP TABLE IF EXISTS `domains`;
+CREATE TABLE `domains` (
+ `id` int(11) NOT NULL,
+ `name` varchar(255) NOT NULL,
+ `master` varchar(128) DEFAULT NULL,
+ `last_check` int(11) DEFAULT NULL,
+ `type` varchar(6) NOT NULL,
+ `notified_serial` int(11) DEFAULT NULL,
+ `account` varchar(40) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Tabellenstruktur für Tabelle `records`
+--
+
+DROP TABLE IF EXISTS `records`;
+CREATE TABLE `records` (
+ `id` int(11) NOT NULL,
+ `domain_id` int(11) DEFAULT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `type` varchar(10) DEFAULT NULL,
+ `content` text DEFAULT NULL,
+ `ttl` int(11) DEFAULT NULL,
+ `prio` int(11) DEFAULT NULL,
+ `change_date` int(11) DEFAULT NULL,
+ `disabled` tinyint(1) DEFAULT 0,
+ `ordername` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
+ `auth` tinyint(1) DEFAULT 1
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Tabellenstruktur für Tabelle `supermasters`
+--
+
+DROP TABLE IF EXISTS `supermasters`;
+CREATE TABLE `supermasters` (
+ `ip` varchar(64) NOT NULL,
+ `nameserver` varchar(255) NOT NULL,
+ `account` varchar(40) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Tabellenstruktur für Tabelle `tsigkeys`
+--
+
+DROP TABLE IF EXISTS `tsigkeys`;
+CREATE TABLE `tsigkeys` (
+ `id` int(11) NOT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `algorithm` varchar(50) DEFAULT NULL,
+ `secret` varchar(255) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Indizes der exportierten Tabellen
+--
+
+--
+-- Indizes für die Tabelle `comments`
+--
+ALTER TABLE `comments`
+ ADD PRIMARY KEY (`id`),
+ ADD KEY `comments_domain_id_idx` (`domain_id`),
+ ADD KEY `comments_name_type_idx` (`name`,`type`),
+ ADD KEY `comments_order_idx` (`domain_id`,`modified_at`);
+
+--
+-- Indizes für die Tabelle `cryptokeys`
+--
+ALTER TABLE `cryptokeys`
+ ADD PRIMARY KEY (`id`),
+ ADD KEY `domainidindex` (`domain_id`);
+
+--
+-- Indizes für die Tabelle `domainmetadata`
+--
+ALTER TABLE `domainmetadata`
+ ADD PRIMARY KEY (`id`),
+ ADD KEY `domainmetadata_idx` (`domain_id`,`kind`);
+
+--
+-- Indizes für die Tabelle `domains`
+--
+ALTER TABLE `domains`
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `name_index` (`name`);
+
+--
+-- Indizes für die Tabelle `records`
+--
+ALTER TABLE `records`
+ ADD PRIMARY KEY (`id`),
+ ADD KEY `nametype_index` (`name`,`type`),
+ ADD KEY `domain_id` (`domain_id`),
+ ADD KEY `recordorder` (`domain_id`,`ordername`);
+
+--
+-- Indizes für die Tabelle `supermasters`
+--
+ALTER TABLE `supermasters`
+ ADD PRIMARY KEY (`ip`,`nameserver`);
+
+--
+-- Indizes für die Tabelle `tsigkeys`
+--
+ALTER TABLE `tsigkeys`
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `namealgoindex` (`name`,`algorithm`);
+
+--
+-- AUTO_INCREMENT für exportierte Tabellen
+--
+
+--
+-- AUTO_INCREMENT für Tabelle `comments`
+--
+ALTER TABLE `comments`
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+--
+-- AUTO_INCREMENT für Tabelle `cryptokeys`
+--
+ALTER TABLE `cryptokeys`
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+--
+-- AUTO_INCREMENT für Tabelle `domainmetadata`
+--
+ALTER TABLE `domainmetadata`
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+--
+-- AUTO_INCREMENT für Tabelle `domains`
+--
+ALTER TABLE `domains`
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+--
+-- AUTO_INCREMENT für Tabelle `records`
+--
+ALTER TABLE `records`
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+--
+-- AUTO_INCREMENT für Tabelle `tsigkeys`
+--
+ALTER TABLE `tsigkeys`
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
+--
+-- Constraints der exportierten Tabellen
+--
+
+--
+-- Constraints der Tabelle `comments`
+--
+ALTER TABLE `comments`
+ ADD CONSTRAINT `fk_comment_domain` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`);
+
+--
+-- Constraints der Tabelle `cryptokeys`
+--
+ALTER TABLE `cryptokeys`
+ ADD CONSTRAINT `fk_cryptokey_domain` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`);
+
+--
+-- Constraints der Tabelle `domainmetadata`
+--
+ALTER TABLE `domainmetadata`
+ ADD CONSTRAINT `fk_metadata_domain` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`);
+
+--
+-- Constraints der Tabelle `records`
+--
+ALTER TABLE `records`
+ ADD CONSTRAINT `fk_record_domain` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`);
+
+SET FOREIGN_KEY_CHECKS = 1;
+COMMIT;
+
from .cfg_app import PpCfgAppError, PpConfigApplication
-__version__ = '0.5.3'
+__version__ = '0.6.1'
LOG = logging.getLogger(__name__)
# =============================================================================
default_src_db_user = 'pdns'
# Target DB data
+ default_tgt_db_type = 'postgresql'
default_tgt_db_host = 'systemshare.pixelpark.com'
- default_tgt_db_port = 5432
+ default_tgt_db_port_psql = 5432
+ default_tgt_db_port_mysql = 3306
default_tgt_db_schema = 'pdns'
default_tgt_db_user = 'pdns'
self.src_db_user = self.default_src_db_user
self.src_db_pass = None
+ self.tgt_db_type = self.default_tgt_db_type
self.tgt_db_host = self.default_tgt_db_host
- self.tgt_db_port = self.default_tgt_db_port
+ self.tgt_db_port = self.default_tgt_db_port_psql
+ if self.tgt_db_type == 'mysql':
+ self.tgt_db_port = self.default_tgt_db_port_mysql
self.tgt_db_schema = self.default_tgt_db_schema
self.tgt_db_user = self.default_tgt_db_user
self.tgt_db_pass = None
LOG.debug("Evaluating config section {n!r}:\n{s}".format(
n=section_name, s=pp(section)))
+ if 'type' in section:
+ db_type = section['type'].lower().strip()
+ if db_type not in ('mysql', 'postgresql', 'postgres', 'psql'):
+ LOG.error('Invalid database type {!r} in configuration section {!r} found.'.format(
+ section['type'], section_name))
+ self.config_has_errors = True
+ else:
+ if db_type == 'mysql':
+ self.tgt_db_type = 'mysql'
+ self.tgt_db_port = self.default_tgt_db_port_mysql
+ else:
+ self.tgt_db_type = 'postgresql'
+ self.tgt_db_port = self.default_tgt_db_port_psql
+
if 'host' in section:
host = section['host'].lower().strip()
if not host:
LOG.error('Invalid target hostname {!r} in configuration section {!r} found.'.format(
section['host'], section_name))
+ self.config_has_errors = True
else:
try:
_ = socket.getaddrinfo(host, 3306, proto=socket.IPPROTO_TCP)