Skip to content

Commit

Permalink
Ignore settings from instances.ini that don't have a setter on the tr…
Browse files Browse the repository at this point in the history
…ansport class used

fixes #8543
  • Loading branch information
lippserd committed Mar 13, 2015
1 parent 9f0af66 commit 32487e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Expand Up @@ -73,7 +73,10 @@ public static function fromConfig(ConfigObject $config)
foreach ($config as $key => $value) {
$method = 'set' . ucfirst($key);
if (! method_exists($transport, $method)) {
throw new ConfigurationError();
// Ignore settings from config that don't have a setter on the transport instead of throwing an
// exception here because the transport should throw an exception if it's not fully set up
// when being about to send a command
continue;
}
$transport->$method($value);
}
Expand Down
Expand Up @@ -4,8 +4,8 @@
namespace Icinga\Module\Monitoring\Command\Transport;

use Exception;
use LogicException;
use Icinga\Application\Logger;
use Icinga\Exception\ConfigurationError;
use Icinga\Module\Monitoring\Command\Exception\TransportException;
use Icinga\Module\Monitoring\Command\IcingaCommand;
use Icinga\Module\Monitoring\Command\Renderer\IcingaCommandFileCommandRenderer;
Expand Down Expand Up @@ -102,13 +102,15 @@ public function getOpenMode()
* @param IcingaCommand $command
* @param int|null $now
*
* @throws LogicException
* @throws ConfigurationError
* @throws TransportException
*/
public function send(IcingaCommand $command, $now = null)
{
if (! isset($this->path)) {
throw new LogicException('Can\'t send external Icinga Command. Path to the local command file is missing');
throw new ConfigurationError(
'Can\'t send external Icinga Command. Path to the local command file is missing'
);
}
$commandString = $this->renderer->render($command, $now);
Logger::debug(
Expand Down
Expand Up @@ -3,8 +3,8 @@

namespace Icinga\Module\Monitoring\Command\Transport;

use LogicException;
use Icinga\Application\Logger;
use Icinga\Exception\ConfigurationError;
use Icinga\Module\Monitoring\Command\Exception\TransportException;
use Icinga\Module\Monitoring\Command\IcingaCommand;
use Icinga\Module\Monitoring\Command\Renderer\IcingaCommandFileCommandRenderer;
Expand Down Expand Up @@ -166,16 +166,18 @@ public function getPath()
* @param IcingaCommand $command
* @param int|null $now
*
* @throws LogicException
* @throws ConfigurationError
* @throws TransportException
*/
public function send(IcingaCommand $command, $now = null)
{
if (! isset($this->path)) {
throw new LogicException('Can\'t send external Icinga Command. Path to the remote command file is missing');
throw new ConfigurationError(
'Can\'t send external Icinga Command. Path to the remote command file is missing'
);
}
if (! isset($this->host)) {
throw new LogicException('Can\'t send external Icinga Command. Remote host is missing');
throw new ConfigurationError('Can\'t send external Icinga Command. Remote host is missing');
}
$commandString = $this->renderer->render($command, $now);
Logger::debug(
Expand Down

0 comments on commit 32487e4

Please sign in to comment.