"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/icinga/apiactions.cpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

apiactions.cpp  (icinga2-2.11.5):apiactions.cpp  (icinga2-2.12.0)
skipping to change at line 217 skipping to change at line 217
if (params->Contains("persistent")) if (params->Contains("persistent"))
persistent = HttpUtility::GetLastParameter(params, "persistent"); persistent = HttpUtility::GetLastParameter(params, "persistent");
if (params->Contains("expiry")) { if (params->Contains("expiry")) {
timestamp = HttpUtility::GetLastParameter(params, "expiry"); timestamp = HttpUtility::GetLastParameter(params, "expiry");
if (timestamp <= Utility::GetTime()) if (timestamp <= Utility::GetTime())
return ApiActions::CreateResult(409, "Acknowledgement 'ex piry' timestamp must be in the future for object " + checkable->GetName()); return ApiActions::CreateResult(409, "Acknowledgement 'ex piry' timestamp must be in the future for object " + checkable->GetName());
} else } else
timestamp = 0; timestamp = 0;
ObjectLock oLock (checkable);
Host::Ptr host; Host::Ptr host;
Service::Ptr service; Service::Ptr service;
tie(host, service) = GetHostService(checkable); tie(host, service) = GetHostService(checkable);
if (!service) { if (!service) {
if (host->GetState() == HostUp) if (host->GetState() == HostUp)
return ApiActions::CreateResult(409, "Host " + checkable- >GetName() + " is UP."); return ApiActions::CreateResult(409, "Host " + checkable- >GetName() + " is UP.");
} else { } else {
if (service->GetState() == ServiceOK) if (service->GetState() == ServiceOK)
return ApiActions::CreateResult(409, "Service " + checkab le->GetName() + " is OK."); return ApiActions::CreateResult(409, "Service " + checkab le->GetName() + " is OK.");
} }
if (checkable->IsAcknowledged()) {
return ApiActions::CreateResult(409, (service ? "Service " : "Hos
t ") + checkable->GetName() + " is already acknowledged.");
}
Comment::AddComment(checkable, CommentAcknowledgement, HttpUtility::GetLa stParameter(params, "author"), Comment::AddComment(checkable, CommentAcknowledgement, HttpUtility::GetLa stParameter(params, "author"),
HttpUtility::GetLastParameter(params, "comment"), persistent, tim estamp); HttpUtility::GetLastParameter(params, "comment"), persistent, tim estamp);
checkable->AcknowledgeProblem(HttpUtility::GetLastParameter(params, "auth or"), checkable->AcknowledgeProblem(HttpUtility::GetLastParameter(params, "auth or"),
HttpUtility::GetLastParameter(params, "comment"), sticky, notify, persistent, timestamp); HttpUtility::GetLastParameter(params, "comment"), sticky, notify, persistent, Utility::GetTime(), timestamp);
return ApiActions::CreateResult(200, "Successfully acknowledged problem f or object '" + checkable->GetName() + "'."); return ApiActions::CreateResult(200, "Successfully acknowledged problem f or object '" + checkable->GetName() + "'.");
} }
Dictionary::Ptr ApiActions::RemoveAcknowledgement(const ConfigObject::Ptr& objec t, Dictionary::Ptr ApiActions::RemoveAcknowledgement(const ConfigObject::Ptr& objec t,
const Dictionary::Ptr& params) const Dictionary::Ptr& params)
{ {
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object); Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
if (!checkable) if (!checkable)
return ApiActions::CreateResult(404, return ApiActions::CreateResult(404,
"Cannot remove acknowledgement for non-existent checkable object " "Cannot remove acknowledgement for non-existent checkable object "
+ object->GetName() + "."); + object->GetName() + ".");
checkable->ClearAcknowledgement(); String removedBy (HttpUtility::GetLastParameter(params, "author"));
checkable->RemoveCommentsByType(CommentAcknowledgement);
checkable->ClearAcknowledgement(removedBy);
checkable->RemoveCommentsByType(CommentAcknowledgement, removedBy);
return ApiActions::CreateResult(200, "Successfully removed acknowledgemen t for object '" + checkable->GetName() + "'."); return ApiActions::CreateResult(200, "Successfully removed acknowledgemen t for object '" + checkable->GetName() + "'.");
} }
Dictionary::Ptr ApiActions::AddComment(const ConfigObject::Ptr& object, Dictionary::Ptr ApiActions::AddComment(const ConfigObject::Ptr& object,
const Dictionary::Ptr& params) const Dictionary::Ptr& params)
{ {
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object); Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
if (!checkable) if (!checkable)
skipping to change at line 283 skipping to change at line 291
}); });
return ApiActions::CreateResult(200, "Successfully added comment '" return ApiActions::CreateResult(200, "Successfully added comment '"
+ commentName + "' for object '" + checkable->GetName() + commentName + "' for object '" + checkable->GetName()
+ "'.", additional); + "'.", additional);
} }
Dictionary::Ptr ApiActions::RemoveComment(const ConfigObject::Ptr& object, Dictionary::Ptr ApiActions::RemoveComment(const ConfigObject::Ptr& object,
const Dictionary::Ptr& params) const Dictionary::Ptr& params)
{ {
auto author (HttpUtility::GetLastParameter(params, "author"));
Checkable::Ptr checkable = dynamic_pointer_cast<Checkable>(object); Checkable::Ptr checkable = dynamic_pointer_cast<Checkable>(object);
if (checkable) { if (checkable) {
std::set<Comment::Ptr> comments = checkable->GetComments(); std::set<Comment::Ptr> comments = checkable->GetComments();
for (const Comment::Ptr& comment : comments) { for (const Comment::Ptr& comment : comments) {
{
ObjectLock oLock (comment);
comment->SetRemovedBy(author);
}
Comment::RemoveComment(comment->GetName()); Comment::RemoveComment(comment->GetName());
} }
return ApiActions::CreateResult(200, "Successfully removed all co mments for object '" + checkable->GetName() + "'."); return ApiActions::CreateResult(200, "Successfully removed all co mments for object '" + checkable->GetName() + "'.");
} }
Comment::Ptr comment = static_pointer_cast<Comment>(object); Comment::Ptr comment = static_pointer_cast<Comment>(object);
if (!comment) if (!comment)
return ApiActions::CreateResult(404, "Cannot remove non-existent comment object."); return ApiActions::CreateResult(404, "Cannot remove non-existent comment object.");
{
ObjectLock oLock (comment);
comment->SetRemovedBy(author);
}
String commentName = comment->GetName(); String commentName = comment->GetName();
Comment::RemoveComment(commentName); Comment::RemoveComment(commentName);
return ApiActions::CreateResult(200, "Successfully removed comment '" + c ommentName + "'."); return ApiActions::CreateResult(200, "Successfully removed comment '" + c ommentName + "'.");
} }
Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object, Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
const Dictionary::Ptr& params) const Dictionary::Ptr& params)
{ {
skipping to change at line 460 skipping to change at line 479
additional->Set("child_downtimes", new Array(std::move(childDownt imes))); additional->Set("child_downtimes", new Array(std::move(childDownt imes)));
} }
return ApiActions::CreateResult(200, "Successfully scheduled downtime '" + return ApiActions::CreateResult(200, "Successfully scheduled downtime '" +
downtimeName + "' for object '" + checkable->GetName() + "'.", ad ditional); downtimeName + "' for object '" + checkable->GetName() + "'.", ad ditional);
} }
Dictionary::Ptr ApiActions::RemoveDowntime(const ConfigObject::Ptr& object, Dictionary::Ptr ApiActions::RemoveDowntime(const ConfigObject::Ptr& object,
const Dictionary::Ptr& params) const Dictionary::Ptr& params)
{ {
auto author (HttpUtility::GetLastParameter(params, "author"));
Checkable::Ptr checkable = dynamic_pointer_cast<Checkable>(object); Checkable::Ptr checkable = dynamic_pointer_cast<Checkable>(object);
if (checkable) { if (checkable) {
std::set<Downtime::Ptr> downtimes = checkable->GetDowntimes(); std::set<Downtime::Ptr> downtimes = checkable->GetDowntimes();
for (const Downtime::Ptr& downtime : downtimes) { for (const Downtime::Ptr& downtime : downtimes) {
{
ObjectLock oLock (downtime);
downtime->SetRemovedBy(author);
}
Downtime::RemoveDowntime(downtime->GetName(), true); Downtime::RemoveDowntime(downtime->GetName(), true);
} }
return ApiActions::CreateResult(200, "Successfully removed all do wntimes for object '" + checkable->GetName() + "'."); return ApiActions::CreateResult(200, "Successfully removed all do wntimes for object '" + checkable->GetName() + "'.");
} }
Downtime::Ptr downtime = static_pointer_cast<Downtime>(object); Downtime::Ptr downtime = static_pointer_cast<Downtime>(object);
if (!downtime) if (!downtime)
return ApiActions::CreateResult(404, "Cannot remove non-existent downtime object."); return ApiActions::CreateResult(404, "Cannot remove non-existent downtime object.");
{
ObjectLock oLock (downtime);
downtime->SetRemovedBy(author);
}
String downtimeName = downtime->GetName(); String downtimeName = downtime->GetName();
Downtime::RemoveDowntime(downtimeName, true); Downtime::RemoveDowntime(downtimeName, true);
return ApiActions::CreateResult(200, "Successfully removed downtime '" + downtimeName + "'."); return ApiActions::CreateResult(200, "Successfully removed downtime '" + downtimeName + "'.");
} }
Dictionary::Ptr ApiActions::ShutdownProcess(const ConfigObject::Ptr& object, Dictionary::Ptr ApiActions::ShutdownProcess(const ConfigObject::Ptr& object,
const Dictionary::Ptr& params) const Dictionary::Ptr& params)
{ {
 End of changes. 10 change blocks. 
3 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)