[icinga-checkins] icinga.org: icingaweb2-module-director/master: HostApplyMatches: allow usage for single hosts

git at icinga.org git at icinga.org
Mon Jan 2 10:16:06 CET 2017


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

Author: Thomas Gelf <thomas at gelf.net>
Date:   Mon Jan  2 10:15:35 2017 +0100

HostApplyMatches: allow usage for single hosts

refs #13849

---

 library/Director/Objects/HostApplyMatches.php |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/library/Director/Objects/HostApplyMatches.php b/library/Director/Objects/HostApplyMatches.php
index 07df56b..932f343 100644
--- a/library/Director/Objects/HostApplyMatches.php
+++ b/library/Director/Objects/HostApplyMatches.php
@@ -16,6 +16,22 @@ class HostApplyMatches
         'name' => 'object_name'
     );
 
+    protected $host;
+
+    protected $flatHost;
+
+    public static function prepare(IcingaHost $host)
+    {
+        return new static($host);
+    }
+
+    public function matchesFilter(Filter $filter)
+    {
+        $filter = clone($filter);
+        static::fixFilterColumns($filter);
+        return $filter->matches($this->flatHost);
+    }
+
     /**
      * @param Filter $filter
      * @param Db $db
@@ -116,7 +132,10 @@ class HostApplyMatches
         }
     }
 
-    protected function __construct()
+    protected function __construct(IcingaHost $host)
     {
+        $this->host = $host;
+        $this->flatHost = $host->toPlainObject(true, false);
+        static::flattenVars($this->flatHost);
     }
-}
\ No newline at end of file
+}



More information about the icinga-checkins mailing list