From 274e787cb4ec40fdd58a22dbbbd10c089d7c57be Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 8 Sep 2016 18:02:47 +0000 Subject: [PATCH] CLI/service: fix issues with multi-column key fixes #12014 fixes #12673 --- application/clicommands/ServiceCommand.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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', + ); + } + } }