diff --git a/application/clicommands/ServiceCommand.php b/application/clicommands/ServiceCommand.php index 194cfe78..a485ba1a 100644 --- a/application/clicommands/ServiceCommand.php +++ b/application/clicommands/ServiceCommand.php @@ -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', + ); + } + } }