[icinga-checkins] icinga.org: icingaweb2-module-director/master: Use `config` variable in apply for rules

git at icinga.org git at icinga.org
Tue Oct 25 04:39:55 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 3e30d34098da77c35ab5459f7120d2227f1ba8d1
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=3e30d34098da77c35ab5459f7120d2227f1ba8d1

Author: Corentin Ardeois <cardeois at internap.com>
Date:   Thu Sep  8 18:37:23 2016 -0400

Use `config` variable in apply for rules

* use `config` instead of `value` in apply for rules
* update documentation

refs #11976

---

 application/forms/IcingaServiceForm.php                |    4 ++--
 doc/15-Service-apply-for-example.md                    |    6 ++++--
 .../15_apply-for-services/155_configure_apply_for.png  |  Bin 35848 -> 35789 bytes
 .../15_apply-for-services/156_config_preview.png       |  Bin 30190 -> 34882 bytes
 library/Director/Objects/IcingaService.php             |    2 +-
 .../php/library/Director/Objects/IcingaServiceTest.php |    2 +-
 .../php/library/Director/Objects/rendered/service3.out |   16 ----------------
 7 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/application/forms/IcingaServiceForm.php b/application/forms/IcingaServiceForm.php
index 6bafe9d..99d9c8a 100644
--- a/application/forms/IcingaServiceForm.php
+++ b/application/forms/IcingaServiceForm.php
@@ -288,8 +288,8 @@ class IcingaServiceForm extends DirectorObjectForm
                 'description' => $this->translate(
                     'Evaluates the apply for rule for ' .
                     'all objects with the custom attribute specified. ' .
-                    'E.g selecting "host.vars.custom_attr" will generate "for (value in ' .
-                    'host.vars.array_var)" where "value" will be accessible through "$$value$$". ' .
+                    'E.g selecting "host.vars.custom_attr" will generate "for (config in ' .
+                    'host.vars.array_var)" where "config" will be accessible through "$config$". ' .
                     'NOTE: only custom variables of type "Array" are eligible.'
                 )
             ));
diff --git a/doc/15-Service-apply-for-example.md b/doc/15-Service-apply-for-example.md
index d6c0bf8..ae1fbf1 100644
--- a/doc/15-Service-apply-for-example.md
+++ b/doc/15-Service-apply-for-example.md
@@ -25,8 +25,10 @@ Then create a new `apply-rule` for the `Service template`:
 ![Define apply rule](screenshot/director/15_apply-for-services/154_create_apply_rule.png)
 
 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 
-corresponds to the item of the array it will iterate on. Set the `Tcp port` property to `$$value$$`:
+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 `$config$`:
 
 ![Add field to template](screenshot/director/15_apply-for-services/155_configure_apply_for.png)
 
diff --git a/doc/screenshot/director/15_apply-for-services/155_configure_apply_for.png b/doc/screenshot/director/15_apply-for-services/155_configure_apply_for.png
index 8d6c6e3..b17ce9e 100644
Binary files a/doc/screenshot/director/15_apply-for-services/155_configure_apply_for.png and b/doc/screenshot/director/15_apply-for-services/155_configure_apply_for.png differ
diff --git a/doc/screenshot/director/15_apply-for-services/156_config_preview.png b/doc/screenshot/director/15_apply-for-services/156_config_preview.png
index f4c0392..c9b20f8 100644
Binary files a/doc/screenshot/director/15_apply-for-services/156_config_preview.png and b/doc/screenshot/director/15_apply-for-services/156_config_preview.png differ
diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php
index c405975..6a237e0 100644
--- a/library/Director/Objects/IcingaService.php
+++ b/library/Director/Objects/IcingaService.php
@@ -159,7 +159,7 @@ class IcingaService extends IcingaObject
             && $this->get('apply_for') !== null) {
 
             return sprintf(
-                "%s %s %s for (value in %s) {\n",
+                "%s %s %s for (config in %s) {\n",
                 $this->getObjectTypeName(),
                 $this->getType(),
                 c::renderString($this->getObjectName()),
diff --git a/test/php/library/Director/Objects/IcingaServiceTest.php b/test/php/library/Director/Objects/IcingaServiceTest.php
index 07fea36..45a1823 100644
--- a/test/php/library/Director/Objects/IcingaServiceTest.php
+++ b/test/php/library/Director/Objects/IcingaServiceTest.php
@@ -254,7 +254,7 @@ class IcingaServiceTest extends BaseTestCase
 
         $service = IcingaService::loadWithAutoIncId($service->id, $db);
         $this->assertEquals(
-            $this->loadRendered('service3'),
+            $this->loadRendered('service5'),
             (string) $service
         );
     }
diff --git a/test/php/library/Director/Objects/rendered/service3.out b/test/php/library/Director/Objects/rendered/service3.out
deleted file mode 100644
index ad39128..0000000
--- a/test/php/library/Director/Objects/rendered/service3.out
+++ /dev/null
@@ -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
-}
-



More information about the icinga-checkins mailing list