icinga2/cib/host.cpp

36 lines
659 B
C++
Raw Normal View History

#include "i2-cib.h"
using namespace icinga;
2012-06-30 13:39:55 +02:00
string Host::GetAlias(void) const
{
string value;
2012-06-30 13:39:55 +02:00
if (GetConfigObject()->GetProperty("alias", &value))
return value;
return GetName();
}
2012-06-30 13:39:55 +02:00
bool Host::Exists(const string& name)
{
return (ConfigObject::GetObject("host", name));
}
Host Host::GetByName(const string& name)
{
ConfigObject::Ptr configObject = ConfigObject::GetObject("host", name);
if (!configObject)
throw invalid_argument("Host '" + name + "' does not exist.");
return Host(configObject);
}
2012-06-30 13:39:55 +02:00
Dictionary::Ptr Host::GetGroups(void) const
{
Dictionary::Ptr value;
GetConfigObject()->GetProperty("hostgroups", &value);
return value;
}