mirror of https://github.com/Icinga/icinga2.git
Add {Host,Service}Group attributes: notes, notes_url, action_url.
Fixes #6057
This commit is contained in:
parent
097e0bf4f4
commit
2b70b282ad
|
@ -564,9 +564,23 @@ void StatusDataWriter::UpdateObjectsCache(void)
|
|||
std::ostringstream tempobjectfp;
|
||||
tempobjectfp << std::fixed;
|
||||
|
||||
String display_name = hg->GetDisplayName();
|
||||
String notes = hg->GetNotes();
|
||||
String notes_url = hg->GetNotesUrl();
|
||||
String action_url = hg->GetActionUrl();
|
||||
|
||||
tempobjectfp << "define hostgroup {" "\n"
|
||||
"\t" "hostgroup_name" "\t" << hg->GetName() << "\n";
|
||||
|
||||
if (!display_name.IsEmpty())
|
||||
tempobjectfp << "\t" "alias" "\t" << display_name << "\n";
|
||||
if (!notes.IsEmpty())
|
||||
tempobjectfp << "\t" "notes" "\t" << notes << "\n";
|
||||
if (!notes_url.IsEmpty())
|
||||
tempobjectfp << "\t" "notes_url" "\t" << notes_url << "\n";
|
||||
if (!action_url.IsEmpty())
|
||||
tempobjectfp << "\t" "action_url" "\t" << action_url << "\n";
|
||||
|
||||
DumpCustomAttributes(tempobjectfp, hg);
|
||||
|
||||
tempobjectfp << "\t" "members" "\t";
|
||||
|
@ -581,9 +595,23 @@ void StatusDataWriter::UpdateObjectsCache(void)
|
|||
std::ostringstream tempobjectfp;
|
||||
tempobjectfp << std::fixed;
|
||||
|
||||
String display_name = sg->GetDisplayName();
|
||||
String notes = sg->GetNotes();
|
||||
String notes_url = sg->GetNotesUrl();
|
||||
String action_url = sg->GetActionUrl();
|
||||
|
||||
tempobjectfp << "define servicegroup {" "\n"
|
||||
"\t" "servicegroup_name" "\t" << sg->GetName() << "\n";
|
||||
|
||||
if (!display_name.IsEmpty())
|
||||
tempobjectfp << "\t" "alias" "\t" << display_name << "\n";
|
||||
if (!notes.IsEmpty())
|
||||
tempobjectfp << "\t" "notes" "\t" << notes << "\n";
|
||||
if (!notes_url.IsEmpty())
|
||||
tempobjectfp << "\t" "notes_url" "\t" << notes_url << "\n";
|
||||
if (!action_url.IsEmpty())
|
||||
tempobjectfp << "\t" "action_url" "\t" << action_url << "\n";
|
||||
|
||||
DumpCustomAttributes(tempobjectfp, sg);
|
||||
|
||||
tempobjectfp << "\t" "members" "\t";
|
||||
|
|
|
@ -600,6 +600,9 @@ CREATE TABLE IF NOT EXISTS icinga_hostgroups (
|
|||
config_type smallint default 0,
|
||||
hostgroup_object_id bigint unsigned default 0,
|
||||
alias TEXT character set latin1 default '',
|
||||
notes TEXT character set latin1 default NULL,
|
||||
notes_url TEXT character set latin1 default NULL,
|
||||
action_url TEXT character set latin1 default NULL,
|
||||
PRIMARY KEY (hostgroup_id),
|
||||
UNIQUE KEY instance_id (instance_id,hostgroup_object_id)
|
||||
) ENGINE=InnoDB COMMENT='Hostgroup definitions';
|
||||
|
@ -1086,6 +1089,9 @@ CREATE TABLE IF NOT EXISTS icinga_servicegroups (
|
|||
config_type smallint default 0,
|
||||
servicegroup_object_id bigint unsigned default 0,
|
||||
alias TEXT character set latin1 default '',
|
||||
notes TEXT character set latin1 default NULL,
|
||||
notes_url TEXT character set latin1 default NULL,
|
||||
action_url TEXT character set latin1 default NULL,
|
||||
PRIMARY KEY (servicegroup_id),
|
||||
UNIQUE KEY instance_id (instance_id,config_type,servicegroup_object_id)
|
||||
) ENGINE=InnoDB COMMENT='Servicegroup definitions';
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
|
||||
ALTER TABLE icinga_hostgroups ADD COLUMN notes TEXT character set latin1 default NULL;
|
||||
ALTER TABLE icinga_hostgroups ADD COLUMN notes_url TEXT character set latin1 default NULL;
|
||||
ALTER TABLE icinga_hostgroups ADD COLUMN action_url TEXT character set latin1 default NULL;
|
||||
ALTER TABLE icinga_servicegroups ADD COLUMN notes TEXT character set latin1 default NULL;
|
||||
ALTER TABLE icinga_servicegroups ADD COLUMN notes_url TEXT character set latin1 default NULL;
|
||||
ALTER TABLE icinga_servicegroups ADD COLUMN action_url TEXT character set latin1 default NULL;
|
|
@ -627,6 +627,9 @@ CREATE TABLE icinga_hostgroups (
|
|||
config_type INTEGER default 0,
|
||||
hostgroup_object_id bigint default 0,
|
||||
alias TEXT default '',
|
||||
notes TEXT default NULL,
|
||||
notes_url TEXT default NULL,
|
||||
action_url TEXT default NULL,
|
||||
CONSTRAINT PK_hostgroup_id PRIMARY KEY (hostgroup_id) ,
|
||||
CONSTRAINT UQ_hostgroups UNIQUE (instance_id,hostgroup_object_id)
|
||||
) ;
|
||||
|
@ -1113,6 +1116,9 @@ CREATE TABLE icinga_servicegroups (
|
|||
config_type INTEGER default 0,
|
||||
servicegroup_object_id bigint default 0,
|
||||
alias TEXT default '',
|
||||
notes TEXT default NULL,
|
||||
notes_url TEXT default NULL,
|
||||
action_url TEXT default NULL,
|
||||
CONSTRAINT PK_servicegroup_id PRIMARY KEY (servicegroup_id) ,
|
||||
CONSTRAINT UQ_servicegroups UNIQUE (instance_id,config_type,servicegroup_object_id)
|
||||
) ;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
|
||||
ALTER TABLE icinga_hostgroups ADD COLUMN notes TEXT default NULL;
|
||||
ALTER TABLE icinga_hostgroups ADD COLUMN notes_url TEXT default NULL;
|
||||
ALTER TABLE icinga_hostgroups ADD COLUMN action_url TEXT default NULL;
|
||||
ALTER TABLE icinga_servicegroups ADD COLUMN notes TEXT default NULL;
|
||||
ALTER TABLE icinga_servicegroups ADD COLUMN notes_url TEXT default NULL;
|
||||
ALTER TABLE icinga_servicegroups ADD COLUMN action_url TEXT default NULL;
|
|
@ -85,32 +85,17 @@ Value HostGroupsTable::AliasAccessor(const Value& row)
|
|||
|
||||
Value HostGroupsTable::NotesAccessor(const Value& row)
|
||||
{
|
||||
Dictionary::Ptr vars = static_cast<HostGroup::Ptr>(row)->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
||||
return vars->Get("notes");
|
||||
return static_cast<HostGroup::Ptr>(row)->GetNotes();
|
||||
}
|
||||
|
||||
Value HostGroupsTable::NotesUrlAccessor(const Value& row)
|
||||
{
|
||||
Dictionary::Ptr vars = static_cast<HostGroup::Ptr>(row)->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
||||
return vars->Get("notes_url");
|
||||
return static_cast<HostGroup::Ptr>(row)->GetNotesUrl();
|
||||
}
|
||||
|
||||
Value HostGroupsTable::ActionUrlAccessor(const Value& row)
|
||||
{
|
||||
Dictionary::Ptr vars = static_cast<HostGroup::Ptr>(row)->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
||||
return vars->Get("action_url");
|
||||
return static_cast<HostGroup::Ptr>(row)->GetActionUrl();
|
||||
}
|
||||
|
||||
Value HostGroupsTable::MembersAccessor(const Value& row)
|
||||
|
|
|
@ -76,32 +76,17 @@ Value ServiceGroupsTable::AliasAccessor(const Value& row)
|
|||
|
||||
Value ServiceGroupsTable::NotesAccessor(const Value& row)
|
||||
{
|
||||
Dictionary::Ptr vars = static_cast<ServiceGroup::Ptr>(row)->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
||||
return vars->Get("notes");
|
||||
return static_cast<ServiceGroup::Ptr>(row)->GetNotes();
|
||||
}
|
||||
|
||||
Value ServiceGroupsTable::NotesUrlAccessor(const Value& row)
|
||||
{
|
||||
Dictionary::Ptr vars = static_cast<ServiceGroup::Ptr>(row)->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
||||
return vars->Get("notes_url");
|
||||
return static_cast<ServiceGroup::Ptr>(row)->GetNotesUrl();
|
||||
}
|
||||
|
||||
Value ServiceGroupsTable::ActionUrlAccessor(const Value& row)
|
||||
{
|
||||
Dictionary::Ptr vars = static_cast<ServiceGroup::Ptr>(row)->GetVars();
|
||||
|
||||
if (!vars)
|
||||
return Empty;
|
||||
|
||||
return vars->Get("action_url");
|
||||
return static_cast<ServiceGroup::Ptr>(row)->GetActionUrl();
|
||||
}
|
||||
|
||||
Value ServiceGroupsTable::MembersAccessor(const Value& row)
|
||||
|
|
|
@ -39,6 +39,9 @@ Dictionary::Ptr HostGroupDbObject::GetConfigFields(void) const
|
|||
HostGroup::Ptr group = static_pointer_cast<HostGroup>(GetObject());
|
||||
|
||||
fields->Set("alias", group->GetDisplayName());
|
||||
fields->Set("notes", group->GetNotes());
|
||||
fields->Set("notes_url", group->GetNotesUrl());
|
||||
fields->Set("action_url", group->GetActionUrl());
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ Dictionary::Ptr ServiceGroupDbObject::GetConfigFields(void) const
|
|||
ServiceGroup::Ptr group = static_pointer_cast<ServiceGroup>(GetObject());
|
||||
|
||||
fields->Set("alias", group->GetDisplayName());
|
||||
fields->Set("notes", group->GetNotes());
|
||||
fields->Set("notes_url", group->GetNotesUrl());
|
||||
fields->Set("action_url", group->GetActionUrl());
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ class HostGroup : DynamicObject
|
|||
};
|
||||
|
||||
[config] Array::Ptr groups;
|
||||
[config] String notes;
|
||||
[config] String notes_url;
|
||||
[config] String action_url;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -76,6 +76,10 @@
|
|||
%attribute %array "groups" {
|
||||
%attribute %name(HostGroup) "*"
|
||||
},
|
||||
|
||||
%attribute %string "notes",
|
||||
%attribute %string "notes_url",
|
||||
%attribute %string "action_url",
|
||||
}
|
||||
|
||||
%type Service %inherits Checkable {
|
||||
|
@ -95,6 +99,10 @@
|
|||
%attribute %array "groups" {
|
||||
%attribute %name(ServiceGroup) "*"
|
||||
},
|
||||
|
||||
%attribute %string "notes",
|
||||
%attribute %string "notes_url",
|
||||
%attribute %string "action_url",
|
||||
}
|
||||
|
||||
%type Notification {
|
||||
|
|
|
@ -15,6 +15,9 @@ class ServiceGroup : DynamicObject
|
|||
};
|
||||
|
||||
[config] Array::Ptr groups;
|
||||
[config] String notes;
|
||||
[config] String notes_url;
|
||||
[config] String action_url;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue