[icinga-checkins] icinga.org: icinga-web/r1.5: * Updated REST commandhandler

git at icinga.org git at icinga.org
Wed Aug 31 17:45:37 CEST 2011


Module: icinga-web
Branch: r1.5
Commit: 54ceb7d8a539c6b8e10469a1b5a08a2b133e24f9
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=54ceb7d8a539c6b8e10469a1b5a08a2b133e24f9

Author: Jannis Moßhammer <jannis.mosshammer at netways.de>
Date:   Wed Aug 31 15:31:37 2011 +0200

* Updated REST commandhandler

---

 app/modules/Api/actions/ApiCommandAction.class.php |   23 ++++++++++---------
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/app/modules/Api/actions/ApiCommandAction.class.php b/app/modules/Api/actions/ApiCommandAction.class.php
index 5e4756c..4e6acef 100644
--- a/app/modules/Api/actions/ApiCommandAction.class.php
+++ b/app/modules/Api/actions/ApiCommandAction.class.php
@@ -13,7 +13,8 @@ class Api_ApiCommandAction extends IcingaApiBaseAction {
      *                     executed.</li>
      *                   </ul>
      */
-
+    private $instances           = array();
+    
     public function getDefaultViewName() {
         return 'Success';
     }
@@ -66,24 +67,24 @@ class Api_ApiCommandAction extends IcingaApiBaseAction {
             $targets = array($targets);
         }
 
-        $api = $this->getContext()->getModel("Icinga.ApiContainer","Web");
-
-        $commands = $this->buildCommandArray($command,$targets,$data);
-
+        $api = $this->getContext()->getModel("System.CommandSender","Cronks");
+        $api->setCommandName($command);
+        $api->setData($data);
+        $api->setSelection($targets);
+        
         // send it
         try {
-            $api->dispatchCommandArray($commands);
+            $api->dispatchCommands();
             $this->setAttribute("success",true);
         } catch (IcingaApiCommandException $e) {
-            $str= "";
-            foreach($api->getLastErrors() as $err) {
-                $str .= $err->getMessage()."\n";
-            }
-            $this->setAttribute("error",$str);
+            $this->setAttribute("error",$e->getMessage());
+            return 'Error';
         }
 
         return 'Success';
     }
+    
+    
 
     private function buildCommandArray($command,array $targets, $data) {
         $commands = array();





More information about the icinga-checkins mailing list