From 28c29c1fbc6cd6239390eaf9663b0242c000af9c Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 20 Jun 2022 15:25:40 +0200 Subject: [PATCH] Don't allow to change object parent,host/service_name at runtime --- lib/icinga/comment.ti | 4 ++-- lib/icinga/dependency.ti | 8 ++++---- lib/icinga/downtime.ti | 4 ++-- lib/icinga/notification.ti | 4 ++-- lib/icinga/scheduleddowntime.ti | 4 ++-- lib/icinga/service.ti | 2 +- lib/remote/zone.ti | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/icinga/comment.ti b/lib/icinga/comment.ti index 853c28fac..b8ad6f7f2 100644 --- a/lib/icinga/comment.ti +++ b/lib/icinga/comment.ti @@ -34,12 +34,12 @@ class Comment : ConfigObject < CommentNameComposer load_after Host; load_after Service; - [config, protected, required, navigation(host)] name(Host) host_name { + [config, no_user_modify, protected, required, navigation(host)] name(Host) host_name { navigate {{{ return Host::GetByName(GetHostName()); }}} }; - [config, protected, navigation(service)] String service_name { + [config, no_user_modify, protected, navigation(service)] String service_name { track {{{ if (!oldValue.IsEmpty()) { Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue); diff --git a/lib/icinga/dependency.ti b/lib/icinga/dependency.ti index 10e2aae3d..3fc832522 100644 --- a/lib/icinga/dependency.ti +++ b/lib/icinga/dependency.ti @@ -23,13 +23,13 @@ class Dependency : CustomVarObject < DependencyNameComposer load_after Host; load_after Service; - [config, required, navigation(child_host)] name(Host) child_host_name { + [config, no_user_modify, required, navigation(child_host)] name(Host) child_host_name { navigate {{{ return Host::GetByName(GetChildHostName()); }}} }; - [config, navigation(child_service)] String child_service_name { + [config, no_user_modify, navigation(child_service)] String child_service_name { track {{{ if (!oldValue.IsEmpty()) { Service::Ptr service = Service::GetByNamePair(GetChildHostName(), oldValue); @@ -50,13 +50,13 @@ class Dependency : CustomVarObject < DependencyNameComposer }}} }; - [config, required, navigation(parent_host)] name(Host) parent_host_name { + [config, no_user_modify, required, navigation(parent_host)] name(Host) parent_host_name { navigate {{{ return Host::GetByName(GetParentHostName()); }}} }; - [config, navigation(parent_service)] String parent_service_name { + [config, no_user_modify, navigation(parent_service)] String parent_service_name { track {{{ if (!oldValue.IsEmpty()) { Service::Ptr service = Service::GetByNamePair(GetParentHostName(), oldValue); diff --git a/lib/icinga/downtime.ti b/lib/icinga/downtime.ti index 9fe182392..21e97313e 100644 --- a/lib/icinga/downtime.ti +++ b/lib/icinga/downtime.ti @@ -25,12 +25,12 @@ class Downtime : ConfigObject < DowntimeNameComposer load_after Host; load_after Service; - [config, required, navigation(host)] name(Host) host_name { + [config, no_user_modify, required, navigation(host)] name(Host) host_name { navigate {{{ return Host::GetByName(GetHostName()); }}} }; - [config, navigation(service)] String service_name { + [config, no_user_modify, navigation(service)] String service_name { track {{{ if (!oldValue.IsEmpty()) { Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue); diff --git a/lib/icinga/notification.ti b/lib/icinga/notification.ti index ab633c5dc..485360757 100644 --- a/lib/icinga/notification.ti +++ b/lib/icinga/notification.ti @@ -43,12 +43,12 @@ class Notification : CustomVarObject < NotificationNameComposer [no_user_view, no_user_modify] int type_filter_real (TypeFilter); [config] array(Value) states; [no_user_view, no_user_modify] int state_filter_real (StateFilter); - [config, protected, required, navigation(host)] name(Host) host_name { + [config, no_user_modify, protected, required, navigation(host)] name(Host) host_name { navigate {{{ return Host::GetByName(GetHostName()); }}} }; - [config, protected, navigation(service)] String service_name { + [config, protected, no_user_modify, navigation(service)] String service_name { track {{{ if (!oldValue.IsEmpty()) { Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue); diff --git a/lib/icinga/scheduleddowntime.ti b/lib/icinga/scheduleddowntime.ti index 7dfb8bf39..1653f27e7 100644 --- a/lib/icinga/scheduleddowntime.ti +++ b/lib/icinga/scheduleddowntime.ti @@ -26,12 +26,12 @@ class ScheduledDowntime : CustomVarObject < ScheduledDowntimeNameComposer load_after Host; load_after Service; - [config, protected, required, navigation(host)] name(Host) host_name { + [config, protected, no_user_modify, required, navigation(host)] name(Host) host_name { navigate {{{ return Host::GetByName(GetHostName()); }}} }; - [config, protected, navigation(service)] String service_name { + [config, protected, no_user_modify, navigation(service)] String service_name { track {{{ if (!oldValue.IsEmpty()) { Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue); diff --git a/lib/icinga/service.ti b/lib/icinga/service.ti index bbd241241..12c2d8c66 100644 --- a/lib/icinga/service.ti +++ b/lib/icinga/service.ti @@ -40,7 +40,7 @@ class Service : Checkable < ServiceNameComposer return displayName; }}} }; - [config, required] name(Host) host_name; + [config, no_user_modify, required] name(Host) host_name; [no_storage, navigation] Host::Ptr host { get; navigate {{{ diff --git a/lib/remote/zone.ti b/lib/remote/zone.ti index 53fd4e609..25f6a642d 100644 --- a/lib/remote/zone.ti +++ b/lib/remote/zone.ti @@ -9,7 +9,7 @@ namespace icinga class Zone : ConfigObject { - [config, navigation] name(Zone) parent (ParentRaw) { + [config, no_user_modify, navigation] name(Zone) parent (ParentRaw) { navigate {{{ return Zone::GetByName(GetParentRaw()); }}}