mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-26 03:09:11 +02:00
Use config
variable in apply for rules
* use `config` instead of `value` in apply for rules * update documentation refs #11976
This commit is contained in:
parent
b5e984e0e5
commit
3e30d34098
@ -288,8 +288,8 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'Evaluates the apply for rule for ' .
|
'Evaluates the apply for rule for ' .
|
||||||
'all objects with the custom attribute specified. ' .
|
'all objects with the custom attribute specified. ' .
|
||||||
'E.g selecting "host.vars.custom_attr" will generate "for (value in ' .
|
'E.g selecting "host.vars.custom_attr" will generate "for (config in ' .
|
||||||
'host.vars.array_var)" where "value" will be accessible through "$$value$$". ' .
|
'host.vars.array_var)" where "config" will be accessible through "$config$". ' .
|
||||||
'NOTE: only custom variables of type "Array" are eligible.'
|
'NOTE: only custom variables of type "Array" are eligible.'
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
@ -25,8 +25,10 @@ Then create a new `apply-rule` for the `Service template`:
|
|||||||

|

|
||||||
|
|
||||||
Now define the `Apply For` property, select the previously defined field `tcp_ports` associated to
|
Now define the `Apply For` property, select the previously defined field `tcp_ports` associated to
|
||||||
the host template. `Apply For` rule define a variable `value` that can be used as `$$value$$`, it
|
the host template. `Apply For` rule define a variable `config` that can be used as `$config$`, it
|
||||||
corresponds to the item of the array it will iterate on. Set the `Tcp port` property to `$$value$$`:
|
corresponds to the item of the array it will iterate on.
|
||||||
|
|
||||||
|
Set the `Tcp port` property to `$config$`:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Binary file not shown.
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 34 KiB |
@ -159,7 +159,7 @@ class IcingaService extends IcingaObject
|
|||||||
&& $this->get('apply_for') !== null) {
|
&& $this->get('apply_for') !== null) {
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
"%s %s %s for (value in %s) {\n",
|
"%s %s %s for (config in %s) {\n",
|
||||||
$this->getObjectTypeName(),
|
$this->getObjectTypeName(),
|
||||||
$this->getType(),
|
$this->getType(),
|
||||||
c::renderString($this->getObjectName()),
|
c::renderString($this->getObjectName()),
|
||||||
|
@ -254,7 +254,7 @@ class IcingaServiceTest extends BaseTestCase
|
|||||||
|
|
||||||
$service = IcingaService::loadWithAutoIncId($service->id, $db);
|
$service = IcingaService::loadWithAutoIncId($service->id, $db);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->loadRendered('service3'),
|
$this->loadRendered('service5'),
|
||||||
(string) $service
|
(string) $service
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
apply Service "___TEST___service_$not_replaced$" {
|
|
||||||
display_name = "Service: " + host.vars.replaced
|
|
||||||
vars.custom_var = host.vars.replaced
|
|
||||||
vars.test1 = "string"
|
|
||||||
vars.test2 = 17
|
|
||||||
vars.test3 = false
|
|
||||||
vars.test4 = {
|
|
||||||
a = [ "dict", "ionary" ]
|
|
||||||
@this = "is"
|
|
||||||
}
|
|
||||||
|
|
||||||
assign where match("127.*", host.address)
|
|
||||||
|
|
||||||
import DirectorOverrideTemplate
|
|
||||||
}
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user