mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
CoreApi: add a couple of helper methods
This commit is contained in:
parent
1a6fbd5cd7
commit
aa0c04d5e7
@ -102,6 +102,36 @@ class CoreApi implements DeploymentApiInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function acknowledgeHostProblem($host, $author, $comment)
|
||||||
|
{
|
||||||
|
$filter = 'host.name == "' . $host . '"';
|
||||||
|
return $this->client->post(
|
||||||
|
'actions/acknowledge-problem?type=Host&filter=' . rawurlencode($filter),
|
||||||
|
(object) array(
|
||||||
|
'author' => $author,
|
||||||
|
'comment' => $comment
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeHostAcknowledgement($host)
|
||||||
|
{
|
||||||
|
$filter = 'host.name == "' . $host . '"';
|
||||||
|
return $this->client->post(
|
||||||
|
'actions/remove-acknowledgement?type=Host&filter=' . rawurlencode($filter)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reloadNow()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->client->post('actions/restart-process');
|
||||||
|
return true;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getHostOutput($host)
|
public function getHostOutput($host)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -118,13 +148,12 @@ class CoreApi implements DeploymentApiInterface
|
|||||||
|
|
||||||
public function checkHostAndWaitForResult($host, $timeout = 10)
|
public function checkHostAndWaitForResult($host, $timeout = 10)
|
||||||
{
|
{
|
||||||
|
$now = microtime(true);
|
||||||
$this->checkHostNow($host);
|
$this->checkHostNow($host);
|
||||||
$now = time();
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
$object = $this->getObject($host, 'hosts');
|
$object = $this->getObject($host, 'hosts');
|
||||||
|
|
||||||
if (isset($object->attrs->last_check_result)) {
|
if (isset($object->attrs->last_check_result)) {
|
||||||
$res = $object->attrs->last_check_result;
|
$res = $object->attrs->last_check_result;
|
||||||
if ($res->execution_start > $now) {
|
if ($res->execution_start > $now) {
|
||||||
@ -140,7 +169,7 @@ class CoreApi implements DeploymentApiInterface
|
|||||||
$host
|
$host
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (time() > ($now + $timeout)) {
|
if (microtime(true) > ($now + $timeout)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +249,7 @@ constants
|
|||||||
return $constants;
|
return $constants;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function runConsoleCommand($command)
|
public function runConsoleCommand($command)
|
||||||
{
|
{
|
||||||
return $this->client->post(
|
return $this->client->post(
|
||||||
'console/execute-script',
|
'console/execute-script',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user