From c8b3fde2efd90c2cea95bb7e0a9d5256db4959ba Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 22 Apr 2014 13:48:06 +0200 Subject: [PATCH] Drop unused statusmap_image & coords attributes entirely. Fixes #6044 --- components/compat/statusdatawriter.cpp | 3 -- components/livestatus/hoststable.cpp | 36 ++----------- components/livestatus/hoststable.h | 3 -- doc/2.5-setting-up-icinga2-uis.md | 3 +- doc/4.3-object-types.md | 4 -- doc/8-differences-between-icinga-1x-and-2.md | 20 ++------ lib/db_ido/hostdbobject.cpp | 13 ----- lib/icinga/compatutility.cpp | 54 +------------------- lib/icinga/compatutility.h | 12 ----- 9 files changed, 9 insertions(+), 139 deletions(-) diff --git a/components/compat/statusdatawriter.cpp b/components/compat/statusdatawriter.cpp index c0101a4bd..d45dc1317 100644 --- a/components/compat/statusdatawriter.cpp +++ b/components/compat/statusdatawriter.cpp @@ -235,7 +235,6 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host) String action_url = host->GetActionUrl(); String icon_image = host->GetIconImage(); String icon_image_alt = host->GetIconImageAlt(); - String statusmap_image = CompatUtility::GetCustomAttributeConfig(host, "statusmap_image"); String display_name = host->GetDisplayName(); String address = host->GetAddress(); String address6 = host->GetAddress6(); @@ -260,8 +259,6 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host) fp << "\t" "icon_image" "\t" << icon_image << "\n"; if (!icon_image_alt.IsEmpty()) fp << "\t" "icon_image_alt" "\t" << icon_image_alt << "\n"; - if (!statusmap_image.IsEmpty()) - fp << "\t" "statusmap_image" "\t" << statusmap_image << "\n"; std::set parents = host->GetParents(); diff --git a/components/livestatus/hoststable.cpp b/components/livestatus/hoststable.cpp index 5077438c1..e3faadc0d 100644 --- a/components/livestatus/hoststable.cpp +++ b/components/livestatus/hoststable.cpp @@ -67,7 +67,7 @@ void HostsTable::AddColumns(Table *table, const String& prefix, table->AddColumn(prefix + "icon_image", Column(&HostsTable::IconImageAccessor, objectAccessor)); table->AddColumn(prefix + "icon_image_expanded", Column(&HostsTable::IconImageExpandedAccessor, objectAccessor)); table->AddColumn(prefix + "icon_image_alt", Column(&HostsTable::IconImageAltAccessor, objectAccessor)); - table->AddColumn(prefix + "statusmap_image", Column(&HostsTable::StatusmapImageAccessor, objectAccessor)); + table->AddColumn(prefix + "statusmap_image", Column(&Table::EmptyStringAccessor, objectAccessor)); table->AddColumn(prefix + "long_plugin_output", Column(&HostsTable::LongPluginOutputAccessor, objectAccessor)); table->AddColumn(prefix + "initial_state", Column(&Table::EmptyStringAccessor, objectAccessor)); table->AddColumn(prefix + "max_check_attempts", Column(&HostsTable::MaxCheckAttemptsAccessor, objectAccessor)); @@ -118,8 +118,8 @@ void HostsTable::AddColumns(Table *table, const String& prefix, table->AddColumn(prefix + "x_3d", Column(&EmptyStringAccessor, objectAccessor)); table->AddColumn(prefix + "y_3d", Column(&EmptyStringAccessor, objectAccessor)); table->AddColumn(prefix + "z_3d", Column(&EmptyStringAccessor, objectAccessor)); - table->AddColumn(prefix + "x_2d", Column(&HostsTable::X2dAccessor, objectAccessor)); - table->AddColumn(prefix + "y_2d", Column(&HostsTable::Y2dAccessor, objectAccessor)); + table->AddColumn(prefix + "x_2d", Column(&Table::EmptyStringAccessor, objectAccessor)); + table->AddColumn(prefix + "y_2d", Column(&Table::EmptyStringAccessor, objectAccessor)); table->AddColumn(prefix + "latency", Column(&HostsTable::LatencyAccessor, objectAccessor)); table->AddColumn(prefix + "execution_time", Column(&HostsTable::ExecutionTimeAccessor, objectAccessor)); table->AddColumn(prefix + "percent_state_change", Column(&HostsTable::PercentStateChangeAccessor, objectAccessor)); @@ -412,16 +412,6 @@ Value HostsTable::IconImageAltAccessor(const Value& row) return host->GetIconImageAlt(); } -Value HostsTable::StatusmapImageAccessor(const Value& row) -{ - Host::Ptr host = static_cast(row); - - if (!host) - return Empty; - - return CompatUtility::GetCustomAttributeConfig(host, "statusmap_image"); -} - Value HostsTable::LongPluginOutputAccessor(const Value& row) { Host::Ptr host = static_cast(row); @@ -814,26 +804,6 @@ Value HostsTable::HighFlapThresholdAccessor(const Value& row) return CompatUtility::GetCheckableHighFlapThreshold(host); } -Value HostsTable::X2dAccessor(const Value& row) -{ - Host::Ptr host = static_cast(row); - - if (!host) - return Empty; - - return CompatUtility::GetHost2dCoordX(host); -} - -Value HostsTable::Y2dAccessor(const Value& row) -{ - Host::Ptr host = static_cast(row); - - if (!host) - return Empty; - - return CompatUtility::GetHost2dCoordY(host); -} - Value HostsTable::LatencyAccessor(const Value& row) { Host::Ptr host = static_cast(row); diff --git a/components/livestatus/hoststable.h b/components/livestatus/hoststable.h index 88d5f9f65..1c821c2df 100644 --- a/components/livestatus/hoststable.h +++ b/components/livestatus/hoststable.h @@ -65,7 +65,6 @@ protected: static Value IconImageAccessor(const Value& row); static Value IconImageExpandedAccessor(const Value& row); static Value IconImageAltAccessor(const Value& row); - static Value StatusmapImageAccessor(const Value& row); static Value LongPluginOutputAccessor(const Value& row); static Value MaxCheckAttemptsAccessor(const Value& row); static Value FlapDetectionEnabledAccessor(const Value& row); @@ -106,8 +105,6 @@ protected: static Value NotificationIntervalAccessor(const Value& row); static Value LowFlapThresholdAccessor(const Value& row); static Value HighFlapThresholdAccessor(const Value& row); - static Value X2dAccessor(const Value& row); - static Value Y2dAccessor(const Value& row); static Value LatencyAccessor(const Value& row); static Value ExecutionTimeAccessor(const Value& row); static Value PercentStateChangeAccessor(const Value& row); diff --git a/doc/2.5-setting-up-icinga2-uis.md b/doc/2.5-setting-up-icinga2-uis.md index 38c4713cb..27b9ecc86 100644 --- a/doc/2.5-setting-up-icinga2-uis.md +++ b/doc/2.5-setting-up-icinga2-uis.md @@ -9,8 +9,7 @@ user interface. Some interface features will only work in a limited manner due to [compatibility reasons](#differences-1x-2), other features like the -statusmap parents are available through intelligent compatibility layers -for dumping the host dependencies as parents. +statusmap parents are available dumping the host dependencies as parents. Special restrictions are noted specifically in the sections below. > **Tip** diff --git a/doc/4.3-object-types.md b/doc/4.3-object-types.md index d467ddca8..a70916e39 100644 --- a/doc/4.3-object-types.md +++ b/doc/4.3-object-types.md @@ -52,10 +52,6 @@ Attributes: > The `address` and `address6` attributes are required for running commands using > the `$address$` and `$address6` runtime macros. -Unlike Icinga 1.x the `statusmap_image` and `2d_coords` attributes are -custom attributes only in Icinga 2. - - ### HostGroup A group of hosts. diff --git a/doc/8-differences-between-icinga-1x-and-2.md b/doc/8-differences-between-icinga-1x-and-2.md index 28c99b5ca..6f7860d61 100644 --- a/doc/8-differences-between-icinga-1x-and-2.md +++ b/doc/8-differences-between-icinga-1x-and-2.md @@ -168,29 +168,15 @@ Icinga 2 allows you to define custom attributes in the `vars` dictionary. The `notes`, `notes_url`, `action_url`, `icon_image`, `icon_image_alt` attributes for host and service objects are still available in Icinga 2. -### Statusmap Image, 2D Coords - -These attributes can be set using the `vars` dictionary in Icinga 2 `Host` -or `Service` objects: - - vars = { - "2d_coords" = "1,2" - statusmap_image = "../../images/logos/icinga.gif" - } - -External interfaces will recognize and display these attributes accordingly. +`2d_coords` and `statusmap_image` are not supported in Icinga 2. ### Custom Variables Icinga 1.x custom variable attributes must be prefixed using an underscore (`_`). In Icinga 2 these attributes must be added to the `vars` dictionary as custom attributes. - vars = { - DN = "cn=icinga2-dev-host,ou=icinga,ou=main,ou=IcingaConfig,ou=LConf,dc=icinga,dc=org" - CV = "my custom cmdb description" - } - -TODO + vars.dn = "cn=icinga2-dev-host,ou=icinga,ou=main,ou=IcingaConfig,ou=LConf,dc=icinga,dc=org" + vars.cv = "my custom cmdb description" ## Host Service Relation diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index 8b597e504..f3a167a02 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -102,19 +102,6 @@ Dictionary::Ptr HostDbObject::GetConfigFields(void) const fields->Set("action_url", host->GetActionUrl()); fields->Set("icon_image", host->GetIconImage()); fields->Set("icon_image_alt", host->GetIconImageAlt()); - fields->Set("statusmap_image", CompatUtility::GetCustomAttributeConfig(host, "statusmap_image")); - - Host2dCoords coords = CompatUtility::GetHost2dCoords(host); - - fields->Set("have_2d_coords", coords.have_2d_coords); - - if (coords.have_2d_coords) { - fields->Set("x_2d", coords.x_2d); - fields->Set("y_2d", coords.y_2d); - } - - /* deprecated in 1.x */ - fields->Set("have_3d_coords", 0); return fields; } diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index 92f67eca6..e115a4fe3 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -70,54 +70,6 @@ String CompatUtility::GetHostAlias(const Host::Ptr& host) return host->GetDisplayName(); } -Host2dCoords CompatUtility::GetHost2dCoords(const Host::Ptr& host) -{ - ASSERT(host->OwnsLock()); - - Dictionary::Ptr vars = host->GetVars(); - Host2dCoords bag; - - if (vars) { - String coords = vars->Get("2d_coords"); - bag.have_2d_coords = (!coords.IsEmpty() ? 1 : 0); - - std::vector tokens; - boost::algorithm::split(tokens, coords, boost::is_any_of(",")); - - if (tokens.size() != 2) - bag.have_2d_coords = 0; - - if (bag.have_2d_coords == 1) { - bag.x_2d = tokens[0]; - bag.y_2d = tokens[1]; - } - } else { - bag.have_2d_coords = 0; - } - - return bag; -} - -String CompatUtility::GetHost2dCoordX(const Host::Ptr& host) -{ - Host2dCoords bag = GetHost2dCoords(host); - - if (bag.have_2d_coords == 0) - return Empty; - - return bag.x_2d; -} - -String CompatUtility::GetHost2dCoordY(const Host::Ptr& host) -{ - Host2dCoords bag = GetHost2dCoords(host); - - if (bag.have_2d_coords == 0) - return Empty; - - return bag.y_2d; -} - int CompatUtility::GetHostNotifyOnDown(const Host::Ptr& host) { ASSERT(host->OwnsLock()); @@ -371,9 +323,7 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka bool CompatUtility::IsLegacyAttribute(DynamicObject::Ptr const& object, const String& name) { if ((name == "address" || - name == "address6" || - name == "statusmap_image" || - name == "2d_coords") && + name == "address6") && object->GetType() == DynamicType::GetByName("Host")) return true; @@ -392,7 +342,7 @@ bool CompatUtility::IsLegacyAttribute(DynamicObject::Ptr const& object, const St name == "action_url" || name == "notes_url" || name == "icon_image" || - name == "icon_image_alt") && + name == "icon_image_alt") && (object->GetType() == DynamicType::GetByName("Host") || object->GetType() == DynamicType::GetByName("Service"))) return true; diff --git a/lib/icinga/compatutility.h b/lib/icinga/compatutility.h index d88109f4f..b4cc1178d 100644 --- a/lib/icinga/compatutility.h +++ b/lib/icinga/compatutility.h @@ -31,15 +31,6 @@ namespace icinga { -/** - * @ingroup icinga - */ -struct Host2dCoords { - int have_2d_coords; - String x_2d; - String y_2d; -}; - /** * Compatibility utility functions. * @@ -51,9 +42,6 @@ public: /* host */ static String GetHostAlias(const Host::Ptr& host); - static Host2dCoords GetHost2dCoords(const Host::Ptr& host); - static String GetHost2dCoordX(const Host::Ptr& host); - static String GetHost2dCoordY(const Host::Ptr& host); static int GetHostNotifyOnDown(const Host::Ptr& host); static int GetHostNotifyOnUnreachable(const Host::Ptr& host); -- 2.40.0