[icinga-checkins] icinga.org: icingaweb2-module-director/bugfix/service-set-contraints-13309 : IcingaServiceSet: Check if object_name is unique for templates
git at icinga.org
git at icinga.org
Mon Nov 28 16:53:51 CET 2016
Module: icingaweb2-module-director
Branch: bugfix/service-set-contraints-13309
Commit: 3a8cad248612f2eb499e5b4880acfc04bb5e30c3
URL: https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=3a8cad248612f2eb499e5b4880acfc04bb5e30c3
Author: Markus Frosch <markus.frosch at icinga.com>
Date: Thu Nov 24 17:39:51 2016 +0100
IcingaServiceSet: Check if object_name is unique for templates
refs #13309
---
library/Director/Objects/IcingaServiceSet.php | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/library/Director/Objects/IcingaServiceSet.php b/library/Director/Objects/IcingaServiceSet.php
index 4251a26..214de13 100644
--- a/library/Director/Objects/IcingaServiceSet.php
+++ b/library/Director/Objects/IcingaServiceSet.php
@@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Objects;
use Icinga\Data\Filter\Filter;
use Icinga\Exception\IcingaException;
+use Icinga\Module\Director\Exception\DuplicateKeyException;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
@@ -249,4 +250,17 @@ class IcingaServiceSet extends IcingaObject
return $host->getRenderingZone($config);
}
}
+
+ protected function beforeStore()
+ {
+ parent::beforeStore();
+
+ $name = $this->getObjectName();
+
+ // checking if template object_name is unique
+ // TODO: Move to IcingaObject
+ if (! $this->hasBeenLoadedFromDb() && $this->isTemplate() && static::exists($name, $this->connection)) {
+ throw new DuplicateKeyException('%s template "%s" already existing in database!', $this->getType(), $name);
+ }
+ }
}
More information about the icinga-checkins
mailing list