From e08e19ee64d672663d406696166aba75cef2527b Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 23 Dec 2019 12:58:03 -0500 Subject: [PATCH] Add provisioner database schema --- roles/pvc/files/patroni/provisioner-schema.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 roles/pvc/files/patroni/provisioner-schema.sql diff --git a/roles/pvc/files/patroni/provisioner-schema.sql b/roles/pvc/files/patroni/provisioner-schema.sql new file mode 100644 index 0000000..7ca7c6e --- /dev/null +++ b/roles/pvc/files/patroni/provisioner-schema.sql @@ -0,0 +1,15 @@ +CREATE DATABASE pvcprov WITH owner = pvcprov CONNECTION LIMIT = -1; +\c pvcprov +CREATE TABLE system_template (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, vcpu_count INT NOT NULL, vram_mb INT NOT NULL, serial BOOL NOT NULL, vnc BOOL NOT NULL, vnc_bind TEXT, node_limit TEXT, node_selector TEXT, start_with_node BOOL NOT NULL); +CREATE TABLE network_template (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, mac_template TEXT); +CREATE TABLE network (id SERIAL PRIMARY KEY, network_template INT REFERENCES network_template(id), vni INT NOT NULL); +CREATE TABLE storage_template (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE); +CREATE TABLE storage (id SERIAL PRIMARY KEY, storage_template INT REFERENCES storage_template(id), pool TEXT NOT NULL, disk_id TEXT NOT NULL, disk_size_gb INT NOT NULL, mountpoint TEXT, filesystem TEXT, filesystem_args TEXT); +CREATE TABLE userdata_template (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, userdata TEXT NOT NULL); +CREATE TABLE script (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, script TEXT NOT NULL); +CREATE TABLE profile (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, system_template INT REFERENCES system_template(id), network_template INT REFERENCES network_template(id), storage_template INT REFERENCES storage_template(id), userdata_template INT REFERENCES userdata_template(id), script INT REFERENCES script(id), arguments text); +GRANT ALL PRIVILEGES ON DATABASE pvcprov TO pvcprov; +GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO pvcprov; +GRANT ALL PRIVILEGES ON ALL SQQUENCES IN SCHEMA public TO pvcprov; + +INSERT INTO userdata_template(name, userdata) VALUES ('empty', '');