mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-26 11:19:16 +02:00
parent
e961f0eb2a
commit
738e4eeaf1
@ -23,6 +23,7 @@ class BasketForm extends DirectorObjectForm
|
|||||||
'ServiceTemplate' => $this->translate('Service Templates'),
|
'ServiceTemplate' => $this->translate('Service Templates'),
|
||||||
'ServiceSet' => $this->translate('Service Sets'),
|
'ServiceSet' => $this->translate('Service Sets'),
|
||||||
'Notification' => $this->translate('Notifications'),
|
'Notification' => $this->translate('Notifications'),
|
||||||
|
'TimePeriod' => $this->translate('Time Periods'),
|
||||||
'Dependency' => $this->translate('Dependencies'),
|
'Dependency' => $this->translate('Dependencies'),
|
||||||
'DataList' => $this->translate('Data Lists'),
|
'DataList' => $this->translate('Data Lists'),
|
||||||
'ImportSource' => $this->translate('Import Sources'),
|
'ImportSource' => $this->translate('Import Sources'),
|
||||||
|
@ -19,6 +19,7 @@ before switching to a new version.
|
|||||||
* FIX: Basket failed to restore depending on PHP version (#1782)
|
* FIX: Basket failed to restore depending on PHP version (#1782)
|
||||||
* FIX: Loop detection works again (#1631)
|
* FIX: Loop detection works again (#1631)
|
||||||
* FIX: Snapshots for Baskets with Dependencies are now possible (#1739)
|
* FIX: Snapshots for Baskets with Dependencies are now possible (#1739)
|
||||||
|
* FEATURE: Add TimePeriod support to Configuration Baskets (#1735)
|
||||||
* FEATURE: RO users could want to see where a configured service originated (#1785)
|
* FEATURE: RO users could want to see where a configured service originated (#1785)
|
||||||
|
|
||||||
### REST API
|
### REST API
|
||||||
|
@ -9,6 +9,7 @@ use Icinga\Module\Director\Objects\DirectorDatafield;
|
|||||||
use Icinga\Module\Director\Objects\IcingaCommand;
|
use Icinga\Module\Director\Objects\IcingaCommand;
|
||||||
use Icinga\Module\Director\Objects\IcingaDependency;
|
use Icinga\Module\Director\Objects\IcingaDependency;
|
||||||
use Icinga\Module\Director\Objects\IcingaObject;
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
|
use Icinga\Module\Director\Objects\IcingaTimePeriod;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ class BasketSnapshot extends DbObject
|
|||||||
{
|
{
|
||||||
protected static $typeClasses = [
|
protected static $typeClasses = [
|
||||||
'Datafield' => '\\Icinga\\Module\\Director\\Objects\\DirectorDatafield',
|
'Datafield' => '\\Icinga\\Module\\Director\\Objects\\DirectorDatafield',
|
||||||
|
'TimePeriod' => '\\Icinga\\Module\\Director\\Objects\\IcingaTimePeriod',
|
||||||
'Command' => '\\Icinga\\Module\\Director\\Objects\\IcingaCommand',
|
'Command' => '\\Icinga\\Module\\Director\\Objects\\IcingaCommand',
|
||||||
'HostGroup' => '\\Icinga\\Module\\Director\\Objects\\IcingaHostGroup',
|
'HostGroup' => '\\Icinga\\Module\\Director\\Objects\\IcingaHostGroup',
|
||||||
'IcingaTemplateChoiceHost' => '\\Icinga\\Module\\Director\\Objects\\IcingaTemplateChoiceHost',
|
'IcingaTemplateChoiceHost' => '\\Icinga\\Module\\Director\\Objects\\IcingaTemplateChoiceHost',
|
||||||
@ -46,6 +48,7 @@ class BasketSnapshot extends DbObject
|
|||||||
|
|
||||||
protected $restoreOrder = [
|
protected $restoreOrder = [
|
||||||
'Command',
|
'Command',
|
||||||
|
'TimePeriod',
|
||||||
'HostGroup',
|
'HostGroup',
|
||||||
'IcingaTemplateChoiceHost',
|
'IcingaTemplateChoiceHost',
|
||||||
'HostTemplate',
|
'HostTemplate',
|
||||||
@ -379,7 +382,11 @@ class BasketSnapshot extends DbObject
|
|||||||
if ($dummy instanceof IcingaCommand) {
|
if ($dummy instanceof IcingaCommand) {
|
||||||
$select = $db->select()->from($dummy->getTableName())
|
$select = $db->select()->from($dummy->getTableName())
|
||||||
->where('object_type != ?', 'external_object');
|
->where('object_type != ?', 'external_object');
|
||||||
} elseif (! $dummy->isGroup() && ! $dummy instanceof IcingaDependency) {
|
} elseif (! $dummy->isGroup()
|
||||||
|
// TODO: this is ugly.
|
||||||
|
&& ! $dummy instanceof IcingaDependency
|
||||||
|
&& ! $dummy instanceof IcingaTimePeriod
|
||||||
|
) {
|
||||||
$select = $db->select()->from($dummy->getTableName())
|
$select = $db->select()->from($dummy->getTableName())
|
||||||
->where('object_type = ?', 'template');
|
->where('object_type = ?', 'template');
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,7 +93,7 @@ class IcingaDependency extends IcingaObject implements ExportInterface
|
|||||||
$object = static::load($key, $db);
|
$object = static::load($key, $db);
|
||||||
} elseif (static::exists($key, $db)) {
|
} elseif (static::exists($key, $db)) {
|
||||||
throw new DuplicateKeyException(
|
throw new DuplicateKeyException(
|
||||||
'Service Template "%s" already exists',
|
'Dependency "%s" already exists',
|
||||||
$name
|
$name
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Director\Objects;
|
namespace Icinga\Module\Director\Objects;
|
||||||
|
|
||||||
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
|
use Icinga\Module\Director\Db;
|
||||||
|
use Icinga\Module\Director\DirectorObject\Automation\ExportInterface;
|
||||||
|
use Icinga\Module\Director\Exception\DuplicateKeyException;
|
||||||
|
|
||||||
class IcingaTimePeriod extends IcingaObject
|
class IcingaTimePeriod extends IcingaObject implements ExportInterface
|
||||||
{
|
{
|
||||||
protected $table = 'icinga_timeperiod';
|
protected $table = 'icinga_timeperiod';
|
||||||
|
|
||||||
@ -45,6 +47,52 @@ class IcingaTimePeriod extends IcingaObject
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getUniqueIdentifier()
|
||||||
|
{
|
||||||
|
return $this->getObjectName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return object
|
||||||
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
|
*/
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
$props = (array) $this->toPlainObject();
|
||||||
|
ksort($props);
|
||||||
|
|
||||||
|
return (object) $props;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $plain
|
||||||
|
* @param Db $db
|
||||||
|
* @param bool $replace
|
||||||
|
* @return static
|
||||||
|
* @throws DuplicateKeyException
|
||||||
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
|
*/
|
||||||
|
public static function import($plain, Db $db, $replace = false)
|
||||||
|
{
|
||||||
|
$properties = (array) $plain;
|
||||||
|
$name = $properties['object_name'];
|
||||||
|
$key = $name;
|
||||||
|
|
||||||
|
if ($replace && static::exists($key, $db)) {
|
||||||
|
$object = static::load($key, $db);
|
||||||
|
} elseif (static::exists($key, $db)) {
|
||||||
|
throw new DuplicateKeyException(
|
||||||
|
'Time Period "%s" already exists',
|
||||||
|
$name
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$object = static::create([], $db);
|
||||||
|
}
|
||||||
|
$object->setProperties($properties);
|
||||||
|
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render update property
|
* Render update property
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user