Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'Dependency Redundancy Groups' #2860

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions application/controllers/SuggestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions application/forms/IcingaDependencyForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
1 change: 1 addition & 0 deletions library/Director/Objects/IcingaDependency.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
Expand Down
1 change: 1 addition & 0 deletions library/Director/Web/Form/DirectorObjectForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ protected function groupMainProperties($importsFirst = false)
'email',
'pager',
'enable_notifications',
'redundancy_group', //Dependencies
'disable_checks', //Dependencies
'disable_notifications',
'ignore_soft_states',
Expand Down
6 changes: 6 additions & 0 deletions schema/mysql-migrations/upgrade_188.sql
Original file line number Diff line number Diff line change
@@ -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());
4 changes: 3 additions & 1 deletion schema/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -2446,4 +2448,4 @@ CREATE TABLE branched_icinga_dependency (

INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (187, NOW());
VALUES (188, NOW());
6 changes: 6 additions & 0 deletions schema/pgsql-migrations/upgrade_188.sql
Original file line number Diff line number Diff line change
@@ -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());
4 changes: 3 additions & 1 deletion schema/pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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());