[icinga-checkins] icinga.org: icingaweb2-module-director/feature/test-runner-12905: Kickstart: import notification commands

git at icinga.org git at icinga.org
Wed Nov 2 19:31:04 CET 2016


Module: icingaweb2-module-director
Branch: feature/test-runner-12905
Commit: cbf1a30a26db0ad2d48dcdb71db214222fe06190
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=cbf1a30a26db0ad2d48dcdb71db214222fe06190

Author: Thomas Gelf <thomas at gelf.net>
Date:   Sun Oct 30 12:29:04 2016 +0000

Kickstart: import notification commands

fixes #12028

---

 library/Director/Core/CoreApi.php               |   18 +++++++++++++++++-
 library/Director/Import/ImportSourceCoreApi.php |   15 ++++++++-------
 library/Director/KickstartHelper.php            |   10 ++++++++++
 3 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/library/Director/Core/CoreApi.php b/library/Director/Core/CoreApi.php
index c7b467f..e99795e 100644
--- a/library/Director/Core/CoreApi.php
+++ b/library/Director/Core/CoreApi.php
@@ -440,8 +440,24 @@ constants
         }
 
         return $objects;
+    }
+
+    public function getNotificationCommandObjects()
+    {
+        IcingaCommand::setPluginDir($this->getConstant('PluginDir'));
+
+        $objects = $this->getDirectorObjects('Command', 'NotificationCommand', 'NotificationCommands', array(
+            'arguments' => 'arguments',
+            // 'env'      => 'env',
+            'timeout'   => 'timeout',
+            'command'   => 'command',
+            'vars'      => 'vars'
+        ));
+        foreach ($objects as $obj) {
+            $obj->methods_execute = 'PluginNotification';
+        }
 
-        return $this->getObjects('CheckCommand', 'CheckCommands');
+        return $objects;
     }
 
     public function listModuleStages($name, $active = null)
diff --git a/library/Director/Import/ImportSourceCoreApi.php b/library/Director/Import/ImportSourceCoreApi.php
index 7d80381..c2a3cc8 100644
--- a/library/Director/Import/ImportSourceCoreApi.php
+++ b/library/Director/Import/ImportSourceCoreApi.php
@@ -57,13 +57,14 @@ class ImportSourceCoreApi extends ImportSourceHook
     protected static function enumObjectTypes($form)
     {
         $types = array(
-            'CheckCommand'  => $form->translate('Commands'),
-            'Endpoint'      => $form->translate('Endpoints'),
-            'Host'          => $form->translate('Hosts'),
-            'HostGroup'     => $form->translate('Hostgroups'),
-            'User'          => $form->translate('Users'),
-            'UserGroup'     => $form->translate('Usergroups'),
-            'Zone'          => $form->translate('Zones'),
+            'CheckCommand'        => $form->translate('Check Commands'),
+            'NotificationCommand' => $form->translate('Notification Commands'),
+            'Endpoint'            => $form->translate('Endpoints'),
+            'Host'                => $form->translate('Hosts'),
+            'HostGroup'           => $form->translate('Hostgroups'),
+            'User'                => $form->translate('Users'),
+            'UserGroup'           => $form->translate('Usergroups'),
+            'Zone'                => $form->translate('Zones'),
         );
 
         asort($types);
diff --git a/library/Director/KickstartHelper.php b/library/Director/KickstartHelper.php
index 4908dbb..8639cd7 100644
--- a/library/Director/KickstartHelper.php
+++ b/library/Director/KickstartHelper.php
@@ -300,6 +300,16 @@ class KickstartHelper
             $new->store();
         }
 
+        foreach ($this->api()->setDb($db)->getNotificationCommandObjects() as $object) {
+            if ($object::exists($object->object_name, $db)) {
+                $new = $object::load($object->object_name, $db)->replaceWith($object);
+            } else {
+                $new = $object;
+            }
+
+            $new->store();
+        }
+
         return $this;
     }
 



More information about the icinga-checkins mailing list