]> granicus.if.org Git - icinga2/blobdiff - components/livestatus/servicestable.cpp
Use legacy attribute getters in interfaces.
[icinga2] / components / livestatus / servicestable.cpp
index 0fa3bfef2d29a1836e8f7dcaad7f0e7761fa7d75..a6af0e09ff596d9ea962ae09c48e05e2049e2c92 100644 (file)
@@ -280,7 +280,7 @@ Value ServicesTable::NotificationPeriodAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceNotificationNotificationPeriod(service);
+       return CompatUtility::GetCheckableNotificationNotificationPeriod(service);
 }
 
 Value ServicesTable::CheckPeriodAccessor(const Value& row)
@@ -290,7 +290,7 @@ Value ServicesTable::CheckPeriodAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceCheckPeriod(service);
+       return CompatUtility::GetCheckableCheckPeriod(service);
 }
 
 Value ServicesTable::NotesAccessor(const Value& row)
@@ -300,7 +300,7 @@ Value ServicesTable::NotesAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCustomAttributeConfig(service, "notes");
+       return service->GetNotes();
 }
 
 Value ServicesTable::NotesExpandedAccessor(const Value& row)
@@ -310,14 +310,12 @@ Value ServicesTable::NotesExpandedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       std::vector<MacroResolver::Ptr> resolvers;
-       resolvers.push_back(service);
-       resolvers.push_back(service->GetHost());
-       resolvers.push_back(IcingaApplication::GetInstance());
+       MacroProcessor::ResolverList resolvers;
+       resolvers.push_back(std::make_pair("service", service));
+       resolvers.push_back(std::make_pair("host", service->GetHost()));
+       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
 
-       Value value = CompatUtility::GetCustomAttributeConfig(service, "notes");
-
-       return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
+       return MacroProcessor::ResolveMacros(service->GetNotes(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
 }
 
 Value ServicesTable::NotesUrlAccessor(const Value& row)
@@ -327,7 +325,7 @@ Value ServicesTable::NotesUrlAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCustomAttributeConfig(service, "notes_url");
+       return service->GetNotesUrl();
 }
 
 Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
@@ -337,14 +335,12 @@ Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       std::vector<MacroResolver::Ptr> resolvers;
-       resolvers.push_back(service);
-       resolvers.push_back(service->GetHost());
-       resolvers.push_back(IcingaApplication::GetInstance());
-
-       Value value = CompatUtility::GetCustomAttributeConfig(service, "notes_url");
+       MacroProcessor::ResolverList resolvers;
+       resolvers.push_back(std::make_pair("service", service));
+       resolvers.push_back(std::make_pair("host", service->GetHost()));
+       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
 
-       return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
+       return MacroProcessor::ResolveMacros(service->GetNotesUrl(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
 }
 
 Value ServicesTable::ActionUrlAccessor(const Value& row)
@@ -354,7 +350,7 @@ Value ServicesTable::ActionUrlAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCustomAttributeConfig(service, "action_url");
+       return service->GetActionUrl();
 }
 
 Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
@@ -364,14 +360,12 @@ Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       std::vector<MacroResolver::Ptr> resolvers;
-       resolvers.push_back(service);
-       resolvers.push_back(service->GetHost());
-       resolvers.push_back(IcingaApplication::GetInstance());
-
-       Value value = CompatUtility::GetCustomAttributeConfig(service, "action_url");
+       MacroProcessor::ResolverList resolvers;
+       resolvers.push_back(std::make_pair("service", service));
+       resolvers.push_back(std::make_pair("host", service->GetHost()));
+       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
 
-       return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
+       return MacroProcessor::ResolveMacros(service->GetActionUrl(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
 }
 
 Value ServicesTable::IconImageAccessor(const Value& row)
@@ -381,7 +375,7 @@ Value ServicesTable::IconImageAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCustomAttributeConfig(service, "icon_image");
+       return service->GetIconImage();
 }
 
 Value ServicesTable::IconImageExpandedAccessor(const Value& row)
@@ -391,14 +385,12 @@ Value ServicesTable::IconImageExpandedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       std::vector<MacroResolver::Ptr> resolvers;
-       resolvers.push_back(service);
-       resolvers.push_back(service->GetHost());
-       resolvers.push_back(IcingaApplication::GetInstance());
+       MacroProcessor::ResolverList resolvers;
+       resolvers.push_back(std::make_pair("service", service));
+       resolvers.push_back(std::make_pair("host", service->GetHost()));
+       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
 
-       Value value = CompatUtility::GetCustomAttributeConfig(service, "icon_image");
-
-       return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
+       return MacroProcessor::ResolveMacros(service->GetIconImage(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
 }
 
 Value ServicesTable::IconImageAltAccessor(const Value& row)
@@ -408,7 +400,7 @@ Value ServicesTable::IconImageAltAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCustomAttributeConfig(service, "icon_image_alt");
+       return service->GetIconImageAlt();
 }
 
 Value ServicesTable::MaxCheckAttemptsAccessor(const Value& row)
@@ -438,7 +430,7 @@ Value ServicesTable::StateAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceCurrentState(service);
+       return service->GetState();
 }
 
 Value ServicesTable::HasBeenCheckedAccessor(const Value& row)
@@ -448,7 +440,7 @@ Value ServicesTable::HasBeenCheckedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceHasBeenChecked(service);
+       return CompatUtility::GetCheckableHasBeenChecked(service);
 }
 
 Value ServicesTable::LastStateAccessor(const Value& row)
@@ -488,7 +480,7 @@ Value ServicesTable::CheckTypeAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceCheckType(service);
+       return CompatUtility::GetCheckableCheckType(service);
 }
 
 Value ServicesTable::AcknowledgedAccessor(const Value& row)
@@ -498,8 +490,7 @@ Value ServicesTable::AcknowledgedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-
-       return CompatUtility::GetServiceIsAcknowledged(service);
+       return CompatUtility::GetCheckableIsAcknowledged(service);
 }
 
 Value ServicesTable::AcknowledgementTypeAccessor(const Value& row)
@@ -522,7 +513,7 @@ Value ServicesTable::NoMoreNotificationsAccessor(const Value& row)
        if (!service)
                return Empty;
 
-        return CompatUtility::GetServiceNoMoreNotifications(service);
+        return CompatUtility::GetCheckableNoMoreNotifications(service);
 }
 
 Value ServicesTable::LastTimeOkAccessor(const Value& row)
@@ -592,7 +583,7 @@ Value ServicesTable::LastNotificationAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceNotificationLastNotification(service);
+       return CompatUtility::GetCheckableNotificationLastNotification(service);
 }
 
 Value ServicesTable::NextNotificationAccessor(const Value& row)
@@ -602,7 +593,7 @@ Value ServicesTable::NextNotificationAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceNotificationNextNotification(service);
+       return CompatUtility::GetCheckableNotificationNextNotification(service);
 }
 
 Value ServicesTable::CurrentNotificationNumberAccessor(const Value& row)
@@ -612,7 +603,7 @@ Value ServicesTable::CurrentNotificationNumberAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceNotificationNotificationNumber(service);
+       return CompatUtility::GetCheckableNotificationNotificationNumber(service);
 }
 
 Value ServicesTable::LastStateChangeAccessor(const Value& row)
@@ -662,7 +653,7 @@ Value ServicesTable::ChecksEnabledAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceActiveChecksEnabled(service);
+       return CompatUtility::GetCheckableActiveChecksEnabled(service);
 }
 
 Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row)
@@ -672,7 +663,7 @@ Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServicePassiveChecksEnabled(service);
+       return CompatUtility::GetCheckablePassiveChecksEnabled(service);
 }
 
 Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
@@ -682,7 +673,7 @@ Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceEventHandlerEnabled(service);
+       return CompatUtility::GetCheckableEventHandlerEnabled(service);
 }
 
 Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
@@ -692,7 +683,7 @@ Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceNotificationsEnabled(service);
+       return CompatUtility::GetCheckableNotificationsEnabled(service);
 }
 
 Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row)
@@ -702,7 +693,7 @@ Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return  CompatUtility::GetServiceProcessPerformanceData(service);
+       return CompatUtility::GetCheckableProcessPerformanceData(service);
 }
 
 Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row)
@@ -712,7 +703,7 @@ Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceActiveChecksEnabled(service);
+       return CompatUtility::GetCheckableActiveChecksEnabled(service);
 }
 
 Value ServicesTable::CheckOptionsAccessor(const Value& row)
@@ -728,7 +719,7 @@ Value ServicesTable::FlapDetectionEnabledAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceFlapDetectionEnabled(service);
+       return CompatUtility::GetCheckableFlapDetectionEnabled(service);
 }
 
 Value ServicesTable::CheckFreshnessAccessor(const Value& row)
@@ -738,7 +729,7 @@ Value ServicesTable::CheckFreshnessAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceFreshnessChecksEnabled(service);
+       return CompatUtility::GetCheckableFreshnessChecksEnabled(service);
 }
 
 Value ServicesTable::ModifiedAttributesAccessor(const Value& row)
@@ -764,7 +755,7 @@ Value ServicesTable::StalenessAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceStaleness(service);
+       return CompatUtility::GetCheckableStaleness(service);
 }
 
 Value ServicesTable::CheckIntervalAccessor(const Value& row)
@@ -774,7 +765,7 @@ Value ServicesTable::CheckIntervalAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceCheckInterval(service);
+       return CompatUtility::GetCheckableCheckInterval(service);
 }
 
 Value ServicesTable::RetryIntervalAccessor(const Value& row)
@@ -784,7 +775,7 @@ Value ServicesTable::RetryIntervalAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceRetryInterval(service);
+       return CompatUtility::GetCheckableRetryInterval(service);
 }
 
 Value ServicesTable::NotificationIntervalAccessor(const Value& row)
@@ -794,7 +785,7 @@ Value ServicesTable::NotificationIntervalAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceNotificationNotificationInterval(service);
+       return CompatUtility::GetCheckableNotificationNotificationInterval(service);
 }
 
 Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
@@ -804,7 +795,7 @@ Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceLowFlapThreshold(service);
+       return CompatUtility::GetCheckableLowFlapThreshold(service);
 }
 
 Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
@@ -814,7 +805,7 @@ Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceHighFlapThreshold(service);
+       return CompatUtility::GetCheckableHighFlapThreshold(service);
 }
 
 Value ServicesTable::LatencyAccessor(const Value& row)
@@ -844,7 +835,7 @@ Value ServicesTable::PercentStateChangeAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServicePercentStateChange(service);
+       return CompatUtility::GetCheckablePercentStateChange(service);
 }
 
 Value ServicesTable::InCheckPeriodAccessor(const Value& row)
@@ -854,7 +845,7 @@ Value ServicesTable::InCheckPeriodAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceInCheckPeriod(service);
+       return CompatUtility::GetCheckableInCheckPeriod(service);
 }
 
 Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
@@ -864,7 +855,7 @@ Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetServiceInNotificationPeriod(service);
+       return CompatUtility::GetCheckableInNotificationPeriod(service);
 }
 
 Value ServicesTable::ContactsAccessor(const Value& row)
@@ -876,7 +867,7 @@ Value ServicesTable::ContactsAccessor(const Value& row)
 
        Array::Ptr contact_names = make_shared<Array>();
 
-       BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetServiceNotificationUsers(service)) {
+       BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(service)) {
                contact_names->Add(user->GetName());
        }
 
@@ -898,7 +889,7 @@ Value ServicesTable::DowntimesAccessor(const Value& row)
 
        String id;
        Downtime::Ptr downtime;
-       BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
+       BOOST_FOREACH(tie(id, downtime), downtimes) {
 
                if (!downtime)
                        continue;
@@ -927,7 +918,7 @@ Value ServicesTable::DowntimesWithInfoAccessor(const Value& row)
 
        String id;
        Downtime::Ptr downtime;
-       BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
+       BOOST_FOREACH(tie(id, downtime), downtimes) {
 
                if (!downtime)
                        continue;
@@ -960,7 +951,7 @@ Value ServicesTable::CommentsAccessor(const Value& row)
 
        String id;
        Comment::Ptr comment;
-       BOOST_FOREACH(boost::tie(id, comment), comments) {
+       BOOST_FOREACH(tie(id, comment), comments) {
 
                if (!comment)
                        continue;
@@ -989,7 +980,7 @@ Value ServicesTable::CommentsWithInfoAccessor(const Value& row)
 
        String id;
        Comment::Ptr comment;
-       BOOST_FOREACH(boost::tie(id, comment), comments) {
+       BOOST_FOREACH(tie(id, comment), comments) {
 
                if (!comment)
                        continue;
@@ -1022,7 +1013,7 @@ Value ServicesTable::CommentsWithExtraInfoAccessor(const Value& row)
 
        String id;
        Comment::Ptr comment;
-       BOOST_FOREACH(boost::tie(id, comment), comments) {
+       BOOST_FOREACH(tie(id, comment), comments) {
 
                if (!comment)
                        continue;
@@ -1063,7 +1054,7 @@ Value ServicesTable::CustomVariableNamesAccessor(const Value& row)
 
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), vars) {
+       BOOST_FOREACH(tie(key, value), vars) {
                cv->Add(key);
        }
 
@@ -1091,7 +1082,7 @@ Value ServicesTable::CustomVariableValuesAccessor(const Value& row)
 
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), vars) {
+       BOOST_FOREACH(tie(key, value), vars) {
                cv->Add(value);
        }
 
@@ -1119,7 +1110,7 @@ Value ServicesTable::CustomVariablesAccessor(const Value& row)
 
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), vars) {
+       BOOST_FOREACH(tie(key, value), vars) {
                Array::Ptr key_val = make_shared<Array>();
                key_val->Add(key);
                key_val->Add(value);
@@ -1153,7 +1144,7 @@ Value ServicesTable::ContactGroupsAccessor(const Value& row)
 
        Array::Ptr contactgroup_names = make_shared<Array>();
 
-       BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetServiceNotificationUserGroups(service)) {
+       BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(service)) {
                contactgroup_names->Add(usergroup->GetName());
        }