IcingaService: render assigned to host template

This commit is contained in:
Thomas Gelf 2016-03-06 14:21:18 +01:00
parent e5429ab1f3
commit 51916192a9
1 changed files with 41 additions and 0 deletions

View File

@ -2,6 +2,8 @@
namespace Icinga\Module\Director\Objects;
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
class IcingaService extends IcingaObject
{
protected $table = 'icinga_service';
@ -97,6 +99,45 @@ class IcingaService extends IcingaObject
return $this->renderRelationProperty('host', $this->host_id, 'host_name');
}
protected function renderObjectHeader()
{
if ($this->hasBeenAssignedToHostTemplate()) {
return sprintf(
"%s %s %s {\n",
'apply',
$this->getType(),
c::renderString($this->getObjectName())
);
} else {
return parent::renderObjectHeader();
}
}
protected function renderAssignments()
{
if (! $this->hasBeenAssignedToHostTemplate()) {
return parent::renderAssignments();
}
// TODO: use assignment renderer, escape host
$filter = sprintf(
'assign where "%s" in host.templates',
$this->host
);
return "\n " . $filter . "\n";
}
protected function hasBeenAssignedToHostTemplate()
{
return $this->host_id && $this->getRelatedObject(
'host',
$this->host_id
)->object_type === 'template';
}
protected function renderCustomExtensions()
{
if ($this->command_endpoint_id !== null