IcingaApiUser: introduce a new object type

This commit is contained in:
Thomas Gelf 2015-12-17 14:29:08 +01:00
parent b73806d69c
commit 08c3614620
4 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,19 @@
<?php
namespace Icinga\Module\Director\Objects;
class IcingaApiUser extends IcingaObject
{
protected $table = 'icinga_apiuser';
protected $supportsImports = true;
protected $defaultProperties = array(
'id' => null,
'object_name' => null,
'object_type' => null,
'password' => null,
'client_dn' => null,
'permissions' => null,
);
}

View File

@ -16,14 +16,21 @@ class IcingaEndpoint extends IcingaObject
'port' => null,
'log_duration' => null,
'object_type' => null,
'apiuser_id' => null,
);
protected $relations = array(
'zone' => 'IcingaZone',
'zone' => 'IcingaZone',
'apiuser' => 'IcingaApiUser',
);
protected function renderLog_duration()
{
return $this->renderPropertyAsSeconds('log_duration');
}
protected function renderApiuser_id()
{
return '';
}
}

View File

@ -0,0 +1,20 @@
CREATE TABLE icinga_apiuser (
id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
object_name VARCHAR(255) NOT NULL,
object_type ENUM('object', 'template', 'external_object') NOT NULL,
password VARCHAR(255) DEFAULT NULL,
client_dn VARCHAR(64) DEFAULT NULL,
permissions TEXT DEFAULT NULL COMMENT 'JSON-encoded permissions',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE icinga_endpoint
ADD COLUMN apiuser_id INT(10) UNSIGNED DEFAULT NULL,
ADD CONSTRAINT icinga_apiuser
FOREIGN KEY apiuser (apiuser_id)
REFERENCES icinga_apiuser (id)
ON DELETE RESTRICT
ON UPDATE CASCADE;

View File

@ -320,6 +320,16 @@ CREATE TABLE icinga_command_var (
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_apiuser (
id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
object_name VARCHAR(255) NOT NULL,
object_type ENUM('object', 'template', 'external_object') NOT NULL,
password VARCHAR(255) DEFAULT NULL,
client_dn VARCHAR(64) DEFAULT NULL,
permissions TEXT DEFAULT NULL COMMENT 'JSON-encoded permissions',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_endpoint (
id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
zone_id INT(10) UNSIGNED DEFAULT NULL,
@ -328,12 +338,18 @@ CREATE TABLE icinga_endpoint (
port SMALLINT UNSIGNED DEFAULT NULL COMMENT '5665 if not set',
log_duration VARCHAR(32) DEFAULT NULL COMMENT '1d if not set',
object_type ENUM('object', 'template', 'external_object') NOT NULL,
apiuser_id INT(10) UNSIGNED DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE INDEX object_name (object_name),
CONSTRAINT icinga_endpoint_zone
FOREIGN KEY zone (zone_id)
REFERENCES icinga_zone (id)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT icinga_apiuser
FOREIGN KEY apiuser (apiuser_id)
REFERENCES icinga_apiuser (id)
ON DELETE RESTRICT
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;