From fd74a8dfd5b08206d00a87f2d6170eef4d57388a Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 26 Jun 2015 16:20:16 +0200 Subject: [PATCH] Add imports support to Service --- application/forms/IcingaServiceForm.php | 5 +++++ library/Director/Objects/IcingaService.php | 2 ++ schema/mysql-changes/upgrade_12.sql | 17 +++++++++++++++++ schema/mysql.sql | 18 ++++++++++++++++++ schema/pgsql-changes/upgrade-3.sql | 21 +++++++++++++++++++++ schema/pgsql.sql | 22 ++++++++++++++++++++++ 6 files changed, 85 insertions(+) create mode 100644 schema/mysql-changes/upgrade_12.sql create mode 100644 schema/pgsql-changes/upgrade-3.sql diff --git a/application/forms/IcingaServiceForm.php b/application/forms/IcingaServiceForm.php index 764c3c03..2a37227b 100644 --- a/application/forms/IcingaServiceForm.php +++ b/application/forms/IcingaServiceForm.php @@ -84,5 +84,10 @@ class IcingaServiceForm extends DirectorObjectForm 'label' => $this->translate('Servicegroups'), 'description' => $this->translate('One or more comma separated servicegroup names') )); + + $this->addElement('text', 'imports', array( + 'label' => $this->translate('Imports'), + 'description' => $this->translate('The inherited service template names') + )); } } diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php index e6f4d29a..b6aa6a20 100644 --- a/library/Director/Objects/IcingaService.php +++ b/library/Director/Objects/IcingaService.php @@ -38,6 +38,8 @@ class IcingaService extends IcingaObject protected $supportsCustomVars = true; + protected $supportsImports = true; + protected function renderCheck_command_id() { return $this->renderCommandProperty($this->check_command_id); diff --git a/schema/mysql-changes/upgrade_12.sql b/schema/mysql-changes/upgrade_12.sql new file mode 100644 index 00000000..5ee25254 --- /dev/null +++ b/schema/mysql-changes/upgrade_12.sql @@ -0,0 +1,17 @@ +CREATE TABLE icinga_service_inheritance ( + service_id INT(10) UNSIGNED NOT NULL, + parent_service_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (service_id, parent_service_id), + UNIQUE KEY unique_order (service_id, weight), + CONSTRAINT icinga_service_inheritance_service + FOREIGN KEY host (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_service_inheritance_parent_service + FOREIGN KEY host (parent_service_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/schema/mysql.sql b/schema/mysql.sql index 0a7edf91..102bf668 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -384,6 +384,24 @@ CREATE TABLE icinga_service ( ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE icinga_service_inheritance ( + service_id INT(10) UNSIGNED NOT NULL, + parent_service_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (service_id, parent_service_id), + UNIQUE KEY unique_order (service_id, weight), + CONSTRAINT icinga_service_inheritance_service + FOREIGN KEY host (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_service_inheritance_parent_service + FOREIGN KEY host (parent_service_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE icinga_service_var ( service_id INT(10) UNSIGNED NOT NULL, varname VARCHAR(255) DEFAULT NULL, diff --git a/schema/pgsql-changes/upgrade-3.sql b/schema/pgsql-changes/upgrade-3.sql new file mode 100644 index 00000000..77cb3450 --- /dev/null +++ b/schema/pgsql-changes/upgrade-3.sql @@ -0,0 +1,21 @@ +CREATE TABLE icinga_service_inheritance ( + service_id integer NOT NULL, + parent_service_id integer NOT NULL, + weight integer DEFAULT NULL, + PRIMARY KEY (service_id, parent_service_id), + CONSTRAINT icinga_service_inheritance_service + FOREIGN KEY (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_service_inheritance_parent_service + FOREIGN KEY (parent_service_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX service_inheritance_unique_order ON icinga_service_inheritance (service_id, weight); +CREATE INDEX service_inheritance_service ON icinga_service_inheritance (service_id); +CREATE INDEX service_inheritance_service_parent ON icinga_service_inheritance (parent_service_id); + diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 0fe2ae24..a8f8cda4 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -473,6 +473,28 @@ CREATE INDEX service_event_command ON icinga_service (event_command_id); CREATE INDEX service_command_endpoint ON icinga_service (command_endpoint_id); +CREATE TABLE icinga_service_inheritance ( + service_id integer NOT NULL, + parent_service_id integer NOT NULL, + weight integer DEFAULT NULL, + PRIMARY KEY (service_id, parent_service_id), + CONSTRAINT icinga_service_inheritance_service + FOREIGN KEY (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_service_inheritance_parent_service + FOREIGN KEY (parent_service_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX service_inheritance_unique_order ON icinga_service_inheritance (service_id, weight); +CREATE INDEX service_inheritance_service ON icinga_service_inheritance (service_id); +CREATE INDEX service_inheritance_service_parent ON icinga_service_inheritance (parent_service_id); + + CREATE TABLE icinga_service_var ( service_id integer NOT NULL, varname character varying(255) DEFAULT NULL,