IcingaHost: add agent properties

This commit is contained in:
Thomas Gelf 2015-12-17 19:27:01 +01:00
parent 63081474fa
commit f8634cf66b
4 changed files with 57 additions and 1 deletions

View File

@ -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(

View File

@ -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 '';
}
}

View File

@ -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;

View File

@ -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),