show/activitylog: fallback rendering for hosts...
...with obsolete parents, that have been removed in the meantime
This commit is contained in:
parent
081ea72497
commit
c0a8c49d4f
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue