IcingaServiceSet: A simple key identifies a ServiceSet (template)

refs #12891
This commit is contained in:
Markus Frosch 2016-11-10 14:04:05 +01:00
parent b08f3df882
commit ddd59ab274
1 changed files with 21 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Objects;
use Icinga\Data\Filter\Filter;
use Icinga\Exception\IcingaException;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
@ -43,6 +44,26 @@ class IcingaServiceSet extends IcingaObject
return true;
}
protected function setKey($key)
{
if (is_int($key)) {
$this->id = $key;
} elseif (is_string($key)) {
$keyComponents = preg_split('~!~', $key);
if (count($keyComponents) === 1) {
$this->set('object_name', $keyComponents[0]);
$this->set('object_type', 'template');
}
else {
throw new IcingaException('Can not parse key: %s', $key);
}
} else {
return parent::setKey($key);
}
return $this;
}
/**
* @return IcingaService[]
*/