Commit e93f5ab6 authored by loiclau's avatar loiclau Committed by Loic Laurent

fix(clapi) link host with default poller if unknown poller (#6099)

parent ba022241
......@@ -45,4 +45,16 @@ class Centreon_Object_Instance extends Centreon_Object
protected $table = "nagios_server";
protected $primaryKey = "id";
protected $uniqueLabelField = "name";
public function getDefaultInstance()
{
$res = $this->db->query("SELECT `name` FROM `nagios_server` WHERE `is_default` = 1");
if( $res->rowCount() == 0) {
$res = $this->db->query("SELECT `name` FROM `nagios_server` WHERE `localhost` = '1'");
}
$row = $res->fetch();
return $row['name'];
}
}
......@@ -257,7 +257,14 @@ class CentreonHost extends CentreonObject
if ($instanceName) {
$tmp = $instanceObject->getIdByParameter($instanceObject->getUniqueLabelField(), $instanceName);
if (!count($tmp)) {
throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $instanceName);
$defaultInstanceName = $instanceObject->getDefaultInstance();
$tmp = $instanceObject->getIdByParameter(
$instanceObject->getUniqueLabelField(),
$defaultInstanceName
);
if (!count($tmp)) {
throw new CentreonClapiException(self::OBJECT_NOT_FOUND . " :" . $instanceName);
}
}
$instanceId = $tmp[0];
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment