icingaweb2-module-director/application/forms/IcingaHostForm.php

102 lines
3.4 KiB
PHP
Raw Normal View History

<?php
namespace Icinga\Module\Director\Forms;
2015-07-28 17:37:05 +02:00
use Icinga\Module\Director\Objects\DirectorDatafield;
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
class IcingaHostForm extends DirectorObjectForm
{
public function setup()
{
2016-02-17 21:58:28 +01:00
$this->addObjectTypeElement();
2015-07-30 11:33:08 +02:00
$this->addElement('text', 'object_name', array(
'label' => $this->translate('Hostname'),
'required' => true,
'description' => $this->translate('Icinga object name for this host')
));
2015-08-29 00:05:39 +02:00
$this->addElement('text', 'display_name', array(
'label' => $this->translate('Display name'),
'description' => $this->translate('Alternative name for this host')
));
$this->addElement('text', 'address', array(
'label' => $this->translate('Host address'),
'description' => $this->translate('Host address. Usually an IPv4 address, but may be any kind of address your check plugin is able to deal with')
));
$this->addElement('text', 'address6', array(
'label' => $this->translate('IPv6 address'),
'description' => $this->translate('Usually your hosts main IPv6 address')
));
$this->addZoneElement();
2015-12-17 19:27:01 +01:00
$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
));
}
2015-07-30 11:33:08 +02:00
$this->addImportsElement();
2016-02-17 20:10:22 +01:00
$this->addDisabledElement();
/*
$this->addElement('text', 'groups', array(
'label' => $this->translate('Hostgroups'),
'description' => $this->translate('One or more comma separated hostgroup names')
));
*/
2015-10-15 20:08:40 +02:00
$elements = array(
2016-02-17 21:58:28 +01:00
'object_type',
2015-10-15 20:08:40 +02:00
'object_name',
'display_name',
'address',
'address6',
'zone_id',
2015-12-17 19:27:01 +01:00
'has_agent',
'master_should_connect',
'accept_config',
2015-10-15 20:08:40 +02:00
'imports',
2016-02-17 20:10:22 +01:00
'disabled',
2015-10-15 20:08:40 +02:00
);
$this->addDisplayGroup($elements, 'object_definition', array(
'decorators' => array(
'FormElements',
'Fieldset',
),
'order' => 20,
'legend' => $this->translate('Host properties')
));
2015-07-28 17:37:05 +02:00
2015-10-15 20:08:40 +02:00
if ($this->isTemplate()) {
$this->addCheckCommandElements();
$this->addCheckExecutionElements();
2015-07-30 11:33:08 +02:00
} else {
$this->getElement('imports')->setRequired();
2015-07-28 17:37:05 +02:00
}
2015-07-30 11:33:08 +02:00
$this->setButtons();
2015-07-28 17:37:05 +02:00
}
}