Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b31a002
Alternative custom property support
raviks789 Mar 11, 2025
681db90
Edit host vars using REST api
raviks789 May 9, 2025
ea969ef
Apply for rule: Configurable for both dictionaries and arrays
raviks789 May 9, 2025
ee7433d
IcingaServiceForm: Support `apply for` rule for instantiable dictiona…
raviks789 May 16, 2025
6e4005d
IcingaService: Do not attach `config` to custom variables for apply f…
raviks789 May 16, 2025
7a65b71
`module.js`: Do not show count for fieldset element added in CustomPr…
raviks789 May 22, 2025
f523216
CustomVariableString: Render variables explicitily if the name is in …
raviks789 May 22, 2025
9d6208f
IcingaServiceForm: Show dictionary's nested keys accessible for apply…
raviks789 May 23, 2025
f6809ef
Rename 'config' to 'value' for items array/dictionary in apply-for-rule
raviks789 May 23, 2025
e7a9a97
IcingaServiceForm: Change the nested key suggestions to list
raviks789 May 26, 2025
d3a4b84
Render the host dictionary items as variable in apply-for-rule
raviks789 May 27, 2025
28b6cb1
Add SQL migration file
raviks789 Jun 4, 2025
15772d0
Fix: substr deprecation error
raviks789 Jun 13, 2025
d30a9fa
CustomVariables: Use operator '+=' instead of '=' if the variable is …
raviks789 Jul 1, 2025
fdf739b
Check for existence of custom variable in the object before storing it
raviks789 Jul 10, 2025
c1c08be
IcingaObjectHandler: Upadte/create the object first and then set the …
raviks789 Aug 14, 2025
fa0cc44
Temporary patch to distinguish instantiable and non instantaible dict…
raviks789 Aug 14, 2025
4c47125
New clean form for custom properties
raviks789 Aug 28, 2025
0c9a582
WIP: new mockup
raviks789 Sep 24, 2025
8ba8d2c
WIP: temporary migration script
raviks789 Sep 25, 2025
4d41fbc
Fix api update of custom variables
raviks789 Sep 25, 2025
b67a041
CustomVariables: Use property_uuid only for hosts
raviks789 Sep 26, 2025
e60f198
WIP: Use Icinga Web collapsible implementation for Nested Dictionary …
raviks789 Sep 26, 2025
1425cd0
WIP: cleanup
raviks789 Sep 26, 2025
69f30ff
Save fixed array type custom variables correctly
raviks789 Sep 30, 2025
f515998
Append inherited items for the dynamic dictionary custom variable ins…
raviks789 Sep 30, 2025
eb5c750
CustomVariable: Check for property_uuid before saving the custom vari…
raviks789 Oct 6, 2025
2ce57a0
Wip: cleanup IcingaObjectHandler
raviks789 Oct 6, 2025
07baa39
WIP: Basket configuration for custom properties
raviks789 Oct 9, 2025
e05edd3
IcingaConfigHelper: Expand config macro match
raviks789 Oct 10, 2025
8f85549
Fix: Issues with foreign key constraint modification for icinga_host_var
raviks789 Oct 15, 2025
baa7e69
Temporary documentation for new custom property implementation
raviks789 Oct 15, 2025
706dfd7
fix: additional cleanup
raviks789 Oct 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions application/clicommands/ExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ public function datafieldsAction()
);
}

/**
* Export all CustomProperty definitions
*
* USAGE
*
* icingacli director export customproperties [options]
*
* OPTIONS
*
* --no-pretty JSON is pretty-printed per default
* Use this flag to enforce unformatted JSON
*/
public function custompropertiesAction()
{
$export = new ImportExport($this->db());
echo $this->renderJson(
$export->serializeAllCustomProperties(),
! $this->params->shift('no-pretty')
);
}

/**
* Export all DataList definitions
*
Expand Down
74 changes: 74 additions & 0 deletions application/clicommands/HostsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

namespace Icinga\Module\Director\Clicommands;

use GuzzleHttp\Psr7\ServerRequest;
use Icinga\Module\Director\Cli\ObjectsCommand;
use Icinga\Module\Director\Forms\CustomPropertiesForm;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Objects\IcingaObject;
use PDO;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;

/**
* Manage Icinga Hosts
Expand All @@ -11,4 +18,71 @@
*/
class HostsCommand extends ObjectsCommand
{
public function refreshCustomVarsAction(): void
{
foreach ($this->getObjects() as $o) {
$vars = $o->vars();
$objectProperties = $this->getObjectCustomProperties($o);

foreach ($objectProperties as $key => $property) {
$var = $vars->get($key);
if ($var && $property['uuid'] !== null) {
$var->setUuid(Uuid::fromBytes($property['uuid']));
$vars->set($key, $var);
}
}

$vars->storeToDb($o);
}
}

private function getObjectCustomProperties(IcingaObject $object)
{
if ($object->uuid === null) {
return [];
}

$type = $object->getShortTableName();

$parents = $object->listAncestorIds();

$uuids = [];
$db = $object->getConnection();

foreach ($parents as $parent) {
$uuids[] = IcingaHost::loadWithAutoIncId($parent, $db)->get('uuid');
}

$uuids[] = (int) $object->get('uuid');
$query = $db->getDbAdapter()
->select()
->from(
['dp' => 'director_property'],
[
'key_name' => 'dp.key_name',
'uuid' => 'dp.uuid',
$type . '_uuid' => 'iop.' . $type . '_uuid',
'value_type' => 'dp.value_type',
'label' => 'dp.label',
'children' => 'COUNT(cdp.uuid)'
]
)
->join(['iop' => "icinga_$type" . '_property'], 'dp.uuid = iop.property_uuid', [])
->joinLeft(['cdp' => 'director_property'], 'cdp.parent_uuid = dp.uuid', [])
->where('iop.' . $type . '_uuid IN (?)', $uuids)
->group(['dp.uuid', 'dp.key_name', 'dp.value_type', 'dp.label'])
->order(
"FIELD(dp.value_type, 'string', 'number', 'bool', 'fixed-array',"
. " 'dynamic-array', 'fixed-dictionary', 'dynamic-dictionary')"
)
->order('children')
->order('key_name');

$result = [];
foreach ($db->getDbAdapter()->fetchAll($query, fetchMode: PDO::FETCH_ASSOC) as $row) {
$result[$row['key_name']] = $row;
}

return $result;
}
}
2 changes: 1 addition & 1 deletion application/controllers/BasketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function snapshotAction()
$this->addSingleTab($this->translate('Snapshot'));
$diff = new BasketDiff($snapshot, $connection);
foreach ($diff->getBasketObjects() as $type => $objects) {
if ($type === 'Datafield') {
if ($type === 'Datafield' || $type === 'Property') {
// TODO: we should now be able to show all fields and link
// to a "diff" for the ones that should be created
// $this->content()->add(Html::tag('h2', sprintf('+%d Datafield(s)', count($objects))));
Expand Down
Loading
Loading