2015-07-23 16:40:32 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Forms;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
|
|
|
|
|
|
|
class SyncRuleForm extends DirectorObjectForm
|
|
|
|
{
|
|
|
|
public function setup()
|
|
|
|
{
|
2016-02-26 12:42:21 +01:00
|
|
|
$availableTypes = array(
|
2015-12-08 10:58:05 +01:00
|
|
|
'command' => $this->translate('Command'),
|
2015-12-03 16:13:49 +01:00
|
|
|
'endpoint' => $this->translate('Endpoint'),
|
|
|
|
'host' => $this->translate('Host'),
|
|
|
|
'service' => $this->translate('Service'),
|
|
|
|
'user' => $this->translate('User'),
|
|
|
|
'hostgroup' => $this->translate('Hostgroup'),
|
|
|
|
'servicegroup' => $this->translate('Servicegroup'),
|
|
|
|
'usergroup' => $this->translate('Usergroup'),
|
|
|
|
'datalistEntry' => $this->translate('Datalist entry'),
|
|
|
|
'zone' => $this->translate('Zone'),
|
|
|
|
);
|
|
|
|
asort($availableTypes);
|
|
|
|
|
2015-07-23 16:40:32 +02:00
|
|
|
$this->addElement('text', 'rule_name', array(
|
2015-11-02 10:36:10 +01:00
|
|
|
'label' => $this->translate('Rule name'),
|
|
|
|
'description' => $this->translate('Please provide a rule name'),
|
2015-07-23 16:40:32 +02:00
|
|
|
'required' => true,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->addElement('select', 'object_type', array(
|
2015-11-02 10:36:10 +01:00
|
|
|
'label' => $this->translate('Object Type'),
|
2016-04-12 20:32:30 +02:00
|
|
|
'description' => $this->translate('Choose an object type'),
|
2015-11-02 10:36:10 +01:00
|
|
|
'required' => true,
|
2015-12-03 16:13:49 +01:00
|
|
|
'multiOptions' => $this->optionalEnum($availableTypes)
|
2015-07-23 16:40:32 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
$this->addElement('select', 'update_policy', array(
|
2015-11-02 10:36:10 +01:00
|
|
|
'label' => $this->translate('Update Policity'),
|
2016-04-12 20:32:30 +02:00
|
|
|
'description' => $this->translate(
|
|
|
|
'Define what should happen when an object with a matching key'
|
2016-04-12 21:06:15 +02:00
|
|
|
. " already exists. You could merge it's properties (import source"
|
|
|
|
. ' wins), replace it completely with the imported object or ignore'
|
|
|
|
. ' it (helpful for one-time imports)'
|
2016-04-12 20:32:30 +02:00
|
|
|
),
|
2015-11-02 10:36:10 +01:00
|
|
|
'required' => true,
|
2016-02-26 12:42:21 +01:00
|
|
|
'multiOptions' => $this->optionalEnum(array(
|
2016-04-12 20:32:30 +02:00
|
|
|
'merge' => $this->translate('Merge'),
|
|
|
|
'override' => $this->translate('Replace'),
|
|
|
|
'ignore' => $this->translate('Ignore'),
|
2015-11-02 10:36:10 +01:00
|
|
|
))
|
2015-07-23 16:40:32 +02:00
|
|
|
));
|
|
|
|
|
2015-07-23 20:00:31 +02:00
|
|
|
$this->addElement('select', 'purge_existing', array(
|
|
|
|
'label' => $this->translate('Purge'),
|
2016-04-12 20:32:30 +02:00
|
|
|
'description' => $this->translate(
|
|
|
|
'Whether to purge existing objects. This means that objects of'
|
2016-04-12 21:06:15 +02:00
|
|
|
. ' the same type will be removed from Director in case they no'
|
|
|
|
. ' longer exist at your import source.'
|
2016-04-12 20:32:30 +02:00
|
|
|
),
|
|
|
|
'required' => true,
|
2016-02-26 12:42:21 +01:00
|
|
|
'multiOptions' => $this->optionalEnum(array(
|
2016-04-12 20:32:30 +02:00
|
|
|
'y' => $this->translate('Yes'),
|
|
|
|
'n' => $this->translate('No')
|
2015-11-02 10:36:10 +01:00
|
|
|
))
|
2015-07-23 16:40:32 +02:00
|
|
|
));
|
|
|
|
|
2015-07-23 20:00:31 +02:00
|
|
|
$this->addElement('text', 'filter_expression', array(
|
2015-11-02 10:36:10 +01:00
|
|
|
'label' => $this->translate('Filter Expression'),
|
2016-04-12 20:32:30 +02:00
|
|
|
'description' => sprintf(
|
|
|
|
$this->translate(
|
|
|
|
'Sync only part of your imported objects with this rule. Icinga Web 2'
|
2016-04-12 21:06:15 +02:00
|
|
|
. ' filter syntax is allowed, so this could look as follows: %s'
|
2016-04-12 20:32:30 +02:00
|
|
|
),
|
|
|
|
'(host=a|host=b)&!ip=127.*'
|
|
|
|
),
|
2015-07-23 16:40:32 +02:00
|
|
|
));
|
2015-11-06 09:12:54 +01:00
|
|
|
|
|
|
|
$this->setButtons();
|
2015-07-23 16:40:32 +02:00
|
|
|
}
|
|
|
|
}
|