parent
e961f0eb2a
commit
738e4eeaf1
|
@ -23,6 +23,7 @@ class BasketForm extends DirectorObjectForm
|
|||
'ServiceTemplate' => $this->translate('Service Templates'),
|
||||
'ServiceSet' => $this->translate('Service Sets'),
|
||||
'Notification' => $this->translate('Notifications'),
|
||||
'TimePeriod' => $this->translate('Time Periods'),
|
||||
'Dependency' => $this->translate('Dependencies'),
|
||||
'DataList' => $this->translate('Data Lists'),
|
||||
'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: Loop detection works again (#1631)
|
||||
* 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)
|
||||
|
||||
### REST API
|
||||
|
|
|
@ -9,6 +9,7 @@ use Icinga\Module\Director\Objects\DirectorDatafield;
|
|||
use Icinga\Module\Director\Objects\IcingaCommand;
|
||||
use Icinga\Module\Director\Objects\IcingaDependency;
|
||||
use Icinga\Module\Director\Objects\IcingaObject;
|
||||
use Icinga\Module\Director\Objects\IcingaTimePeriod;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -16,6 +17,7 @@ class BasketSnapshot extends DbObject
|
|||
{
|
||||
protected static $typeClasses = [
|
||||
'Datafield' => '\\Icinga\\Module\\Director\\Objects\\DirectorDatafield',
|
||||
'TimePeriod' => '\\Icinga\\Module\\Director\\Objects\\IcingaTimePeriod',
|
||||
'Command' => '\\Icinga\\Module\\Director\\Objects\\IcingaCommand',
|
||||
'HostGroup' => '\\Icinga\\Module\\Director\\Objects\\IcingaHostGroup',
|
||||
'IcingaTemplateChoiceHost' => '\\Icinga\\Module\\Director\\Objects\\IcingaTemplateChoiceHost',
|
||||
|
@ -46,6 +48,7 @@ class BasketSnapshot extends DbObject
|
|||
|
||||
protected $restoreOrder = [
|
||||
'Command',
|
||||
'TimePeriod',
|
||||
'HostGroup',
|
||||
'IcingaTemplateChoiceHost',
|
||||
'HostTemplate',
|
||||
|
@ -379,7 +382,11 @@ class BasketSnapshot extends DbObject
|
|||
if ($dummy instanceof IcingaCommand) {
|
||||
$select = $db->select()->from($dummy->getTableName())
|
||||
->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())
|
||||
->where('object_type = ?', 'template');
|
||||
} else {
|
||||
|
|
|
@ -93,7 +93,7 @@ class IcingaDependency extends IcingaObject implements ExportInterface
|
|||
$object = static::load($key, $db);
|
||||
} elseif (static::exists($key, $db)) {
|
||||
throw new DuplicateKeyException(
|
||||
'Service Template "%s" already exists',
|
||||
'Dependency "%s" already exists',
|
||||
$name
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
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';
|
||||
|
||||
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue