Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(clapi): use downtime_id to show and cancel rtdowntimes (19.x) #8212

Merged
merged 2 commits into from
Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Centreon/Object/Downtime/RtDowntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getHostDowntimes($hostList = array())
$hostFilter = "AND h.name IN ('" . implode("','", $hostList) . "') ";
}

$query = "SELECT internal_id, name, author, actual_start_time , actual_end_time, " .
$query = "SELECT downtime_id, name, author, actual_start_time , actual_end_time, " .
"start_time, end_time, comment_data, duration, fixed " .
"FROM downtimes d, hosts h " .
"WHERE d.host_id = h.host_id " .
Expand Down Expand Up @@ -91,7 +91,7 @@ public function getSvcDowntimes($svcList = array())
$serviceFilter .= implode(' AND ', $filterTab) . ') ';
}

$query = "SELECT d.internal_id, h.name, s.description, author, actual_start_time, actual_end_time, " .
$query = "SELECT d.downtime_id, h.name, s.description, author, actual_start_time, actual_end_time, " .
"start_time, end_time, comment_data, duration, fixed " .
"FROM downtimes d, hosts h, services s " .
"WHERE d.service_id = s.service_id " .
Expand All @@ -112,7 +112,7 @@ public function getSvcDowntimes($svcList = array())
public function getCurrentDowntime($id)
{
$query = "SELECT * FROM downtimes WHERE ISNULL(actual_end_time) " .
" AND end_time > " . time() . " AND internal_id = " . $id;
" AND end_time > " . time() . " AND downtime_id = " . $id;
return $this->getResult($query, array(), 'fetch');
}
}
15 changes: 11 additions & 4 deletions www/class/centreon-clapi/centreonRtDowntime.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ public function show($parameters = null, $filter = array())
*/
public function showHost($hostList)
{
$unknownHost = [];

$fields = array(
'id',
'host_name',
Expand All @@ -252,7 +254,6 @@ function ($element) use ($db) {
);

// check if host exist
$unknownHost = array();
$existingHost = array();
foreach ($hostList as $host) {
if ($this->hostObject->getHostID($host) == 0) {
Expand Down Expand Up @@ -750,10 +751,16 @@ public function cancel($parameters = null)
$infoDowntime = $this->object->getCurrentDowntime($downtime);
if ($infoDowntime) {
$hostName = $this->hostObject->getHostName($infoDowntime['host_id']);
if (is_null($infoDowntime['service_id'])) {
$this->externalCmdObj->deleteDowntime('HOST', array($hostName . ';' . $downtime => 'on'));
if (is_null($infoDowntime['service_id']) || $infoDowntime['service_id'] == 0) {
$this->externalCmdObj->deleteDowntime(
'HOST',
array($hostName . ';' . $infoDowntime['internal_id'] => 'on')
);
} else {
$this->externalCmdObj->deleteDowntime('SVC', array($hostName . ';' . $downtime => 'on'));
$this->externalCmdObj->deleteDowntime(
'SVC',
array($hostName . ';' . $infoDowntime['internal_id'] => 'on')
);
}
} else {
$unknownDowntime[] = $downtime;
Expand Down