[icinga-checkins] icinga.org: icingaweb2-module-director/feature/service-sets-12891: IcingaServiceSet: A simple key identifies a ServiceSet (template)

git at icinga.org git at icinga.org
Thu Nov 10 14:05:27 CET 2016


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

Author: Markus Frosch <markus.frosch at icinga.com>
Date:   Thu Nov 10 14:04:05 2016 +0100

IcingaServiceSet: A simple key identifies a ServiceSet (template)

refs #12891

---

 library/Director/Objects/IcingaServiceSet.php |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/library/Director/Objects/IcingaServiceSet.php b/library/Director/Objects/IcingaServiceSet.php
index 371e88c..12c6f39 100644
--- a/library/Director/Objects/IcingaServiceSet.php
+++ b/library/Director/Objects/IcingaServiceSet.php
@@ -3,6 +3,7 @@
 namespace Icinga\Module\Director\Objects;
 
 use Icinga\Data\Filter\Filter;
+use Icinga\Exception\IcingaException;
 use Icinga\Module\Director\IcingaConfig\IcingaConfig;
 
 
@@ -43,6 +44,26 @@ class IcingaServiceSet extends IcingaObject
         return true;
     }
 
+    protected function setKey($key)
+    {
+        if (is_int($key)) {
+            $this->id = $key;
+        } elseif (is_string($key)) {
+            $keyComponents = preg_split('~!~', $key);
+            if (count($keyComponents) === 1) {
+                $this->set('object_name', $keyComponents[0]);
+                $this->set('object_type', 'template');
+            }
+            else {
+                throw new IcingaException('Can not parse key: %s', $key);
+            }
+        } else {
+            return parent::setKey($key);
+        }
+
+        return $this;
+    }
+
     /**
      * @return IcingaService[]
      */



More information about the icinga-checkins mailing list