Rename "short_name", "host" and "sevice" attributes.

Fixes #5857
This commit is contained in:
Gunnar Beutner 2014-04-05 09:15:40 +02:00
parent 31e3377897
commit c42a582307
18 changed files with 77 additions and 78 deletions

View File

@ -53,8 +53,8 @@ by Icinga 2.
Example:
object Service "localhost-uptime" {
host = "localhost"
short_name = "uptime"
host_name = "localhost"
name = "uptime"
display_name = "localhost Uptime"
@ -75,8 +75,8 @@ Attributes:
Name |Description
----------------|----------------
host |**Required.** The host this service belongs to. There must be a `Host` object with that name.
short_name |**Required.** The service name. Must be unique on a per-host basis (Similar to the service_description attribute in Icinga 1.x).
host_name |**Required.** The host this service belongs to. There must be a `Host` object with that name.
name |**Required.** The service name. Must be unique on a per-host basis (Similar to the service_description attribute in Icinga 1.x).
display_name |**Optional.** A short description of the service.
vars |**Optional.** A dictionary containing custom attributes that are specific to this host.
check\_command |**Required.** The name of the check command.
@ -127,8 +127,8 @@ of service state changes and other events.
Example:
object Notification "localhost-ping-notification" {
host = "localhost"
service = "ping4"
host_name = "localhost"
service_name = "ping4"
notification_command = "mail-notification"
@ -139,8 +139,8 @@ Attributes:
Name |Description
----------------|----------------
host |**Required.** The name of the host this notification belongs to.
service |**Required.** The short name of the service this notification belongs to.
host_name |**Required.** The name of the host this notification belongs to.
service_name |**Required.** The short name of the service this notification belongs to.
vars |**Optional.** A dictionary containing custom attributes that are specific to this notification object.
users |**Optional.** A list of user names who should be notified.
user_groups |**Optional.** A list of user group names who should be notified.
@ -185,11 +185,11 @@ Dependency objects are used to specify dependencies between hosts and services.
Example:
object Dependency "webserver-internet" {
child_host = "webserver"
child_service = "ping4"
child_host_name = "webserver"
child_service_name = "ping4"
parent_host = "internet"
parent_service = "ping4"
parent_host_name = "internet"
parent_service_name = "ping4"
state_filter = StateFilterOK
@ -344,8 +344,8 @@ ScheduledDowntime objects can be used to set up recurring downtimes for services
Example:
object ScheduledDowntime "some-downtime" {
host = "localhost"
service = "ping4"
host_name = "localhost"
service_name = "ping4"
author = "icingaadmin"
comment = "Some comment"
@ -362,8 +362,8 @@ Attributes:
Name |Description
----------------|----------------
host |**Required.** The name of the host this notification belongs to.
service |**Required.** The short name of the service this notification belongs to.
host_name |**Required.** The name of the host this notification belongs to.
service_name |**Required.** The short name of the service this notification belongs to.
author |**Required.** The author of the downtime.
comment |**Required.** A comment for the downtime.
fixed |**Optional.** Whether this is a fixed downtime. Defaults to true.

View File

@ -45,7 +45,7 @@ apply Service "load" {
apply ScheduledDowntime "backup-downtime" {
import "backup-downtime"
assign where service.host == "localhost" && service.short_name == "load"
assign where host.name == "localhost" && service.name == "load"
}
apply Service "processes" {

View File

@ -3,7 +3,15 @@ namespace icinga
abstract class DynamicObject
{
[config] String name (Name);
[config] String __name (Name);
[config] String name (ShortName) {
get {{{
if (m_ShortName.IsEmpty())
return GetName();
else
return m_ShortName;
}}}
};
[config, get_protected] String type (TypeName);
[config, get_protected] Array::Ptr templates;
[config] Dictionary::Ptr methods;

View File

@ -18,8 +18,8 @@
******************************************************************************/
%type DynamicObject {
%require "name",
%attribute %string "name",
%require "__name",
%attribute %string "__name",
%require "type",
%attribute %string "type",

View File

@ -117,12 +117,12 @@ Dictionary::Ptr ConfigItem::GetProperties(void)
if (!m_Properties) {
m_Properties = make_shared<Dictionary>();
m_Properties->Set("type", m_Type);
m_Properties->Set("name", m_Name);
m_Properties->Set("__name", m_Name);
m_Properties->Set("__parent", m_Scope);
GetExpressionList()->Evaluate(m_Properties);
m_Properties->Remove("__parent");
VERIFY(m_Properties->Get("type") == GetType() && m_Properties->Get("name") == GetName());
VERIFY(m_Properties->Get("type") == GetType() && m_Properties->Get("__name") == GetName());
}
return m_Properties;

View File

@ -69,12 +69,12 @@ void Dependency::EvaluateApplyRules(const std::vector<ApplyRule>& rules)
builder->SetScope(rule.GetScope());
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet,
make_shared<AExpression>(&AExpression::OpLiteral, "child_host", di),
make_shared<AExpression>(&AExpression::OpLiteral, "child_host_name", di),
make_shared<AExpression>(&AExpression::OpLiteral, service->GetHost()->GetName(),
di), di));
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet,
make_shared<AExpression>(&AExpression::OpLiteral, "child_service", di),
make_shared<AExpression>(&AExpression::OpLiteral, "child_service_name", di),
make_shared<AExpression>(&AExpression::OpLiteral, service->GetShortName(), di), di));
builder->AddExpression(rule.GetExpression());

View File

@ -116,28 +116,28 @@ bool Dependency::IsAvailable(DependencyType dt) const
Checkable::Ptr Dependency::GetChild(void) const
{
Host::Ptr host = Host::GetByName(GetChildHostRaw());
Host::Ptr host = Host::GetByName(GetChildHostName());
if (!host)
return Service::Ptr();
if (GetChildServiceRaw().IsEmpty())
if (GetChildServiceName().IsEmpty())
return host;
else
return host->GetServiceByShortName(GetChildServiceRaw());
return host->GetServiceByShortName(GetChildServiceName());
}
Checkable::Ptr Dependency::GetParent(void) const
{
Host::Ptr host = Host::GetByName(GetParentHostRaw());
Host::Ptr host = Host::GetByName(GetParentHostName());
if (!host)
return Service::Ptr();
if (GetParentServiceRaw().IsEmpty())
if (GetParentServiceName().IsEmpty())
return host;
else
return host->GetServiceByShortName(GetParentServiceRaw());
return host->GetServiceByShortName(GetParentServiceName());
}
TimePeriod::Ptr Dependency::GetPeriod(void) const

View File

@ -6,11 +6,11 @@ namespace icinga
class Dependency : DynamicObject
{
[config] String child_host (ChildHostRaw);
[config] String child_service (ChildServiceRaw);
[config] String child_host_name;
[config] String child_service_name;
[config] String parent_host (ParentHostRaw);
[config] String parent_service (ParentServiceRaw);
[config] String parent_host_name;
[config] String parent_service_name;
[config] String period (PeriodRaw);

View File

@ -66,11 +66,10 @@
}
%type Service %inherits Checkable {
%require "host",
%attribute %name(Host) "host",
%attribute %string "short_name",
%require "host_name",
%attribute %name(Host) "host_name",
%attribute %string "name",
%attribute %array "groups" {
%attribute %name(ServiceGroup) "*"
@ -82,11 +81,11 @@
}
%type Notification {
%require "host",
%attribute %name(Host) "host",
%require "host_name",
%attribute %name(Host) "host_name",
%require "service",
%attribute %string "service",
%require "service_name",
%attribute %string "service_name",
%attribute %array "users" {
%attribute %name(User) "*"
@ -190,10 +189,10 @@
}
%type ScheduledDowntime {
%require "host",
%attribute %name(Host) "host",
%require "service",
%attribute %string "service",
%require "host_name",
%attribute %name(Host) "host_name",
%require "service_name",
%attribute %string "service_name",
%require "author",
%attribute %string "author",
@ -211,13 +210,13 @@
}
%type Dependency {
%require "parent_host",
%attribute %name(Host) "parent_host",
%attribute %string "parent_service",
%require "parent_host_name",
%attribute %name(Host) "parent_host_name",
%attribute %string "parent_service_name",
%require "child_host",
%attribute %name(Host) "child_host",
%attribute %string "child_service",
%require "child_host_name",
%attribute %name(Host) "child_host_name",
%attribute %string "child_service_name",
%attribute %name(TimePeriod) "period",

View File

@ -68,12 +68,12 @@ void Notification::EvaluateApplyRules(const std::vector<ApplyRule>& rules)
builder->SetScope(rule.GetScope());
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet,
make_shared<AExpression>(&AExpression::OpLiteral, "host", di),
make_shared<AExpression>(&AExpression::OpLiteral, "host_name", di),
make_shared<AExpression>(&AExpression::OpLiteral, service->GetHost()->GetName(), di),
di));
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet,
make_shared<AExpression>(&AExpression::OpLiteral, "service", di),
make_shared<AExpression>(&AExpression::OpLiteral, "service_name", di),
make_shared<AExpression>(&AExpression::OpLiteral, service->GetShortName(), di),
di));

View File

@ -77,12 +77,12 @@ void Notification::Stop(void)
Checkable::Ptr Notification::GetCheckable(void) const
{
Host::Ptr host = Host::GetByName(GetHostRaw());
Host::Ptr host = Host::GetByName(GetHostName());
if (GetServiceRaw().IsEmpty())
if (GetServiceName().IsEmpty())
return host;
else
return host->GetServiceByShortName(GetServiceRaw());
return host->GetServiceByShortName(GetServiceName());
}
NotificationCommand::Ptr Notification::GetNotificationCommand(void) const

View File

@ -20,8 +20,8 @@ class Notification : DynamicObject
[config] int notification_state_filter {
default {{{ return ~(int)0; }}}
};
[config, protected] String host (HostRaw);
[config, protected] String service (ServiceRaw);
[config, protected] String host_name;
[config, protected] String service_name;
[state] double last_notification;
[state, set_protected] double next_notification (NextNotificationRaw);

View File

@ -68,12 +68,12 @@ void ScheduledDowntime::EvaluateApplyRules(const std::vector<ApplyRule>& rules)
builder->SetScope(rule.GetScope());
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet,
make_shared<AExpression>(&AExpression::OpLiteral, "host", di),
make_shared<AExpression>(&AExpression::OpLiteral, "host_name", di),
make_shared<AExpression>(&AExpression::OpLiteral, service->GetHost()->GetName(), di),
di));
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet,
make_shared<AExpression>(&AExpression::OpLiteral, "service", di),
make_shared<AExpression>(&AExpression::OpLiteral, "service_name", di),
make_shared<AExpression>(&AExpression::OpLiteral, service->GetShortName(), di),
di));

View File

@ -61,12 +61,12 @@ void ScheduledDowntime::TimerProc(void)
Checkable::Ptr ScheduledDowntime::GetCheckable(void) const
{
Host::Ptr host = Host::GetByName(GetHostRaw());
Host::Ptr host = Host::GetByName(GetHostName());
if (GetServiceRaw().IsEmpty())
if (GetServiceName().IsEmpty())
return host;
else
return host->GetServiceByShortName(GetServiceRaw());
return host->GetServiceByShortName(GetServiceName());
}
std::pair<double, double> ScheduledDowntime::FindNextSegment(void)

View File

@ -5,8 +5,8 @@ namespace icinga
class ScheduledDowntime : DynamicObject
{
[config, protected] String host (HostRaw);
[config, protected] String service (ServiceRaw);
[config, protected] String host_name;
[config, protected] String service_name;
[config] String author;
[config] String comment;

View File

@ -67,12 +67,12 @@ void Service::EvaluateApplyRules(const std::vector<ApplyRule>& rules)
builder->SetScope(rule.GetScope());
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet,
make_shared<AExpression>(&AExpression::OpLiteral, "host", di),
make_shared<AExpression>(&AExpression::OpLiteral, "host_name", di),
make_shared<AExpression>(&AExpression::OpLiteral, host->GetName(), di),
di));
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet,
make_shared<AExpression>(&AExpression::OpLiteral, "short_name", di),
make_shared<AExpression>(&AExpression::OpLiteral, "name", di),
make_shared<AExpression>(&AExpression::OpLiteral, rule.GetName(), di),
di));

View File

@ -54,7 +54,7 @@ void Service::OnConfigLoaded(void)
}
}
m_Host = Host::GetByName(GetHostRaw());
m_Host = Host::GetByName(GetHostName());
if (m_Host)
m_Host->AddService(GetSelf());

View File

@ -16,15 +16,7 @@ class Service : Checkable
return m_DisplayName;
}}}
};
[config] String short_name {
get {{{
if (m_ShortName.IsEmpty())
return GetName();
else
return m_ShortName;
}}}
};
[config] String host (HostRaw);
[config] String host_name;
[enum] ServiceState "state" {
get {{{
return GetStateRaw();