[icinga-checkins] icinga.org: icingaweb2-module-director/fiddle/mfrosch-2: WIP: Sync: Hack to allow service template syncing

git at icinga.org git at icinga.org
Fri Jul 22 12:03:50 CEST 2016


Module: icingaweb2-module-director
Branch: fiddle/mfrosch-2
Commit: 888627fa46c6ea1265b3e577c3a2ea3aa882ca1a
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=888627fa46c6ea1265b3e577c3a2ea3aa882ca1a

Author: Markus Frosch <lazyfrosch at icinga.org>
Date:   Tue Jul 19 17:05:08 2016 +0200

WIP: Sync: Hack to allow service template syncing

Service keys in sync will be numeric, unless a combinedKey is used (host services). Due to keyName being an array.

---

 library/Director/Import/Sync.php |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/library/Director/Import/Sync.php b/library/Director/Import/Sync.php
index ba62c7a..2b4873b 100644
--- a/library/Director/Import/Sync.php
+++ b/library/Director/Import/Sync.php
@@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Import;
 
 use Exception;
 use Icinga\Data\Filter\Filter;
+use Icinga\Exception\NotImplementedError;
 use Icinga\Module\Director\Import\SyncUtils;
 use Icinga\Module\Director\Objects\IcingaObject;
 use Icinga\Module\Director\Objects\ImportSource;
@@ -337,7 +338,7 @@ class Sync
             ) as $object) {
 
                 if ($object instanceof IcingaService) {
-                    if (! $object->host_id) {
+                    if (!$object->host_id) {
                         continue;
                     }
                 }
@@ -357,6 +358,13 @@ class Sync
 
                 $this->objects[$key] = $object;
             }
+        } elseif ($this->rule->object_type === 'service') {
+            // TODO: find a better solution
+            $this->objects = IcingaService::loadAll(
+                $this->db,
+                null,
+                'object_name'
+            );
         } else {
             $this->objects = IcingaObject::loadAllByType(
                 $this->rule->object_type,
@@ -482,6 +490,11 @@ class Sync
         $newObjects = $this->prepareNewObjects();
 
         foreach ($newObjects as $key => $object) {
+            // TODO: explain!
+            if (is_integer($key)) { // || is_array($object->getKeyName())) {
+                throw new NotImplementedError('can not sync against objects with numeric ids');
+            }
+
             if (array_key_exists($key, $this->objects)) {
                 switch ($this->rule->update_policy) {
                     case 'override':



More information about the icinga-checkins mailing list