Merge branch 'develop' into dist/risotto/risotto-2.8.0/develop

This commit is contained in:
Emmanuel Garette 2020-09-16 08:14:22 +02:00
commit 5e796f17d2
2 changed files with 12 additions and 173 deletions

View File

@ -1,167 +0,0 @@
-- Deployment
CREATE TABLE Deployment (
DeploymentId SERIAL PRIMARY KEY,
ProviderType VARCHAR(255) NOT NULL,
TargetType VARCHAR(255) NOT NULL,
TargetName VARCHAR(255) NOT NULL,
FactoryCluster VARCHAR(255),
FactoryNodeName VARCHAR(255),
CPU INTEGER,
VCPU INTEGER,
Memory INTEGER,
Labels VARCHAR(255) [] DEFAULT '{}',
UNIQUE (TargetType, TargetName)
);
CREATE INDEX Deployment_FactoryNodeName_index ON Deployment(FactoryNodeName);
-- Cluster
CREATE TABLE FactoryCluster (
ClusterId SERIAL PRIMARY KEY,
ClusterName VARCHAR(255) NOT NULL UNIQUE,
ClusterDescription VARCHAR(255) NOT NULL,
VirtualIp VARCHAR(15) NOT NULL,
ZoneName VARCHAR(255) NOT NULL
);
-- Node in Cluster
CREATE TABLE FactoryClusterNode (
ClusterNodeId SERIAL PRIMARY KEY,
ClusterId INTEGER NOT NULL,
ServerName VARCHAR(255) NOT NULL UNIQUE,
FOREIGN KEY (ClusterId) REFERENCES FactoryCluster(ClusterId)
);
CREATE INDEX FactoryClusterNode_ServerName_index ON FactoryClusterNode(ServerName);
-- Site
CREATE TABLE Site (
SiteId SERIAL PRIMARY KEY,
SiteName VARCHAR(255) NOT NULL UNIQUE,
SiteDescription VARCHAR(255) NOT NULL
);
-- Zone
CREATE TABLE Zone (
ZoneId SERIAL PRIMARY KEY,
ZoneName VARCHAR(255) NOT NULL UNIQUE,
ZoneDescription VARCHAR(255) NOT NULL,
SitesName VARCHAR(255) [] NOT NULL
);
-------------------------------------
-- Infra
-------------------------------------
-- Server
CREATE TABLE InfraServer(
ServerId SERIAL PRIMARY KEY,
ServerName VARCHAR(255) NOT NULL UNIQUE,
ServerDescription VARCHAR(255) NOT NULL,
ServerServermodelName VARCHAR(255) NOT NULL,
ReleaseDistribution VARCHAR(255) NOT NULL,
SiteName VARCHAR(255) NOT NULL,
ZonesName VARCHAR(255) [] NOT NULL,
ZonesIP VARCHAR(255) [] NOT NULL
);
-- Source
CREATE TABLE Source (
SourceId SERIAL PRIMARY KEY,
SourceName VARCHAR(255) NOT NULL UNIQUE,
SourceDirectory TEXT
);
-- Release
CREATE TABLE Release (
ReleaseId SERIAL PRIMARY KEY,
ReleaseName VARCHAR(255) NOT NULL,
ReleaseSourceId INTEGER NOT NULL,
ReleaseDistribution VARCHAR(20) CONSTRAINT releasedistribution_choice CHECK (ReleaseDistribution IN ('last', 'n-1', 'n-2')),
UNIQUE (ReleaseName, ReleaseSourceId),
UNIQUE (ReleaseDistribution, ReleaseSourceId),
FOREIGN KEY (ReleaseSourceId) REFERENCES Source(SourceId)
);
-------------------------------------
-- Setting
-------------------------------------
-- SettingServer
CREATE TABLE SettingServer(
ServerId SERIAL PRIMARY KEY,
ServerName VARCHAR(255) NOT NULL UNIQUE,
ServermodelName VARCHAR(255) NOT NULL,
ReleaseDistribution VARCHAR(255) NOT NULL
);
-- Servermodel
CREATE TABLE Servermodel (
ServermodelId SERIAL PRIMARY KEY,
ServermodelName VARCHAR(255) NOT NULL,
ServermodelDescription VARCHAR(255) NOT NULL,
Osname VARCHAR(255),
Osversion VARCHAR(255),
ISO VARCHAR(255),
ServermodelParents VARCHAR(255) [] DEFAULT '{}',
SourceName VARCHAR(255) NOT NULL,
ReleaseDistribution VARCHAR(255) NOT NULL,
ServermodelApplicationserviceId INTEGER NOT NULL,
UNIQUE (ServermodelName, SourceName, ReleaseDistribution)
);
CREATE INDEX ServermodelApplicationserviceId_index ON Servermodel (ServermodelApplicationserviceId);
-- Applicationservice
CREATE TABLE Applicationservice (
ApplicationserviceId SERIAL PRIMARY KEY,
ApplicationserviceName VARCHAR(255) NOT NULL,
ApplicationserviceDescription VARCHAR(255) NOT NULL,
ApplicationserviceReleaseId INTEGER NOT NULL,
--ApplicationserviceLVIS VARCHAR(255) NOT NULL,
--ApplicationserviceLVIP VARCHAR(255) NOT NULL,
--ApplicationserviceLVMP VARCHAR(255) NOT NULL,
OS JSON,
UNIQUE (ApplicationserviceName, ApplicationserviceReleaseId)
);
CREATE TABLE ApplicationserviceDependency (
ApplicationserviceId INTEGER NOT NULL,
ApplicationserviceDependencyId INTEGER NOT NULL,
UNIQUE(ApplicationserviceId, ApplicationserviceDependencyId),
FOREIGN KEY (ApplicationserviceId) REFERENCES Applicationservice(ApplicationserviceId),
FOREIGN KEY (ApplicationserviceDependencyId) REFERENCES Applicationservice(ApplicationserviceId)
);
-- Log
CREATE TABLE log(
Msg VARCHAR(255) NOT NULL,
Level VARCHAR(10) NOT NULL,
Path VARCHAR(255),
Username VARCHAR(100) NOT NULL,
Data JSON,
Date timestamp DEFAULT current_timestamp
);
-- User, Role and ACL
CREATE TABLE RisottoUser (
UserId SERIAL PRIMARY KEY,
UserLogin VARCHAR(100) NOT NULL UNIQUE,
UserName VARCHAR(100) NOT NULL,
UserSurname VARCHAR(100) NOT NULL
);
CREATE TABLE UserRole (
RoleId SERIAL PRIMARY KEY,
RoleUserId INTEGER NOT NULL,
RoleName VARCHAR(255) NOT NULL,
RoleAttribute VARCHAR(255),
RoleAttributeValue VARCHAR(255),
FOREIGN KEY (RoleUserId) REFERENCES RisottoUser(UserId)
);
CREATE TABLE URI (
URIId SERIAL PRIMARY KEY,
URIName VARCHAR(255) NOT NULL UNIQUE
);
CREATE TABLE RoleURI (
RoleName VARCHAR(255) NOT NULL,
URIId INTEGER NOT NULL,
FOREIGN KEY (URIId) REFERENCES URI(URIId),
PRIMARY KEY (RoleName, URIId)
);

View File

@ -1,17 +1,23 @@
%from os import listdir
%set %%dbname = %%getVar('risotto_main_dbname')
---
dbuser: %%getVar('risotto_db_user')
dbuser_options:
- LOGIN
- LOGIN
privileges:
%%{dbname}.public.*: 'ALL'
%%{dbname}.public: 'ALL'
%%{dbname}: 'ALL'
%%{dbname}.public.*: 'ALL'
%%{dbname}.public: 'ALL'
%%{dbname}: 'ALL'
dbhost: %%getVar('risotto_db_address')
dbport: 5432
dbtype: postgres
dbname: %%dbname
template: 'template0'
sqlscripts: ['/usr/share/eole/db/eole-risotto/gen/create_tables.sql']
sqlscripts:
%for %%file in %%listdir('/usr/share/eole/db/eole-risotto/gen/')
%if %%file.endswith('.sql')
- /usr/share/eole/db/eole-risotto/gen/%%file
%end if
%end for
pwd_files:
- {'file': '/etc/risotto/risotto.conf', 'pattern': 'RISOTTO_DB_PASSWORD='}
- {'file': '/etc/risotto/risotto.conf', 'pattern': 'RISOTTO_DB_PASSWORD='}