1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<?php
namespace Icinga\Module\Director\Forms;
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
class SyncRuleForm extends DirectorObjectForm
{
public function setup()
{
$availableTypes = [
'host' => $this->translate('Host'),
'hostgroup' => $this->translate('Host Group'),
'service' => $this->translate('Service'),
'servicegroup' => $this->translate('Service Group'),
'serviceSet' => $this->translate('Service Set'),
'user' => $this->translate('User'),
'usergroup' => $this->translate('User Group'),
'datalistEntry' => $this->translate('Data List Entry'),
'command' => $this->translate('Command'),
'timePeriod' => $this->translate('Time Period'),
'notification' => $this->translate('Notification'),
'scheduledDowntime' => $this->translate('Scheduled Downtime'),
'dependency' => $this->translate('Dependency'),
'endpoint' => $this->translate('Endpoint'),
'zone' => $this->translate('Zone'),
];
$this->addElement('text', 'rule_name', [
'label' => $this->translate('Rule name'),
'description' => $this->translate('Please provide a rule name'),
'required' => true,
]);
$this->addElement('textarea', 'description', [
'label' => $this->translate('Description'),
'description' => $this->translate(
'An extended description for this Sync Rule. This should explain'
. ' what this Rule is going to accomplish.'
),
'rows' => '3',
]);
$this->addElement('select', 'object_type', [
'label' => $this->translate('Object Type'),
'description' => $this->translate('Choose an object type'),
'required' => true,
'multiOptions' => $this->optionalEnum($availableTypes)
]);
$this->addElement('select', 'update_policy', [
'label' => $this->translate('Update Policy'),
'description' => $this->translate(
'Define what should happen when an object with a matching key'
. " already exists. You could merge its properties (import source"
. ' wins), replace it completely with the imported object or ignore'
. ' it (helpful for one-time imports). "Update only" means that this'
. ' Rule would never create (or delete) full Objects.'
),
'required' => true,
'multiOptions' => $this->optionalEnum([
'merge' => $this->translate('Merge'),
'override' => $this->translate('Replace'),
'ignore' => $this->translate('Ignore'),
'update-only' => $this->translate('Update only'),
])
]);
$this->addBoolean('purge_existing', [
'label' => $this->translate('Purge'),
'description' => $this->translate(
'Whether to purge existing objects. This means that objects of'
. ' the same type will be removed from Director in case they no'
. ' longer exist at your import source.'
),
'required' => true,
'class' => 'autosubmit',
]);
if ($this->getSentOrObjectValue('purge_existing') === 'y') {
$this->addElement('select', 'purge_action', [
'label' => $this->translate('Purge Action'),
'description' => $this->translate(
'Whether to delete or to disable objects subject to purge'
),
'multiOptions' => $this->optionalEnum([
'delete' => $this->translate('Delete'),
'disable' => $this->translate('Disable'),
]),
'required' => true,
]);
}
$this->addElement('text', 'filter_expression', [
'label' => $this->translate('Filter Expression'),
'description' => sprintf(
$this->translate(
'Sync only part of your imported objects with this rule. Icinga Web 2'
. ' filter syntax is allowed, so this could look as follows: %s'
),
'(host=a|host=b)&!ip=127.*'
) . ' ' . $this->translate(
'Be careful: this is usually NOT what you want, as it makes Sync "blind"'
. ' for objects matching this filter. This means that "Purge" will not'
. ' work as expected. The "Black/Whitelist" Import Property Modifier'
. ' is probably what you\'re looking for.'
),
]);
$this->setButtons();
}
}
|