[icinga-checkins] icinga.org: icingaweb2-module-director/feature/service-sets-12891: SyncRule: Support hasCombinedKey for serviceSet

git at icinga.org git at icinga.org
Wed Nov 9 11:37:07 CET 2016


Module: icingaweb2-module-director
Branch: feature/service-sets-12891
Commit: 4b909042fa5c81985602dc8e7b1f7f137674ae19
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=4b909042fa5c81985602dc8e7b1f7f137674ae19

Author: Markus Frosch <markus.frosch at icinga.com>
Date:   Wed Nov  9 10:42:56 2016 +0100

SyncRule: Support hasCombinedKey for serviceSet

refs #12891

---

 library/Director/Objects/SyncRule.php |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/library/Director/Objects/SyncRule.php b/library/Director/Objects/SyncRule.php
index ebb7cff..a5a0e9a 100644
--- a/library/Director/Objects/SyncRule.php
+++ b/library/Director/Objects/SyncRule.php
@@ -282,6 +282,29 @@ class SyncRule extends DbObject
 
                     $this->destinationKeyPattern = '${host}!${object_name}';
                 }
+            } elseif ($this->get('object_type') === 'serviceSet') {
+                $hasHost = false;
+                $hasObjectName = false;
+
+                foreach ($this->getSyncProperties() as $key => $property) {
+                    if ($property->destination_field === 'host') {
+                        $hasHost = $property->source_expression;
+                    }
+                    if ($property->destination_field === 'object_name') {
+                        $hasObjectName = $property->source_expression;
+                    }
+                }
+
+                if ($hasHost !== false && $hasObjectName !== false) {
+                    $this->hasCombinedKey = true;
+                    $this->sourceKeyPattern = sprintf(
+                        '%s!%s',
+                        $hasHost,
+                        $hasObjectName
+                    );
+
+                    $this->destinationKeyPattern = '${host}!${object_name}';
+                }
             } elseif ($this->get('object_type') === 'datalistEntry') {
                 $hasList = false;
                 $hasName = false;



More information about the icinga-checkins mailing list