mirror of https://github.com/Icinga/icinga2.git
parent
9344399f44
commit
a05c31cda2
|
@ -347,11 +347,6 @@ Value HostsTable::NotesUrlAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr custom = host->GetCustom();
|
||||
|
||||
if (!custom)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCustomAttributeConfig(host, "notes_url");
|
||||
}
|
||||
|
||||
|
@ -1066,20 +1061,7 @@ Value HostsTable::X2dAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr custom = host->GetCustom();
|
||||
|
||||
if (!custom)
|
||||
return Empty;
|
||||
|
||||
String coords = custom->Get("2d_coords");
|
||||
|
||||
std::vector<String> tokens;
|
||||
boost::algorithm::split(tokens, coords, boost::is_any_of(","));
|
||||
|
||||
if (tokens.size() != 2)
|
||||
return Empty;
|
||||
|
||||
return tokens[0];
|
||||
return CompatUtility::GetHost2dCoordX(host);
|
||||
}
|
||||
|
||||
Value HostsTable::Y2dAccessor(const Value& row)
|
||||
|
@ -1089,20 +1071,7 @@ Value HostsTable::Y2dAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr custom = host->GetCustom();
|
||||
|
||||
if (!custom)
|
||||
return Empty;
|
||||
|
||||
String coords = custom->Get("2d_coords");
|
||||
|
||||
std::vector<String> tokens;
|
||||
boost::algorithm::split(tokens, coords, boost::is_any_of(","));
|
||||
|
||||
if (tokens.size() != 2)
|
||||
return Empty;
|
||||
|
||||
return tokens[1];
|
||||
return CompatUtility::GetHost2dCoordY(host);
|
||||
}
|
||||
|
||||
Value HostsTable::LatencyAccessor(const Value& row)
|
||||
|
|
|
@ -111,11 +111,18 @@ Host2dCoords CompatUtility::GetHost2dCoords(const Host::Ptr& host)
|
|||
Host2dCoords bag;
|
||||
|
||||
if (custom) {
|
||||
bag.have_2d_coords = (custom->Get("x_2d") && custom->Get("y_2d") ? 1 : 0);
|
||||
String coords = custom->Get("2d_coords");
|
||||
bag.have_2d_coords = (!coords.IsEmpty() ? 1 : 0);
|
||||
|
||||
std::vector<String> 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 = custom->Get("x_2d");
|
||||
bag.y_2d = custom->Get("y_2d");
|
||||
bag.x_2d = tokens[0];
|
||||
bag.y_2d = tokens[1];
|
||||
}
|
||||
} else {
|
||||
bag.have_2d_coords = 0;
|
||||
|
@ -124,6 +131,26 @@ Host2dCoords CompatUtility::GetHost2dCoords(const Host::Ptr& host)
|
|||
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());
|
||||
|
|
|
@ -59,6 +59,8 @@ public:
|
|||
static String GetHostAddress(const Host::Ptr& host);
|
||||
static String GetHostAddress6(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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue