show/activitylog: fallback rendering for hosts...

...with obsolete parents, that have been removed in the meantime
This commit is contained in:
Thomas Gelf 2016-10-06 16:29:50 +00:00
parent 081ea72497
commit c0a8c49d4f
3 changed files with 22 additions and 3 deletions

View File

@ -77,6 +77,10 @@ class ShowController extends ActionController
protected function getObjectConfig($object)
{
$config = new IcingaConfig($this->db());
if ($object->isExternal()) {
$object->object_type = 'object';
}
$object->renderToConfig($config);
return $config;
}

View File

@ -110,6 +110,7 @@ class IcingaHost extends IcingaObject
}
$hostVars = array();
if ($connection !== null) {
foreach ($connection->fetchDistinctHostVars() as $var) {
if ($var->datatype) {
@ -167,6 +168,10 @@ class IcingaHost extends IcingaObject
return;
}
if ($this->getRenderingZone($config) === self::RESOLVE_ERROR) {
return;
}
if ($this->getResolvedProperty('has_agent') !== 'y') {
return;
}

View File

@ -16,6 +16,8 @@ use Exception;
abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
{
const RESOLVE_ERROR = '(unable to resolve)';
protected $keyName = 'object_name';
protected $autoincKeyName = 'id';
@ -1295,9 +1297,17 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
public function getRenderingZone(IcingaConfig $config = null)
{
if ($zoneId = $this->getResolvedProperty('zone_id')) {
// Config has a lookup cache, is faster:
return $config->getZoneName($zoneId);
if ($this->hasUnresolvedRelatedProperty('zone_id')) {
return $this->zone;
}
try {
if ($zoneId = $this->getResolvedProperty('zone_id')) {
// Config has a lookup cache, is faster:
return $config->getZoneName($zoneId);
}
} catch (Exception $e) {
return self::RESOLVE_ERROR;
}
if ($this->prefersGlobalZone()) {