IcingaHost: add enumProperties, test for now
This commit is contained in:
parent
988eb4bf77
commit
c4f8425634
|
@ -382,6 +382,25 @@ class Db extends DbConnection
|
|||
return $this->enum('icinga_' . $type, null, $filters);
|
||||
}
|
||||
|
||||
public function fetchDistinctHostVars()
|
||||
{
|
||||
$select = $this->db()->select()->distinct()->from(
|
||||
array('hv' => 'icinga_host_var'),
|
||||
array(
|
||||
'varname' => 'hv.varname',
|
||||
'format' => 'hv.format',
|
||||
'caption' => 'df.caption',
|
||||
'datatype' => 'df.datatype'
|
||||
)
|
||||
)->joinLeft(
|
||||
array('df' => 'director_datafield'),
|
||||
'df.varname = hv.varname',
|
||||
array()
|
||||
)->order('varname');
|
||||
|
||||
return $this->db()->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getUncollectedDeployments()
|
||||
{
|
||||
$db = $this->db();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Icinga\Module\Director\Objects;
|
||||
|
||||
use Icinga\Data\Db\DbConnection;
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaHost extends IcingaObject
|
||||
|
@ -46,6 +47,25 @@ class IcingaHost extends IcingaObject
|
|||
|
||||
protected $supportsFields = true;
|
||||
|
||||
public static function enumProperties(DbConnection $connection = null)
|
||||
{
|
||||
$properties = static::create()->listProperties();
|
||||
$properties = array_combine($properties, $properties);
|
||||
if ($connection !== null) {
|
||||
foreach ($connection->fetchDistinctHostVars() as $var) {
|
||||
if ($var->datatype) {
|
||||
$properties['vars.' . $var->varname] = $var->caption;
|
||||
} else {
|
||||
$properties['vars.' . $var->varname] = 'vars.' . $var->varname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$properties['vars.*'] = 'Other custom variable';
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
protected function renderCheck_command_id()
|
||||
{
|
||||
return $this->renderCommandProperty($this->check_command_id);
|
||||
|
|
Loading…
Reference in New Issue