From cdb66b648ab96d8fddfaeb5d14cf53ec463e3bbc Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Mon, 29 Jun 2015 10:39:37 +0200 Subject: [PATCH] Add imports support for Command --- application/forms/IcingaCommandForm.php | 5 +++++ library/Director/Objects/IcingaCommand.php | 2 ++ schema/mysql-changes/upgrade_17.sql | 17 +++++++++++++++++ schema/mysql.sql | 18 ++++++++++++++++++ schema/pgsql-changes/upgrade-8.sql | 20 ++++++++++++++++++++ schema/pgsql.sql | 22 ++++++++++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 schema/mysql-changes/upgrade_17.sql create mode 100644 schema/pgsql-changes/upgrade-8.sql diff --git a/application/forms/IcingaCommandForm.php b/application/forms/IcingaCommandForm.php index 16a616b1..03c85dbf 100644 --- a/application/forms/IcingaCommandForm.php +++ b/application/forms/IcingaCommandForm.php @@ -50,5 +50,10 @@ class IcingaCommandForm extends DirectorObjectForm 'template' => $this->translate('Command template'), )) )); + + $this->addElement('text', 'imports', array( + 'label' => $this->translate('Imports'), + 'description' => $this->translate('The inherited command template names') + )); } } diff --git a/library/Director/Objects/IcingaCommand.php b/library/Director/Objects/IcingaCommand.php index 8d5730b2..5a9cdf08 100644 --- a/library/Director/Objects/IcingaCommand.php +++ b/library/Director/Objects/IcingaCommand.php @@ -20,6 +20,8 @@ class IcingaCommand extends IcingaObject protected $supportsCustomVars = true; + protected $supportsImports = true; + protected function renderMethods_execute() { // Execute is a reserved word in SQL, column name was prefixed diff --git a/schema/mysql-changes/upgrade_17.sql b/schema/mysql-changes/upgrade_17.sql new file mode 100644 index 00000000..58f7e889 --- /dev/null +++ b/schema/mysql-changes/upgrade_17.sql @@ -0,0 +1,17 @@ +CREATE TABLE icinga_command_inheritance ( + command_id INT(10) UNSIGNED NOT NULL, + parent_command_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (command_id, parent_command_id), + UNIQUE KEY unique_order (command_id, weight), + CONSTRAINT icinga_command_inheritance_command + FOREIGN KEY command (command_id) + REFERENCES icinga_command (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_command_inheritance_parent_command + FOREIGN KEY command (parent_command_id) + REFERENCES icinga_command (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/schema/mysql.sql b/schema/mysql.sql index e0278a7d..b7fc5820 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -206,6 +206,24 @@ CREATE TABLE icinga_command ( ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE icinga_command_inheritance ( + command_id INT(10) UNSIGNED NOT NULL, + parent_command_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (command_id, parent_command_id), + UNIQUE KEY unique_order (command_id, weight), + CONSTRAINT icinga_command_inheritance_command + FOREIGN KEY command (command_id) + REFERENCES icinga_command (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_command_inheritance_parent_command + FOREIGN KEY command (parent_command_id) + REFERENCES icinga_command (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE icinga_command_argument ( id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, command_id INT(10) UNSIGNED NOT NULL, diff --git a/schema/pgsql-changes/upgrade-8.sql b/schema/pgsql-changes/upgrade-8.sql new file mode 100644 index 00000000..61a9abec --- /dev/null +++ b/schema/pgsql-changes/upgrade-8.sql @@ -0,0 +1,20 @@ +CREATE TABLE icinga_command_inheritance ( + command_id integer NOT NULL, + parent_command_id integer NOT NULL, + weight integer DEFAULT NULL, + PRIMARY KEY (command_id, parent_command_id), + CONSTRAINT icinga_command_inheritance_command + FOREIGN KEY (command_id) + REFERENCES icinga_command (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_command_inheritance_parent_command + FOREIGN KEY (parent_command_id) + REFERENCES icinga_command (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX command_inheritance_unique_order ON icinga_command_inheritance (command_id, weight); +CREATE INDEX command_inheritance_command ON icinga_command_inheritance (command_id); +CREATE INDEX command_inheritance_command_parent ON icinga_command_inheritance (parent_command_id); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 90a6880e..df59cb28 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -263,6 +263,28 @@ CREATE INDEX command_zone ON icinga_command (zone_id); COMMENT ON COLUMN icinga_command.object_type IS 'external_object is an attempt to work with existing commands'; +CREATE TABLE icinga_command_inheritance ( + command_id integer NOT NULL, + parent_command_id integer NOT NULL, + weight integer DEFAULT NULL, + PRIMARY KEY (command_id, parent_command_id), + CONSTRAINT icinga_command_inheritance_command + FOREIGN KEY (command_id) + REFERENCES icinga_command (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_command_inheritance_parent_command + FOREIGN KEY (parent_command_id) + REFERENCES icinga_command (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX command_inheritance_unique_order ON icinga_command_inheritance (command_id, weight); +CREATE INDEX command_inheritance_command ON icinga_command_inheritance (command_id); +CREATE INDEX command_inheritance_command_parent ON icinga_command_inheritance (parent_command_id); + + CREATE TABLE icinga_command_argument ( id serial, command_id integer NOT NULL,