mirror of https://github.com/Icinga/icinga2.git
parent
bb12704a31
commit
97fc5bb10b
|
@ -53,7 +53,7 @@ DynamicObject::DynamicObject(void)
|
||||||
|
|
||||||
DynamicType::Ptr DynamicObject::GetType(void) const
|
DynamicType::Ptr DynamicObject::GetType(void) const
|
||||||
{
|
{
|
||||||
return DynamicType::GetByName(GetTypeName());
|
return DynamicType::GetByName(GetTypeNameV());
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugInfo DynamicObject::GetDebugInfo(void) const
|
DebugInfo DynamicObject::GetDebugInfo(void) const
|
||||||
|
|
|
@ -44,8 +44,8 @@ abstract class DynamicObject
|
||||||
return m_ShortName;
|
return m_ShortName;
|
||||||
}}}
|
}}}
|
||||||
};
|
};
|
||||||
[config, internal, get_protected] String type (TypeName);
|
[config, internal, get_protected] String type (TypeNameV);
|
||||||
[config] String zone;
|
[config] String zone (ZoneName);
|
||||||
[config, internal, get_protected] Array::Ptr templates;
|
[config, internal, get_protected] Array::Ptr templates;
|
||||||
[get_protected] bool active;
|
[get_protected] bool active;
|
||||||
[get_protected] bool paused {
|
[get_protected] bool paused {
|
||||||
|
|
|
@ -258,7 +258,7 @@ void CheckerComponent::ObjectHandler(const DynamicObject::Ptr& object)
|
||||||
|
|
||||||
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
||||||
|
|
||||||
Zone::Ptr zone = Zone::GetByName(checkable->GetZone());
|
Zone::Ptr zone = Zone::GetByName(checkable->GetZoneName());
|
||||||
bool same_zone = (!zone || Zone::GetLocalZone() == zone);
|
bool same_zone = (!zone || Zone::GetLocalZone() == zone);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -160,8 +160,8 @@ DynamicObject::Ptr ConfigItem::Commit(bool discard)
|
||||||
DynamicObject::Ptr dobj = static_pointer_cast<DynamicObject>(type->Instantiate());
|
DynamicObject::Ptr dobj = static_pointer_cast<DynamicObject>(type->Instantiate());
|
||||||
|
|
||||||
dobj->SetDebugInfo(m_DebugInfo);
|
dobj->SetDebugInfo(m_DebugInfo);
|
||||||
dobj->SetTypeName(m_Type);
|
dobj->SetTypeNameV(m_Type);
|
||||||
dobj->SetZone(m_Zone);
|
dobj->SetZoneName(m_Zone);
|
||||||
dobj->SetName(m_Name);
|
dobj->SetName(m_Name);
|
||||||
|
|
||||||
DebugHint debugHints;
|
DebugHint debugHints;
|
||||||
|
|
|
@ -66,7 +66,7 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons
|
||||||
if (service)
|
if (service)
|
||||||
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "child_service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
|
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "child_service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
|
||||||
|
|
||||||
String zone = checkable->GetZone();
|
String zone = checkable->GetZoneName();
|
||||||
|
|
||||||
if (!zone.IsEmpty())
|
if (!zone.IsEmpty())
|
||||||
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
|
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
|
||||||
|
|
|
@ -51,9 +51,9 @@ public:
|
||||||
|
|
||||||
static HostState CalculateState(ServiceState state);
|
static HostState CalculateState(ServiceState state);
|
||||||
|
|
||||||
HostState GetState(void) const;
|
virtual HostState GetState(void) const;
|
||||||
HostState GetLastState(void) const;
|
virtual HostState GetLastState(void) const;
|
||||||
HostState GetLastHardState(void) const;
|
virtual HostState GetLastHardState(void) const;
|
||||||
double GetLastStateUp(void) const;
|
double GetLastStateUp(void) const;
|
||||||
double GetLastStateDown(void) const;
|
double GetLastStateDown(void) const;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,17 @@ class Host : Checkable
|
||||||
|
|
||||||
[config] String address;
|
[config] String address;
|
||||||
[config] String address6;
|
[config] String address6;
|
||||||
|
|
||||||
|
[enum, no_storage] HostState "state" {
|
||||||
|
get;
|
||||||
|
};
|
||||||
|
[enum, no_storage] HostState last_state {
|
||||||
|
get;
|
||||||
|
};
|
||||||
|
[enum, no_storage] HostState last_hard_state {
|
||||||
|
get;
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co
|
||||||
if (service)
|
if (service)
|
||||||
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
|
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
|
||||||
|
|
||||||
String zone = checkable->GetZone();
|
String zone = checkable->GetZoneName();
|
||||||
|
|
||||||
if (!zone.IsEmpty())
|
if (!zone.IsEmpty())
|
||||||
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
|
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
|
||||||
|
|
|
@ -64,7 +64,7 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl
|
||||||
if (service)
|
if (service)
|
||||||
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
|
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "service_name"), OpSetLiteral, MakeLiteral(service->GetShortName()), di));
|
||||||
|
|
||||||
String zone = checkable->GetZone();
|
String zone = checkable->GetZoneName();
|
||||||
|
|
||||||
if (!zone.IsEmpty())
|
if (!zone.IsEmpty())
|
||||||
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
|
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
|
||||||
|
|
|
@ -58,7 +58,7 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam
|
||||||
|
|
||||||
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "name"), OpSetLiteral, MakeLiteral(name), di));
|
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "name"), OpSetLiteral, MakeLiteral(name), di));
|
||||||
|
|
||||||
String zone = host->GetZone();
|
String zone = host->GetZoneName();
|
||||||
|
|
||||||
if (!zone.IsEmpty())
|
if (!zone.IsEmpty())
|
||||||
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
|
builder->AddExpression(new SetExpression(MakeIndexer(ScopeCurrent, "zone"), OpSetLiteral, MakeLiteral(zone), di));
|
||||||
|
|
|
@ -44,17 +44,17 @@ class Service : Checkable < ServiceNameComposer
|
||||||
}}}
|
}}}
|
||||||
};
|
};
|
||||||
[config] String host_name;
|
[config] String host_name;
|
||||||
[enum] ServiceState "state" {
|
[enum, no_storage] ServiceState "state" {
|
||||||
get {{{
|
get {{{
|
||||||
return GetStateRaw();
|
return GetStateRaw();
|
||||||
}}}
|
}}}
|
||||||
};
|
};
|
||||||
[enum] ServiceState last_state {
|
[enum, no_storage] ServiceState last_state {
|
||||||
get {{{
|
get {{{
|
||||||
return GetLastStateRaw();
|
return GetLastStateRaw();
|
||||||
}}}
|
}}}
|
||||||
};
|
};
|
||||||
[enum] ServiceState last_hard_state {
|
[enum, no_storage] ServiceState last_hard_state {
|
||||||
get {{{
|
get {{{
|
||||||
return GetLastHardStateRaw();
|
return GetLastHardStateRaw();
|
||||||
}}}
|
}}}
|
||||||
|
|
|
@ -556,7 +556,7 @@ void ApiListener::SyncRelayMessage(const MessageOrigin& origin, const DynamicObj
|
||||||
|
|
||||||
/* only relay the message to a) the same zone, b) the parent zone and c) direct child zones */
|
/* only relay the message to a) the same zone, b) the parent zone and c) direct child zones */
|
||||||
if (target_zone != my_zone && target_zone != my_zone->GetParent() &&
|
if (target_zone != my_zone && target_zone != my_zone->GetParent() &&
|
||||||
secobj->GetZone() != target_zone->GetName()) {
|
secobj->GetZoneName() != target_zone->GetName()) {
|
||||||
skippedEndpoints.push_back(endpoint);
|
skippedEndpoints.push_back(endpoint);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ bool Zone::CanAccessObject(const DynamicObject::Ptr& object)
|
||||||
if (dynamic_pointer_cast<Zone>(object))
|
if (dynamic_pointer_cast<Zone>(object))
|
||||||
object_zone = static_pointer_cast<Zone>(object);
|
object_zone = static_pointer_cast<Zone>(object);
|
||||||
else
|
else
|
||||||
object_zone = Zone::GetByName(object->GetZone());
|
object_zone = Zone::GetByName(object->GetZoneName());
|
||||||
|
|
||||||
if (!object_zone)
|
if (!object_zone)
|
||||||
object_zone = Zone::GetLocalZone();
|
object_zone = Zone::GetLocalZone();
|
||||||
|
|
|
@ -141,6 +141,7 @@ get_protected { yylval->num = FAGetProtected; return T_FIELD_ATTRIBUTE; }
|
||||||
set_protected { yylval->num = FASetProtected; return T_FIELD_ATTRIBUTE; }
|
set_protected { yylval->num = FASetProtected; return T_FIELD_ATTRIBUTE; }
|
||||||
protected { yylval->num = FAGetProtected | FASetProtected; return T_FIELD_ATTRIBUTE; }
|
protected { yylval->num = FAGetProtected | FASetProtected; return T_FIELD_ATTRIBUTE; }
|
||||||
internal { yylval->num = FAInternal; return T_FIELD_ATTRIBUTE; }
|
internal { yylval->num = FAInternal; return T_FIELD_ATTRIBUTE; }
|
||||||
|
no_storage { yylval->num = FANoStorage; return T_FIELD_ATTRIBUTE; }
|
||||||
default { yylval->num = FTDefault; return T_FIELD_ACCESSOR_TYPE; }
|
default { yylval->num = FTDefault; return T_FIELD_ACCESSOR_TYPE; }
|
||||||
get { yylval->num = FTGet; return T_FIELD_ACCESSOR_TYPE; }
|
get { yylval->num = FTGet; return T_FIELD_ACCESSOR_TYPE; }
|
||||||
set { yylval->num = FTSet; return T_FIELD_ACCESSOR_TYPE; }
|
set { yylval->num = FTSet; return T_FIELD_ACCESSOR_TYPE; }
|
||||||
|
|
|
@ -265,9 +265,11 @@ class_field: field_attribute_list identifier identifier alternative_name_specifi
|
||||||
switch (it->Type) {
|
switch (it->Type) {
|
||||||
case FTGet:
|
case FTGet:
|
||||||
field->GetAccessor = it->Accessor;
|
field->GetAccessor = it->Accessor;
|
||||||
|
field->PureGetAccessor = it->Pure;
|
||||||
break;
|
break;
|
||||||
case FTSet:
|
case FTSet:
|
||||||
field->SetAccessor = it->Accessor;
|
field->SetAccessor = it->Accessor;
|
||||||
|
field->PureSetAccessor = it->Pure;
|
||||||
break;
|
break;
|
||||||
case FTDefault:
|
case FTDefault:
|
||||||
field->DefaultAccessor = it->Accessor;
|
field->DefaultAccessor = it->Accessor;
|
||||||
|
@ -339,9 +341,13 @@ field_accessors: /* empty */
|
||||||
|
|
||||||
field_accessor: T_FIELD_ACCESSOR_TYPE T_STRING
|
field_accessor: T_FIELD_ACCESSOR_TYPE T_STRING
|
||||||
{
|
{
|
||||||
$$ = new FieldAccessor(static_cast<FieldAccessorType>($1), $2);
|
$$ = new FieldAccessor(static_cast<FieldAccessorType>($1), $2, false);
|
||||||
std::free($2);
|
std::free($2);
|
||||||
}
|
}
|
||||||
|
| T_FIELD_ACCESSOR_TYPE ';'
|
||||||
|
{
|
||||||
|
$$ = new FieldAccessor(static_cast<FieldAccessorType>($1), "", true);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
identifier: T_IDENTIFIER
|
identifier: T_IDENTIFIER
|
||||||
|
|
|
@ -454,16 +454,22 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
||||||
prot = "public";
|
prot = "public";
|
||||||
|
|
||||||
std::cout << prot << ":" << std::endl
|
std::cout << prot << ":" << std::endl
|
||||||
<< "\t" << it->Type << " Get" << it->GetFriendlyName() << "(void) const" << std::endl
|
<< "\t" << "virtual " << it->Type << " Get" << it->GetFriendlyName() << "(void) const";
|
||||||
|
|
||||||
|
if (it->PureGetAccessor) {
|
||||||
|
std::cout << " = 0;" << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout << std::endl
|
||||||
<< "\t" << "{" << std::endl;
|
<< "\t" << "{" << std::endl;
|
||||||
|
|
||||||
if (it->GetAccessor.empty())
|
if (it->GetAccessor.empty() && !(it->Attributes & FANoStorage))
|
||||||
std::cout << "\t\t" << "return m_" << it->GetFriendlyName() << ";" << std::endl;
|
std::cout << "\t\t" << "return m_" << it->GetFriendlyName() << ";" << std::endl;
|
||||||
else
|
else
|
||||||
std::cout << it->GetAccessor << std::endl;
|
std::cout << it->GetAccessor << std::endl;
|
||||||
|
|
||||||
std::cout << "\t" << "}" << std::endl << std::endl;
|
std::cout << "\t" << "}" << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* setters */
|
/* setters */
|
||||||
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
||||||
|
@ -484,16 +490,21 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
||||||
else
|
else
|
||||||
std::cout << "const " << it->Type << "&";
|
std::cout << "const " << it->Type << "&";
|
||||||
|
|
||||||
std::cout << " value)" << std::endl
|
std::cout << " value)" << std::endl;
|
||||||
<< "\t" << "{" << std::endl;
|
|
||||||
|
|
||||||
if (it->SetAccessor.empty())
|
if (it->PureSetAccessor) {
|
||||||
|
std::cout << " = 0;" << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout << "\t" << "{" << std::endl;
|
||||||
|
|
||||||
|
if (it->SetAccessor.empty() && !(it->Attributes & FANoStorage))
|
||||||
std::cout << "\t\t" << "m_" << it->GetFriendlyName() << " = value;" << std::endl;
|
std::cout << "\t\t" << "m_" << it->GetFriendlyName() << " = value;" << std::endl;
|
||||||
else
|
else
|
||||||
std::cout << it->SetAccessor << std::endl;
|
std::cout << it->SetAccessor << std::endl;
|
||||||
|
|
||||||
std::cout << "\t" << "}" << std::endl << std::endl;
|
std::cout << "\t" << "}" << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* default */
|
/* default */
|
||||||
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
||||||
|
|
|
@ -48,9 +48,10 @@ struct FieldAccessor
|
||||||
{
|
{
|
||||||
FieldAccessorType Type;
|
FieldAccessorType Type;
|
||||||
std::string Accessor;
|
std::string Accessor;
|
||||||
|
bool Pure;
|
||||||
|
|
||||||
FieldAccessor(FieldAccessorType type, const std::string& accessor)
|
FieldAccessor(FieldAccessorType type, const std::string& accessor, bool pure)
|
||||||
: Type(type), Accessor(accessor)
|
: Type(type), Accessor(accessor), Pure(pure)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,7 +62,8 @@ enum FieldAttribute
|
||||||
FAEnum = 4,
|
FAEnum = 4,
|
||||||
FAGetProtected = 8,
|
FAGetProtected = 8,
|
||||||
FASetProtected = 16,
|
FASetProtected = 16,
|
||||||
FAInternal = 32
|
FAInternal = 32,
|
||||||
|
FANoStorage = 64
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Field
|
struct Field
|
||||||
|
@ -71,7 +73,9 @@ struct Field
|
||||||
std::string Name;
|
std::string Name;
|
||||||
std::string AlternativeName;
|
std::string AlternativeName;
|
||||||
std::string GetAccessor;
|
std::string GetAccessor;
|
||||||
|
bool PureGetAccessor;
|
||||||
std::string SetAccessor;
|
std::string SetAccessor;
|
||||||
|
bool PureSetAccessor;
|
||||||
std::string DefaultAccessor;
|
std::string DefaultAccessor;
|
||||||
|
|
||||||
std::string GetFriendlyName(void) const
|
std::string GetFriendlyName(void) const
|
||||||
|
|
Loading…
Reference in New Issue