CLI/service: fix issues with multi-column key

fixes #12014
fixes #12673
This commit is contained in:
Thomas Gelf 2016-09-08 18:02:47 +00:00
parent cc722578b6
commit 274e787cb4

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Clicommands;
use Icinga\Module\Director\Cli\ObjectCommand;
use Icinga\Module\Director\Objects\IcingaHost;
/**
* Manage Icinga Services
@ -12,4 +13,29 @@ use Icinga\Module\Director\Cli\ObjectCommand;
*/
class ServiceCommand extends ObjectCommand
{
protected function load($name)
{
return parent::load($this->makeServiceKey($this->getName()));
}
protected function exists($name)
{
return parent::exists($this->makeServiceKey($this->getName()));
}
protected function makeServiceKey($name)
{
if ($host = $this->params->get('host')) {
return array(
'object_name' => $name,
'host_id' => IcingaHost::load($host, $this->db())->id,
);
} else {
return array(
'object_name' => $name,
'object_type' => 'template',
);
}
}
}