[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaServiceSet: cleanup, shift responsability...

git at icinga.org git at icinga.org
Mon Nov 7 14:13:12 CET 2016


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

Author: Thomas Gelf <thomas at gelf.net>
Date:   Fri Nov  4 20:31:01 2016 +0100

IcingaServiceSet: cleanup, shift responsability...

...for service_set_id property cleanup

refs #13049

---

 library/Director/Objects/IcingaService.php    |    9 ++++-----
 library/Director/Objects/IcingaServiceSet.php |   14 ++++++--------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php
index f86003e..4563352 100644
--- a/library/Director/Objects/IcingaService.php
+++ b/library/Director/Objects/IcingaService.php
@@ -177,6 +177,10 @@ class IcingaService extends IcingaObject
 
     public function toLegacyConfigString()
     {
+        if ($this->get('service_set_id')) {
+            return '';
+        }
+
         if ($this->get('assign_filter')) {
             return $this->renderLegacyResolvedAssignFilter();
         }
@@ -322,11 +326,6 @@ class IcingaService extends IcingaObject
         return '';
     }
 
-    public function renderService_set()
-    {
-        return '';
-    }
-
     public function renderUse_var_overrides()
     {
         return '';
diff --git a/library/Director/Objects/IcingaServiceSet.php b/library/Director/Objects/IcingaServiceSet.php
index 1f115a2..44d31e4 100644
--- a/library/Director/Objects/IcingaServiceSet.php
+++ b/library/Director/Objects/IcingaServiceSet.php
@@ -3,10 +3,8 @@
 namespace Icinga\Module\Director\Objects;
 
 use Icinga\Data\Filter\Filter;
-use Icinga\Exception\ProgrammingError;
 use Icinga\Module\Director\IcingaConfig\IcingaConfig;
-use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
-use Icinga\Module\Director\Objects\IcingaService;
+
 
 class IcingaServiceSet extends IcingaObject
 {
@@ -80,6 +78,7 @@ class IcingaServiceSet extends IcingaObject
                 'id' => $id,
                 'object_type' => 'template'
             ), $connection);
+            $service->set('service_set', null);
 
             $services[$service->getObjectName()] = $service;
         }
@@ -110,7 +109,7 @@ class IcingaServiceSet extends IcingaObject
                 $service->set('assign_filter', $filter);
             } elseif ($hostId = $this->get('host_id')) {
                 $service->set('object_type', 'object');
-                $service->host_id = $this->host_id;
+                $service->set('host_id', $this->get('host_id'));
             } else {
                 // Service set template without assign filter or host
                 continue;
@@ -139,7 +138,7 @@ class IcingaServiceSet extends IcingaObject
             $comment = "/** Service Set '%s' **/\n\n";
         }
 
-        return sprintf($comment, $this->object_name);
+        return sprintf($comment, $this->getObjectName());
     }
 
     protected function copyVarsToService(IcingaService $service)
@@ -155,7 +154,7 @@ class IcingaServiceSet extends IcingaObject
 
     public function renderToLegacyConfig(IcingaConfig $config)
     {
-        if ($this->assign_filter === null && $this->isTemplate()) {
+        if ($this->get('assign_filter') === null && $this->isTemplate()) {
             return;
         }
 
@@ -180,7 +179,7 @@ class IcingaServiceSet extends IcingaObject
                 $this->copyVarsToService($service);
 
                 foreach ($hosts as $hostname) {
-                    $service->host = $hostname;
+                    $service->set('host', $hostname);
                     $file->addLegacyObject($service);
                 }
             }
@@ -204,6 +203,5 @@ class IcingaServiceSet extends IcingaObject
             $host = $this->getRelatedObject('host', $this->get('host_id'));
             return $host->getRenderingZone($config);
         }
-        return $zone;
     }
 }



More information about the icinga-checkins mailing list