From f8634cf66bf65ea632c787e49741b3adb7f9a683 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 17 Dec 2015 19:27:01 +0100 Subject: [PATCH] IcingaHost: add agent properties --- application/forms/IcingaHostForm.php | 27 +++++++++++++++++++++++++ library/Director/Objects/IcingaHost.php | 23 ++++++++++++++++++++- schema/mysql-changes/upgrade_58.sql | 5 +++++ schema/mysql.sql | 3 +++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 schema/mysql-changes/upgrade_58.sql diff --git a/application/forms/IcingaHostForm.php b/application/forms/IcingaHostForm.php index 3b852090..57d942e5 100644 --- a/application/forms/IcingaHostForm.php +++ b/application/forms/IcingaHostForm.php @@ -31,6 +31,30 @@ class IcingaHostForm extends DirectorObjectForm )); $this->addZoneElement(); + + $this->addBoolean('has_agent', array( + 'label' => $this->translate('Icinga2 Agent'), + 'description' => $this->translate( + 'Whether this host has the Icinga 2 Agent installed' + ), + 'class' => 'autosubmit', + )); + + if ($this->getSentOrObjectValue('has_agent') === 'y') { + $this->addBoolean('master_should_connect', array( + 'label' => $this->translate('Establish connection'), + 'description' => $this->translate( + 'Whether the parent (master) node should actively try to connect to this agent' + ), + 'required' => true + )); + $this->addBoolean('accept_config', array( + 'label' => $this->translate('Accepts config'), + 'description' => $this->translate('Whether the agent is configured to accept config'), + 'required' => true + )); + } + $this->addImportsElement(); /* @@ -46,6 +70,9 @@ class IcingaHostForm extends DirectorObjectForm 'address', 'address6', 'zone_id', + 'has_agent', + 'master_should_connect', + 'accept_config', 'imports', ); $this->addDisplayGroup($elements, 'object_definition', array( diff --git a/library/Director/Objects/IcingaHost.php b/library/Director/Objects/IcingaHost.php index 6586048b..df62f5f5 100644 --- a/library/Director/Objects/IcingaHost.php +++ b/library/Director/Objects/IcingaHost.php @@ -37,6 +37,9 @@ class IcingaHost extends IcingaObject 'icon_image' => null, 'icon_image_alt' => null, 'object_type' => null, + 'has_agent' => null, + 'master_should_connect' => null, + 'accept_config' => null, ); protected $relations = array( @@ -54,7 +57,10 @@ class IcingaHost extends IcingaObject 'enable_event_handler', 'enable_flapping', 'enable_perfdata', - 'volatile' + 'volatile', + 'has_agent', + 'master_should_connect', + 'accept_config' ); protected $supportsCustomVars = true; @@ -104,4 +110,19 @@ class IcingaHost extends IcingaObject { return $this->getResolvedProperty('check_command_id') !== null; } + + protected function renderHas_Agent() + { + return ''; + } + + protected function renderMaster_should_connect() + { + return ''; + } + + protected function renderAccept_config() + { + return ''; + } } diff --git a/schema/mysql-changes/upgrade_58.sql b/schema/mysql-changes/upgrade_58.sql new file mode 100644 index 00000000..5771f6a0 --- /dev/null +++ b/schema/mysql-changes/upgrade_58.sql @@ -0,0 +1,5 @@ +ALTER TABLE icinga_host + ADD COLUMN has_agent ENUM('y', 'n') DEFAULT NULL, + ADD COLUMN master_should_connect ENUM('y', 'n') DEFAULT NULL, + ADD COLUMN accept_config ENUM('y', 'n') DEFAULT NULL; + diff --git a/schema/mysql.sql b/schema/mysql.sql index ad08c833..f578fe37 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -399,6 +399,9 @@ CREATE TABLE icinga_host ( icon_image VARCHAR(255) DEFAULT NULL, icon_image_alt VARCHAR(255) DEFAULT NULL, object_type ENUM('object', 'template') NOT NULL, + has_agent ENUM('y', 'n') DEFAULT NULL, + master_should_connect ENUM('y', 'n') DEFAULT NULL, + accept_config ENUM('y', 'n') DEFAULT NULL, PRIMARY KEY (id), UNIQUE INDEX object_name (object_name, zone_id), KEY search_idx (display_name),