From 24d018a0588616a99a3fcbeea0255bbd7646883a Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 30 Oct 2013 09:55:00 +0100 Subject: [PATCH] Fix short_name and display_name properties. Refs #4973 --- lib/icinga/host.ti | 9 +++++++-- lib/icinga/hostgroup.ti | 9 +++++++-- lib/icinga/service.ti | 7 ++++++- lib/icinga/servicegroup.ti | 9 +++++++-- lib/icinga/timeperiod.ti | 9 +++++++-- lib/icinga/user.ti | 9 +++++++-- lib/icinga/usergroup.ti | 9 +++++++-- 7 files changed, 48 insertions(+), 13 deletions(-) diff --git a/lib/icinga/host.ti b/lib/icinga/host.ti index bef23f4d5..a190c03a2 100644 --- a/lib/icinga/host.ti +++ b/lib/icinga/host.ti @@ -32,7 +32,12 @@ enum StateType class Host : DynamicObject { [config] String display_name { - default {{{ return GetName(); }}} + get {{{ + if (m_DisplayName.IsEmpty()) + return GetName(); + else + return m_DisplayName; + }}} }; [config] Array::Ptr groups; [config] Dictionary::Ptr macros; @@ -42,4 +47,4 @@ class Host : DynamicObject [config, protected] Dictionary::Ptr services (ServiceDescriptions); }; -} \ No newline at end of file +} diff --git a/lib/icinga/hostgroup.ti b/lib/icinga/hostgroup.ti index cf1cd8eaa..71693eb3b 100644 --- a/lib/icinga/hostgroup.ti +++ b/lib/icinga/hostgroup.ti @@ -6,8 +6,13 @@ namespace icinga class HostGroup : DynamicObject { [config] String display_name { - default {{{ return GetName(); }}} + get {{{ + if (m_DisplayName.IsEmpty()) + return GetName(); + else + return m_DisplayName; + }}} }; }; -} \ No newline at end of file +} diff --git a/lib/icinga/service.ti b/lib/icinga/service.ti index 4b2e6313b..6122b8313 100644 --- a/lib/icinga/service.ti +++ b/lib/icinga/service.ti @@ -48,7 +48,12 @@ class Service : DynamicObject [config] String event_command (EventCommandRaw); [config] bool volatile; [config] String short_name { - default {{{ return GetName(); }}} + get {{{ + if (m_ShortName.IsEmpty()) + return GetName(); + else + return m_ShortName; + }}} }; [config] String host (HostRaw); [config] double flapping_threshold { diff --git a/lib/icinga/servicegroup.ti b/lib/icinga/servicegroup.ti index 613b14c73..c07fb4593 100644 --- a/lib/icinga/servicegroup.ti +++ b/lib/icinga/servicegroup.ti @@ -6,8 +6,13 @@ namespace icinga class ServiceGroup : DynamicObject { [config] String display_name { - default {{{ return GetName(); }}} + get {{{ + if (m_DisplayName.IsEmpty()) + return GetName(); + else + return m_DisplayName; + }}} }; }; -} \ No newline at end of file +} diff --git a/lib/icinga/timeperiod.ti b/lib/icinga/timeperiod.ti index 399931855..24e969832 100644 --- a/lib/icinga/timeperiod.ti +++ b/lib/icinga/timeperiod.ti @@ -6,7 +6,12 @@ namespace icinga class TimePeriod : DynamicObject { [config] String display_name { - default {{{ return GetName(); }}} + get {{{ + if (m_DisplayName.IsEmpty()) + return GetName(); + else + return m_DisplayName; + }}} }; [config] Dictionary::Ptr ranges; [state] Value valid_begin; @@ -14,4 +19,4 @@ class TimePeriod : DynamicObject [state] Array::Ptr segments; }; -} \ No newline at end of file +} diff --git a/lib/icinga/user.ti b/lib/icinga/user.ti index 977d389ad..596d45c69 100644 --- a/lib/icinga/user.ti +++ b/lib/icinga/user.ti @@ -6,7 +6,12 @@ namespace icinga class User : DynamicObject { [config] String display_name { - default {{{ return GetName(); }}} + get {{{ + if (m_DisplayName.IsEmpty()) + return GetName(); + else + return m_DisplayName; + }}} }; [config] Dictionary::Ptr macros; [config] Array::Ptr groups; @@ -21,4 +26,4 @@ class User : DynamicObject [state] double last_notification; }; -} \ No newline at end of file +} diff --git a/lib/icinga/usergroup.ti b/lib/icinga/usergroup.ti index c6f7f280e..ebdf73f1f 100644 --- a/lib/icinga/usergroup.ti +++ b/lib/icinga/usergroup.ti @@ -6,8 +6,13 @@ namespace icinga class UserGroup : DynamicObject { [config] String display_name { - default {{{ return GetName(); }}} + get {{{ + if (m_DisplayName.IsEmpty()) + return GetName(); + else + return m_DisplayName; + }}} }; }; -} \ No newline at end of file +}