Kickstart: import notification commands

fixes #12028
This commit is contained in:
Thomas Gelf 2016-10-30 12:29:04 +00:00
parent f41d453448
commit cbf1a30a26
3 changed files with 35 additions and 8 deletions

View File

@ -440,8 +440,24 @@ constants
} }
return $objects; return $objects;
}
return $this->getObjects('CheckCommand', 'CheckCommands'); 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 $objects;
} }
public function listModuleStages($name, $active = null) public function listModuleStages($name, $active = null)

View File

@ -57,13 +57,14 @@ class ImportSourceCoreApi extends ImportSourceHook
protected static function enumObjectTypes($form) protected static function enumObjectTypes($form)
{ {
$types = array( $types = array(
'CheckCommand' => $form->translate('Commands'), 'CheckCommand' => $form->translate('Check Commands'),
'Endpoint' => $form->translate('Endpoints'), 'NotificationCommand' => $form->translate('Notification Commands'),
'Host' => $form->translate('Hosts'), 'Endpoint' => $form->translate('Endpoints'),
'HostGroup' => $form->translate('Hostgroups'), 'Host' => $form->translate('Hosts'),
'User' => $form->translate('Users'), 'HostGroup' => $form->translate('Hostgroups'),
'UserGroup' => $form->translate('Usergroups'), 'User' => $form->translate('Users'),
'Zone' => $form->translate('Zones'), 'UserGroup' => $form->translate('Usergroups'),
'Zone' => $form->translate('Zones'),
); );
asort($types); asort($types);

View File

@ -300,6 +300,16 @@ class KickstartHelper
$new->store(); $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; return $this;
} }