mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 08:14:04 +02:00
IcingaConfig/IcingaObject(Legacy): Render dummy notification settings
So we avoid warnings about nothing configured. refs #13049
This commit is contained in:
parent
03e177bea4
commit
aaeca533fc
@ -500,6 +500,15 @@ class IcingaConfig
|
|||||||
protected function prepareGlobalBasics()
|
protected function prepareGlobalBasics()
|
||||||
{
|
{
|
||||||
if ($this->isLegacy()) {
|
if ($this->isLegacy()) {
|
||||||
|
$this->configFile(
|
||||||
|
sprintf(
|
||||||
|
'director/%s/001-director-basics',
|
||||||
|
$this->connection->getDefaultGlobalZoneName()
|
||||||
|
), '.cfg'
|
||||||
|
)->prepend(
|
||||||
|
$this->renderLegacyDefaultNotification()
|
||||||
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -781,4 +790,39 @@ apply Service for (title => params in host.vars["%s"]) {
|
|||||||
|
|
||||||
return $this->lastActivityChecksum;
|
return $this->lastActivityChecksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function renderLegacyDefaultNotification()
|
||||||
|
{
|
||||||
|
return preg_replace('~^ {12}~m', '', '
|
||||||
|
#
|
||||||
|
# Default objects to avoid warnings
|
||||||
|
#
|
||||||
|
|
||||||
|
define contact {
|
||||||
|
contact_name icingaadmin
|
||||||
|
alias Icinga Admin
|
||||||
|
host_notifications_enabled 0
|
||||||
|
host_notification_commands notify-never-default
|
||||||
|
host_notification_period notification_none
|
||||||
|
service_notifications_enabled 0
|
||||||
|
service_notification_commands notify-never-default
|
||||||
|
service_notification_period notification_none
|
||||||
|
}
|
||||||
|
|
||||||
|
define contactgroup {
|
||||||
|
contactgroup_name icingaadmins
|
||||||
|
members icingaadmin
|
||||||
|
}
|
||||||
|
|
||||||
|
define timeperiod {
|
||||||
|
timeperiod_name notification_none
|
||||||
|
alias No Notifications
|
||||||
|
}
|
||||||
|
|
||||||
|
define command {
|
||||||
|
command_name notify-never-default
|
||||||
|
command_line /bin/echo "NOOP"
|
||||||
|
}
|
||||||
|
');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2054,6 +2054,16 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
{
|
{
|
||||||
$str = '';
|
$str = '';
|
||||||
|
|
||||||
|
// Set notification settings for the object to suppress warnings
|
||||||
|
if (
|
||||||
|
array_key_exists('enable_notifications', $this->defaultProperties)
|
||||||
|
&& $this->isTemplate()
|
||||||
|
) {
|
||||||
|
$str .= c1::renderKeyValue('notification_period', 'notification_none');
|
||||||
|
$str .= c1::renderKeyValue('notification_interval', '0');
|
||||||
|
$str .= c1::renderKeyValue('contact_groups', 'icingaadmins');
|
||||||
|
}
|
||||||
|
|
||||||
// force rendering of check_command when ARG1 is set
|
// force rendering of check_command when ARG1 is set
|
||||||
if ($this->supportsCustomVars() && array_key_exists('check_command_id', $this->defaultProperties)) {
|
if ($this->supportsCustomVars() && array_key_exists('check_command_id', $this->defaultProperties)) {
|
||||||
if (
|
if (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user