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

View File

@ -45,7 +45,7 @@ apply Service "load" {
apply ScheduledDowntime "backup-downtime" { apply ScheduledDowntime "backup-downtime" {
import "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" { apply Service "processes" {

View File

@ -3,7 +3,15 @@ namespace icinga
abstract class DynamicObject 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] String type (TypeName);
[config, get_protected] Array::Ptr templates; [config, get_protected] Array::Ptr templates;
[config] Dictionary::Ptr methods; [config] Dictionary::Ptr methods;

View File

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

View File

@ -117,12 +117,12 @@ Dictionary::Ptr ConfigItem::GetProperties(void)
if (!m_Properties) { if (!m_Properties) {
m_Properties = make_shared<Dictionary>(); m_Properties = make_shared<Dictionary>();
m_Properties->Set("type", m_Type); m_Properties->Set("type", m_Type);
m_Properties->Set("name", m_Name); m_Properties->Set("__name", m_Name);
m_Properties->Set("__parent", m_Scope); m_Properties->Set("__parent", m_Scope);
GetExpressionList()->Evaluate(m_Properties); GetExpressionList()->Evaluate(m_Properties);
m_Properties->Remove("__parent"); 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; return m_Properties;

View File

@ -69,12 +69,12 @@ void Dependency::EvaluateApplyRules(const std::vector<ApplyRule>& rules)
builder->SetScope(rule.GetScope()); builder->SetScope(rule.GetScope());
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, 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(), make_shared<AExpression>(&AExpression::OpLiteral, service->GetHost()->GetName(),
di), di)); di), di));
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, 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)); make_shared<AExpression>(&AExpression::OpLiteral, service->GetShortName(), di), di));
builder->AddExpression(rule.GetExpression()); builder->AddExpression(rule.GetExpression());

View File

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

View File

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

View File

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

View File

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

View File

@ -77,12 +77,12 @@ void Notification::Stop(void)
Checkable::Ptr Notification::GetCheckable(void) const 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; return host;
else else
return host->GetServiceByShortName(GetServiceRaw()); return host->GetServiceByShortName(GetServiceName());
} }
NotificationCommand::Ptr Notification::GetNotificationCommand(void) const NotificationCommand::Ptr Notification::GetNotificationCommand(void) const

View File

@ -20,8 +20,8 @@ class Notification : DynamicObject
[config] int notification_state_filter { [config] int notification_state_filter {
default {{{ return ~(int)0; }}} default {{{ return ~(int)0; }}}
}; };
[config, protected] String host (HostRaw); [config, protected] String host_name;
[config, protected] String service (ServiceRaw); [config, protected] String service_name;
[state] double last_notification; [state] double last_notification;
[state, set_protected] double next_notification (NextNotificationRaw); [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->SetScope(rule.GetScope());
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, 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), make_shared<AExpression>(&AExpression::OpLiteral, service->GetHost()->GetName(), di),
di)); di));
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, 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), make_shared<AExpression>(&AExpression::OpLiteral, service->GetShortName(), di),
di)); di));

View File

@ -61,12 +61,12 @@ void ScheduledDowntime::TimerProc(void)
Checkable::Ptr ScheduledDowntime::GetCheckable(void) const 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; return host;
else else
return host->GetServiceByShortName(GetServiceRaw()); return host->GetServiceByShortName(GetServiceName());
} }
std::pair<double, double> ScheduledDowntime::FindNextSegment(void) std::pair<double, double> ScheduledDowntime::FindNextSegment(void)

View File

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

View File

@ -67,12 +67,12 @@ void Service::EvaluateApplyRules(const std::vector<ApplyRule>& rules)
builder->SetScope(rule.GetScope()); builder->SetScope(rule.GetScope());
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, 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), make_shared<AExpression>(&AExpression::OpLiteral, host->GetName(), di),
di)); di));
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, 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), make_shared<AExpression>(&AExpression::OpLiteral, rule.GetName(), di),
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) if (m_Host)
m_Host->AddService(GetSelf()); m_Host->AddService(GetSelf());

View File

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