mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
ServiceCommand: extract override-logic
This commit is contained in:
parent
706a9b1fc1
commit
02bed9265a
@ -18,8 +18,16 @@ class ServiceCommand extends ObjectCommand
|
||||
public function setAction()
|
||||
{
|
||||
if (($host = $this->params->get('host')) && $this->params->shift('allow-overrides')) {
|
||||
$this->setServiceProperties($host);
|
||||
}
|
||||
|
||||
parent::setAction();
|
||||
}
|
||||
|
||||
protected function setServiceProperties($hostname)
|
||||
{
|
||||
$name = $this->getName();
|
||||
$host = IcingaHost::load($host, $this->db());
|
||||
$host = IcingaHost::load($hostname, $this->db());
|
||||
$service = ServiceFinder::find($host, $name);
|
||||
if ($service->requiresOverrides()) {
|
||||
$this->params->shift('host');
|
||||
@ -43,10 +51,10 @@ class ServiceCommand extends ObjectCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($appends)) {
|
||||
if (!empty($appends)) {
|
||||
throw new RuntimeException('--append- is not available for Variable Overrides');
|
||||
}
|
||||
if (! empty($remove)) {
|
||||
if (!empty($remove)) {
|
||||
throw new RuntimeException('--remove- is not available for Variable Overrides');
|
||||
}
|
||||
// Alternative, untested:
|
||||
@ -58,9 +66,6 @@ class ServiceCommand extends ObjectCommand
|
||||
}
|
||||
}
|
||||
|
||||
parent::setAction();
|
||||
}
|
||||
|
||||
protected static function assertVarsForOverrides($properties)
|
||||
{
|
||||
if (empty($properties)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user