[icinga-checkins] icinga.org: icingaweb2-module-director/feature-ddo-playground: StateObject : transform state types

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


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

Author: Thomas Gelf <thomas at gelf.net>
Date:   Tue Jun 21 15:06:59 2016 +0200

StateObject: transform state types

---

 library/Director/Ddo/StateObject.php |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/library/Director/Ddo/StateObject.php b/library/Director/Ddo/StateObject.php
index b19ae61..7a19ff2 100644
--- a/library/Director/Ddo/StateObject.php
+++ b/library/Director/Ddo/StateObject.php
@@ -34,6 +34,11 @@ abstract class StateObject extends DdoObject
         self::ICINGA_OK       => 0,
     );
 
+    protected static $stateTypes = array(
+        'soft',
+        'hard',
+    );
+
     public function processCheckResult($result)
     {
         $checkResult = $result->check_result;
@@ -46,6 +51,15 @@ abstract class StateObject extends DdoObject
         $this->severity   = $this->calculateSeverity();
     }
 
+    public function setState_type($type)
+    {
+        if (ctype_digit($type)) {
+            $type = $this->stateTypes[$type];
+        }
+
+        return $this->reallySet('state_type', $type);
+     }
+
     /*
     // Draft for history updates
     public function storeStateChange()



More information about the icinga-checkins mailing list