[icinga-checkins] icinga.org: icingaweb2-module-director/feature-ddo-playground: ImportRunBasedPurgeStrategy: use source key pattern

git at icinga.org git at icinga.org
Tue Jul 19 10:31:51 CEST 2016


Module: icingaweb2-module-director
Branch: feature-ddo-playground
Commit: 34e57d51603325abf2f5c9d034ec628d9d38ad03
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=34e57d51603325abf2f5c9d034ec628d9d38ad03

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed Jul 13 20:14:35 2016 +0200

ImportRunBasedPurgeStrategy: use source key pattern

fixes #12059

---

 .../Import/PurgeStrategy/ImportRunBasedPurgeStrategy.php |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/library/Director/Import/PurgeStrategy/ImportRunBasedPurgeStrategy.php b/library/Director/Import/PurgeStrategy/ImportRunBasedPurgeStrategy.php
index 57bebce..4c64a8d 100644
--- a/library/Director/Import/PurgeStrategy/ImportRunBasedPurgeStrategy.php
+++ b/library/Director/Import/PurgeStrategy/ImportRunBasedPurgeStrategy.php
@@ -2,6 +2,7 @@
 
 namespace Icinga\Module\Director\Import\PurgeStrategy;
 
+use Icinga\Module\Director\Import\SyncUtils;
 use Icinga\Module\Director\Objects\ImportRun;
 use Icinga\Module\Director\Objects\ImportSource;
 
@@ -48,7 +49,8 @@ class ImportRunBasedPurgeStrategy extends PurgeStrategy
 
     public function listKeysRemovedBetween(ImportRun $runA, ImportRun $runB)
     {
-        $db = $this->getSyncRule()->getDb();
+        $rule = $this->getSyncRule();
+        $db = $rule->getDb();
 
         $selectA = $runA->prepareImportedObjectQuery();
         $selectB = $runB->prepareImportedObjectQuery();
@@ -64,6 +66,16 @@ class ImportRunBasedPurgeStrategy extends PurgeStrategy
 
         $result = $db->fetchCol($query);
 
+        if ($rule->object_type === 'service') {
+            $pattern = $rule->getSourceKeyPattern();
+            $columns = SyncUtils::extractVariableNames($pattern);
+            $rows = $runA->fetchRows($columns, null, $result);
+            $result = array();
+            foreach ($rows as $row) {
+                $result[] = SyncUtils::fillVariables($pattern, $row);
+            }
+        }
+
         if ($result) {
             return array_combine($result, $result);
         } else {



More information about the icinga-checkins mailing list