Objects: add uuid column

This commit is contained in:
Thomas Gelf 2021-10-05 18:19:01 +02:00
parent 65bbaa9f98
commit 792ff03a6d
14 changed files with 57 additions and 4 deletions

View File

@ -8,18 +8,21 @@ class IcingaApiUser extends IcingaObject
{ {
protected $table = 'icinga_apiuser'; protected $table = 'icinga_apiuser';
protected $uuidColumn = 'uuid';
// TODO: Enable (and add table) if required // TODO: Enable (and add table) if required
protected $supportsImports = false; protected $supportsImports = false;
protected $defaultProperties = array( protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',
'password' => null, 'password' => null,
'client_dn' => null, 'client_dn' => null,
'permissions' => null, 'permissions' => null,
); ];
protected function renderPassword() protected function renderPassword()
{ {

View File

@ -18,8 +18,11 @@ class IcingaCommand extends IcingaObject implements ObjectWithArguments, ExportI
protected $type = 'CheckCommand'; protected $type = 'CheckCommand';
protected $uuidColumn = 'uuid';
protected $defaultProperties = [ protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',

View File

@ -16,6 +16,7 @@ class IcingaDependency extends IcingaObject implements ExportInterface
protected $defaultProperties = [ protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',
@ -34,6 +35,8 @@ class IcingaDependency extends IcingaObject implements ExportInterface
'parent_service_by_name' => null, 'parent_service_by_name' => null,
]; ];
protected $uuidColumn = 'uuid';
protected $supportsCustomVars = false; protected $supportsCustomVars = false;
protected $supportsImports = true; protected $supportsImports = true;

View File

@ -15,8 +15,11 @@ class IcingaEndpoint extends IcingaObject
protected $supportsImports = true; protected $supportsImports = true;
protected $uuidColumn = 'uuid';
protected $defaultProperties = [ protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'zone_id' => null, 'zone_id' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,

View File

@ -22,6 +22,7 @@ class IcingaHost extends IcingaObject implements ExportInterface
protected $defaultProperties = array( protected $defaultProperties = array(
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',
@ -101,6 +102,8 @@ class IcingaHost extends IcingaObject implements ExportInterface
/** @var HostGroupMembershipResolver */ /** @var HostGroupMembershipResolver */
protected $hostgroupMembershipResolver; protected $hostgroupMembershipResolver;
protected $uuidColumn = 'uuid';
public static function enumProperties( public static function enumProperties(
DbConnection $connection = null, DbConnection $connection = null,
$prefix = '', $prefix = '',

View File

@ -14,6 +14,7 @@ class IcingaNotification extends IcingaObject implements ExportInterface
protected $defaultProperties = [ protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',
@ -31,6 +32,8 @@ class IcingaNotification extends IcingaObject implements ExportInterface
'assign_filter' => null, 'assign_filter' => null,
]; ];
protected $uuidColumn = 'uuid';
protected $supportsCustomVars = true; protected $supportsCustomVars = true;
protected $supportsFields = true; protected $supportsFields = true;

View File

@ -2159,6 +2159,11 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return ''; return '';
} }
public function renderUuid()
{
return '';
}
/** /**
* @return string * @return string
*/ */
@ -2785,6 +2790,9 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
foreach ($p as $k => $v) { foreach ($p as $k => $v) {
// Do not ship ids for IcingaObjects: // Do not ship ids for IcingaObjects:
if ($k === $this->getUuidColumn()) {
continue;
}
if ($resolveIds) { if ($resolveIds) {
if ($k === 'id' && $keepId === false && $this->hasProperty('object_name')) { if ($k === 'id' && $keepId === false && $this->hasProperty('object_name')) {
continue; continue;
@ -3003,6 +3011,9 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
public function getUrlParams() public function getUrlParams()
{ {
$params = []; $params = [];
if ($column = $this->getUuidColumn()) {
return [$column => $this->getUniqueId()->toString()];
}
if ($this->isApplyRule() && ! $this instanceof IcingaScheduledDowntime) { if ($this->isApplyRule() && ! $this instanceof IcingaScheduledDowntime) {
$params['id'] = $this->get('id'); $params['id'] = $this->get('id');
@ -3056,6 +3067,9 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
if ($k === 'id' && $this->hasProperty('object_name')) { if ($k === 'id' && $this->hasProperty('object_name')) {
continue; continue;
} }
if ($k === $this->getUuidColumn()) {
continue;
}
if ('_id' === substr($k, -3)) { if ('_id' === substr($k, -3)) {
$relKey = substr($k, 0, -3); $relKey = substr($k, 0, -3);

View File

@ -12,8 +12,11 @@ abstract class IcingaObjectGroup extends IcingaObject implements ExportInterface
protected $supportedInLegacy = true; protected $supportedInLegacy = true;
protected $uuidColumn = 'uuid';
protected $defaultProperties = [ protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',

View File

@ -11,6 +11,7 @@ class IcingaScheduledDowntime extends IcingaObject
protected $defaultProperties = [ protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'zone_id' => null, 'zone_id' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
@ -24,6 +25,8 @@ class IcingaScheduledDowntime extends IcingaObject
'with_services' => null, 'with_services' => null,
]; ];
protected $uuidColumn = 'uuid';
protected $supportsImports = true; protected $supportsImports = true;
protected $supportsRanges = true; protected $supportsRanges = true;

View File

@ -23,8 +23,11 @@ class IcingaService extends IcingaObject implements ExportInterface
protected $table = 'icinga_service'; protected $table = 'icinga_service';
protected $uuidColumn = 'uuid';
protected $defaultProperties = [ protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',

View File

@ -10,8 +10,11 @@ class IcingaTimePeriod extends IcingaObject implements ExportInterface
{ {
protected $table = 'icinga_timeperiod'; protected $table = 'icinga_timeperiod';
protected $defaultProperties = array( protected $uuidColumn = 'uuid';
protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'zone_id' => null, 'zone_id' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
@ -19,7 +22,7 @@ class IcingaTimePeriod extends IcingaObject implements ExportInterface
'prefer_includes' => null, 'prefer_includes' => null,
'display_name' => null, 'display_name' => null,
'update_method' => null, 'update_method' => null,
); ];
protected $booleans = [ protected $booleans = [
'prefer_includes' => 'prefer_includes', 'prefer_includes' => 'prefer_includes',

View File

@ -12,6 +12,7 @@ class IcingaUser extends IcingaObject implements ExportInterface
protected $defaultProperties = array( protected $defaultProperties = array(
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',
@ -23,6 +24,8 @@ class IcingaUser extends IcingaObject implements ExportInterface
'zone_id' => null, 'zone_id' => null,
); );
protected $uuidColumn = 'uuid';
protected $supportsGroups = true; protected $supportsGroups = true;
protected $supportsCustomVars = true; protected $supportsCustomVars = true;

View File

@ -6,8 +6,11 @@ class IcingaUserGroup extends IcingaObjectGroup
{ {
protected $table = 'icinga_usergroup'; protected $table = 'icinga_usergroup';
protected $uuidColumn = 'uuid';
protected $defaultProperties = [ protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',

View File

@ -10,8 +10,11 @@ class IcingaZone extends IcingaObject
{ {
protected $table = 'icinga_zone'; protected $table = 'icinga_zone';
protected $uuidColumn = 'uuid';
protected $defaultProperties = [ protected $defaultProperties = [
'id' => null, 'id' => null,
'uuid' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'disabled' => 'n', 'disabled' => 'n',