diff --git a/application/controllers/SuggestController.php b/application/controllers/SuggestController.php index 659c48c97..4a4a68f4d 100644 --- a/application/controllers/SuggestController.php +++ b/application/controllers/SuggestController.php @@ -356,6 +356,17 @@ protected function suggestDependencytemplates() return $this->fetchTemplateNames('icinga_dependency'); } + protected function suggestDependencyRedundancyGroups() + { + $db = $this->db()->getDbAdapter(); + $query = $db->select() + ->distinct() + ->from('icinga_dependency', 'redundancy_group') + ->where('redundancy_group IS NOT NULL') + ->order('redundancy_group'); + return $db->fetchCol($query); + } + protected function highlight($val, $search) { $search = ($search); diff --git a/application/forms/IcingaDependencyForm.php b/application/forms/IcingaDependencyForm.php index 56597f91a..0a7826f3f 100644 --- a/application/forms/IcingaDependencyForm.php +++ b/application/forms/IcingaDependencyForm.php @@ -303,6 +303,20 @@ protected function addObjectsElement() } } + $redundancyGroup = $dependency->get('redundancy_group'); + $this->addElement('text', 'redundancy_group', [ + 'label' => $this->translate('Redundancy Group'), + 'description' => $this->translate( + 'The dependency redundancy group. A name for a group of which' + . ' at least one single dependency must be fulfilled for the' + . ' whole dependency to be fulfilled.' + ), + 'class' => "director-suggest", + 'data-suggestion-context' => 'dependencyredundancygroups', + 'required' => false, + 'value' => $redundancyGroup + ]); + $elements = ['parent_host', 'child_host', 'parent_service', 'child_service']; $this->addDisplayGroup($elements, 'related_objects', [ 'decorators' => [ diff --git a/library/Director/Objects/IcingaDependency.php b/library/Director/Objects/IcingaDependency.php index abd92e625..5016a56f9 100644 --- a/library/Director/Objects/IcingaDependency.php +++ b/library/Director/Objects/IcingaDependency.php @@ -29,6 +29,7 @@ class IcingaDependency extends IcingaObject implements ExportInterface 'ignore_soft_states' => null, 'period_id' => null, 'zone_id' => null, + 'redundancy_group' => null, 'assign_filter' => null, 'parent_service_by_name' => null, ]; diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index abbd4f091..a17a1366a 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -553,6 +553,7 @@ protected function groupMainProperties($importsFirst = false) 'email', 'pager', 'enable_notifications', + 'redundancy_group', //Dependencies 'disable_checks', //Dependencies 'disable_notifications', 'ignore_soft_states', diff --git a/schema/mysql-migrations/upgrade_188.sql b/schema/mysql-migrations/upgrade_188.sql new file mode 100644 index 000000000..ba86abf9e --- /dev/null +++ b/schema/mysql-migrations/upgrade_188.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_dependency ADD COLUMN redundancy_group VARCHAR(255) DEFAULT NULL AFTER parent_service_by_name; +ALTER TABLE branched_icinga_dependency ADD COLUMN redundancy_group VARCHAR(255) DEFAULT NULL AFTER parent_service_by_name; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (188, NOW()); diff --git a/schema/mysql.sql b/schema/mysql.sql index 832ab122d..2b4ea6a5a 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -1774,6 +1774,7 @@ CREATE TABLE icinga_dependency ( zone_id INT(10) UNSIGNED DEFAULT NULL, assign_filter TEXT DEFAULT NULL, parent_service_by_name VARCHAR(255) DEFAULT NULL, + redundancy_group VARCHAR(255) DEFAULT NULL, PRIMARY KEY (id), UNIQUE INDEX uuid (uuid), CONSTRAINT icinga_dependency_parent_host @@ -2431,6 +2432,7 @@ CREATE TABLE branched_icinga_dependency ( zone VARCHAR(255) DEFAULT NULL, assign_filter TEXT DEFAULT NULL, parent_service_by_name VARCHAR(255) DEFAULT NULL, + redundancy_group VARCHAR(255) DEFAULT NULL, imports TEXT DEFAULT NULL, set_null TEXT DEFAULT NULL, @@ -2446,4 +2448,4 @@ CREATE TABLE branched_icinga_dependency ( INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (187, NOW()); + VALUES (188, NOW()); diff --git a/schema/pgsql-migrations/upgrade_188.sql b/schema/pgsql-migrations/upgrade_188.sql new file mode 100644 index 000000000..08e8b9bc2 --- /dev/null +++ b/schema/pgsql-migrations/upgrade_188.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_dependency ADD COLUMN redundancy_group character varying(255); +ALTER TABLE branched_icinga_dependency ADD COLUMN redundancy_group character varying(255); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (188, NOW()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 32931e6d7..f2972e1a9 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -2062,6 +2062,7 @@ CREATE TABLE icinga_dependency ( zone_id integer DEFAULT NULL, assign_filter text DEFAULT NULL, parent_service_by_name character varying(255), + redundancy_group character varying(255), PRIMARY KEY (id), CONSTRAINT icinga_dependency_parent_host FOREIGN KEY (parent_host_id) @@ -2768,6 +2769,7 @@ CREATE TABLE branched_icinga_dependency ( zone_id integer DEFAULT NULL, assign_filter text DEFAULT NULL, parent_service_by_name character varying(255), + redundancy_group character varying(255), imports TEXT DEFAULT NULL, set_null TEXT DEFAULT NULL, @@ -2785,4 +2787,4 @@ CREATE INDEX branched_dependency_search_object_name ON branched_icinga_dependenc INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (187, NOW()); + VALUES (188, NOW());