From 61812d61156f96e147f3122b3c5396e9e812fb1e Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 29 Jun 2015 10:46:32 +0200 Subject: [PATCH] Add imports support for Zone --- application/forms/IcingaZoneForm.php | 5 +++++ library/Director/Objects/IcingaZone.php | 2 ++ schema/mysql-changes/upgrade_18.sql | 17 +++++++++++++++++ schema/mysql.sql | 18 ++++++++++++++++++ schema/pgsql-changes/upgrade-9.sql | 20 ++++++++++++++++++++ schema/pgsql.sql | 22 ++++++++++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 schema/mysql-changes/upgrade_18.sql create mode 100644 schema/pgsql-changes/upgrade-9.sql diff --git a/application/forms/IcingaZoneForm.php b/application/forms/IcingaZoneForm.php index bad34539..27c8219b 100644 --- a/application/forms/IcingaZoneForm.php +++ b/application/forms/IcingaZoneForm.php @@ -37,5 +37,10 @@ class IcingaZoneForm extends DirectorObjectForm 'label' => $this->translate('Parent Zone'), 'description' => $this->translate('Chose an (optional) parent zone') )); + + $this->addElement('text', 'imports', array( + 'label' => $this->translate('Imports'), + 'description' => $this->translate('The inherited zone template names') + )); } } diff --git a/library/Director/Objects/IcingaZone.php b/library/Director/Objects/IcingaZone.php index 172eb8e4..97a959e7 100644 --- a/library/Director/Objects/IcingaZone.php +++ b/library/Director/Objects/IcingaZone.php @@ -16,6 +16,8 @@ class IcingaZone extends IcingaObject 'is_global' => 'n', ); + protected $supportsImports = true; + protected function renderParent_zone_id() { return $this->renderZoneProperty($this->parent_zone_id, 'parent_zone'); diff --git a/schema/mysql-changes/upgrade_18.sql b/schema/mysql-changes/upgrade_18.sql new file mode 100644 index 00000000..5d3eb85e --- /dev/null +++ b/schema/mysql-changes/upgrade_18.sql @@ -0,0 +1,17 @@ +CREATE TABLE icinga_zone_inheritance ( + zone_id INT(10) UNSIGNED NOT NULL, + parent_zone_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (zone_id, parent_zone_id), + UNIQUE KEY unique_order (zone_id, weight), + CONSTRAINT icinga_zone_inheritance_zone + FOREIGN KEY zone (zone_id) + REFERENCES icinga_zone (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_zone_inheritance_parent_zone + FOREIGN KEY zone (parent_zone_id) + REFERENCES icinga_zone (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/schema/mysql.sql b/schema/mysql.sql index b7fc5820..7b911ab6 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -136,6 +136,24 @@ CREATE TABLE icinga_zone ( ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE icinga_zone_inheritance ( + zone_id INT(10) UNSIGNED NOT NULL, + parent_zone_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (zone_id, parent_zone_id), + UNIQUE KEY unique_order (zone_id, weight), + CONSTRAINT icinga_zone_inheritance_zone + FOREIGN KEY zone (zone_id) + REFERENCES icinga_zone (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_zone_inheritance_parent_zone + FOREIGN KEY zone (parent_zone_id) + REFERENCES icinga_zone (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE icinga_timeperiod ( id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, object_name VARCHAR(255) NOT NULL, diff --git a/schema/pgsql-changes/upgrade-9.sql b/schema/pgsql-changes/upgrade-9.sql new file mode 100644 index 00000000..401a8647 --- /dev/null +++ b/schema/pgsql-changes/upgrade-9.sql @@ -0,0 +1,20 @@ +CREATE TABLE icinga_zone_inheritance ( + zone_id integer NOT NULL, + parent_zone_id integer NOT NULL, + weight integer DEFAULT NULL, + PRIMARY KEY (zone_id, parent_zone_id), + CONSTRAINT icinga_zone_inheritance_zone + FOREIGN KEY (zone_id) + REFERENCES icinga_zone (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_zone_inheritance_parent_zone + FOREIGN KEY (parent_zone_id) + REFERENCES icinga_zone (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX zone_inheritance_unique_order ON icinga_zone_inheritance (zone_id, weight); +CREATE INDEX zone_inheritance_zone ON icinga_zone_inheritance (zone_id); +CREATE INDEX zone_inheritance_zone_parent ON icinga_zone_inheritance (parent_zone_id); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index df59cb28..0cee0575 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -177,6 +177,28 @@ CREATE TABLE icinga_zone ( CREATE INDEX zone_parent ON icinga_zone (parent_zone_id); +CREATE TABLE icinga_zone_inheritance ( + zone_id integer NOT NULL, + parent_zone_id integer NOT NULL, + weight integer DEFAULT NULL, + PRIMARY KEY (zone_id, parent_zone_id), + CONSTRAINT icinga_zone_inheritance_zone + FOREIGN KEY (zone_id) + REFERENCES icinga_zone (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_zone_inheritance_parent_zone + FOREIGN KEY (parent_zone_id) + REFERENCES icinga_zone (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX zone_inheritance_unique_order ON icinga_zone_inheritance (zone_id, weight); +CREATE INDEX zone_inheritance_zone ON icinga_zone_inheritance (zone_id); +CREATE INDEX zone_inheritance_zone_parent ON icinga_zone_inheritance (parent_zone_id); + + CREATE TABLE icinga_timeperiod ( id serial, object_name character varying(255) NOT NULL,