-- This is the database schema for the 'scan-cluster Scan Agent'. -- -- NOTE: This agent is not host-bound. It's update by node 1 if it's in the cluster, else by node 2 if it's -- the only one online. CREATE TABLE scan_cluster ( scan_cluster_uuid uuid primary key, scan_cluster_name text not null, -- The name of the cluster scan_cluster_stonith_enabled boolean not null, -- Tracks when stonith (fencing) was enabled/disabled scan_cluster_maintenance_mode boolean not null, -- Tracks when maintenance mode is enabled/disabled. modified_date timestamp with time zone not null, FOREIGN KEY(scan_cluster_host_uuid) REFERENCES hosts(host_uuid) ); ALTER TABLE scan_cluster OWNER TO admin; CREATE TABLE history.scan_cluster ( history_id bigserial, scan_cluster_uuid uuid, scan_cluster_name text, scan_cluster_stonith_enabled boolean, scan_cluster_maintenance_mode boolean, modified_date timestamp with time zone not null ); ALTER TABLE history.scan_cluster OWNER TO admin; CREATE FUNCTION history_scan_cluster() RETURNS trigger AS $$ DECLARE history_scan_cluster RECORD; BEGIN SELECT INTO history_scan_cluster * FROM scan_cluster WHERE scan_cluster_uuid=new.scan_cluster_uuid; INSERT INTO history.scan_cluster (scan_cluster_uuid, scan_cluster_name, scan_cluster_stonith_enabled, scan_cluster_maintenance_mode, modified_date) VALUES (history_scan_cluster.scan_cluster_uuid, history_scan_cluster.scan_cluster_host_uuid, history_scan_cluster.scan_cluster_name, history_scan_cluster.scan_cluster_stonith_enabled, history_scan_cluster.scan_cluster_maintenance_mode, history_scan_cluster.modified_date); RETURN NULL; END; $$ LANGUAGE plpgsql; ALTER FUNCTION history_scan_cluster() OWNER TO admin; CREATE TRIGGER trigger_scan_cluster AFTER INSERT OR UPDATE ON scan_cluster FOR EACH ROW EXECUTE PROCEDURE history_scan_cluster(); CREATE TABLE scan_cluster_nodes ( scan_cluster_node_uuid uuid primary key, scan_cluster_node_scan_cluster_uuid uuid not null, -- The parent scan_cluster_uuid. scan_cluster_node_host_uuid uuid not null, -- This is the host UUID of the node. scan_cluster_node_name text not null, -- This is the host name as reported by pacemaker. It _should_ match up to a host name in 'hosts'. scan_cluster_node_pacemaker_id numeric not null, -- This is the internal pacemaker ID number of this node. modified_date timestamp with time zone not null, FOREIGN KEY(scan_cluster_node_scan_cluster_uuid) REFERENCES scan_cluster(scan_cluster_uuid), FOREIGN KEY(scan_cluster_host_uuid) REFERENCES hosts(host_uuid) ); ALTER TABLE scan_cluster_nodes OWNER TO admin; CREATE TABLE history.scan_cluster_nodes ( history_id bigserial, scan_cluster_node_uuid uuid, scan_cluster_node_scan_cluster_uuid uuid, scan_cluster_node_host_uuid uuid, scan_cluster_node_name text, scan_cluster_node_pacemaker_id numeric, modified_date timestamp with time zone not null ); ALTER TABLE history.scan_cluster_nodes OWNER TO admin; CREATE FUNCTION history_scan_cluster_nodes() RETURNS trigger AS $$ DECLARE history_scan_cluster_nodes RECORD; BEGIN SELECT INTO history_scan_cluster_nodes * FROM scan_cluster_nodes WHERE scan_cluster_node_uuid=new.scan_cluster_node_uuid; INSERT INTO history.scan_cluster_nodes (scan_cluster_node_uuid, scan_cluster_node_scan_cluster_uuid, scan_cluster_node_host_uuid, scan_cluster_node_name, scan_cluster_node_pacemaker_id, modified_date) VALUES (history_scan_cluster_nodes.scan_cluster_node_uuid, history_scan_cluster_nodes.scan_cluster_node_scan_cluster_uuid, history_scan_cluster_nodes.scan_cluster_node_host_uuid, history_scan_cluster_nodes.scan_cluster_node_name, history_scan_cluster_nodes.scan_cluster_node_pacemaker_id, history_scan_cluster_nodes.modified_date); RETURN NULL; END; $$ LANGUAGE plpgsql; ALTER FUNCTION history_scan_cluster_nodes() OWNER TO admin; CREATE TRIGGER trigger_scan_cluster_nodes AFTER INSERT OR UPDATE ON scan_cluster_nodes FOR EACH ROW EXECUTE PROCEDURE history_scan_cluster_nodes(); CREATE TABLE scan_cluster_stoniths ( scan_cluster_stonith_uuid uuid primary key, scan_cluster_stonith_scan_cluster_uuid uuid not null, -- The parent scan_cluster_uuid. scan_cluster_stonith_host_uuid uuid not null, -- This is the host UUID of the node. scan_cluster_stonith_name text not null, -- This is the 'stonith id' scan_cluster_stonith_arguments text not null, -- This is the fence agent + collection of primitive variable=value pairs (the nvpairs) scan_cluster_stonith_operations text not null, -- This is the collection of operation variable=value pairs (the nvpairs) modified_date timestamp with time zone not null, FOREIGN KEY(scan_cluster_stonith_scan_cluster_uuid) REFERENCES scan_cluster(scan_cluster_uuid), FOREIGN KEY(scan_cluster_host_uuid) REFERENCES hosts(host_uuid) ); ALTER TABLE scan_cluster_stoniths OWNER TO admin; CREATE TABLE history.scan_cluster_stoniths ( history_id bigserial, scan_cluster_stonith_uuid uuid, scan_cluster_stonith_scan_cluster_uuid uuid, scan_cluster_stonith_host_uuid uuid, scan_cluster_stonith_name text, scan_cluster_stonith_arguments text, scan_cluster_stonith_operations text, modified_date timestamp with time zone not null ); ALTER TABLE history.scan_cluster_stoniths OWNER TO admin; CREATE FUNCTION history_scan_cluster_stoniths() RETURNS trigger AS $$ DECLARE history_scan_cluster_stoniths RECORD; BEGIN SELECT INTO history_scan_cluster_stoniths * FROM scan_cluster_stoniths WHERE scan_cluster_stonith_uuid=new.scan_cluster_stonith_uuid; INSERT INTO history.scan_cluster_stoniths (scan_cluster_stonith_uuid, scan_cluster_stonith_scan_cluster_uuid, scan_cluster_stonith_host_uuid, scan_cluster_stonith_name, scan_cluster_stonith_arguments, scan_cluster_stonith_operations, modified_date) VALUES (history_scan_cluster_stoniths.scan_cluster_stonith_uuid, history_scan_cluster_stoniths.scan_cluster_stonith_scan_cluster_uuid, history_scan_cluster_stoniths.scan_cluster_stonith_host_uuid, history_scan_cluster_stoniths.scan_cluster_stonith_name, history_scan_cluster_stoniths.scan_cluster_stonith_arguments, history_scan_cluster_stoniths.scan_cluster_stonith_operations, history_scan_cluster_stoniths.modified_date); RETURN NULL; END; $$ LANGUAGE plpgsql; ALTER FUNCTION history_scan_cluster_stoniths() OWNER TO admin; CREATE TRIGGER trigger_scan_cluster_stoniths AFTER INSERT OR UPDATE ON scan_cluster_stoniths FOR EACH ROW EXECUTE PROCEDURE history_scan_cluster_stoniths(); CREATE TABLE scan_cluster_servers ( scan_cluster_server_uuid uuid primary key, scan_cluster_server_scan_cluster_uuid uuid not null, -- The parent scan_cluster_uuid. scan_cluster_server_name text not null, -- This is the name of the server (ocf primitive id) scan_cluster_server_state text not null, -- This is the 'running' or why it's off (off by user, etc) scan_cluster_server_host_name uuid not null, -- This is the (cluster) name of the node hosting the server. Blank if the server is off. scan_cluster_server_arguments text not null, -- This is the collection of primitive variable=value pairs (the nvpairs) scan_cluster_server_operations text not null, -- This is the collection of operation variable=value pairs (the nvpairs) scan_cluster_server_meta text not null, -- This is the collection of meta attribute variable=value pairs (the nvpairs) modified_date timestamp with time zone not null, FOREIGN KEY(scan_cluster_server_scan_cluster_uuid) REFERENCES scan_cluster(scan_cluster_uuid), FOREIGN KEY(scan_cluster_host_uuid) REFERENCES hosts(host_uuid) ); ALTER TABLE scan_cluster_servers OWNER TO admin; CREATE TABLE history.scan_cluster_servers ( history_id bigserial, scan_cluster_server_uuid uuid, scan_cluster_server_scan_cluster_uuid uuid, scan_cluster_server_name text, scan_cluster_server_arguments text, scan_cluster_server_operations text, scan_cluster_server_meta text, modified_date timestamp with time zone not null ); ALTER TABLE history.scan_cluster_servers OWNER TO admin; CREATE FUNCTION history_scan_cluster_servers() RETURNS trigger AS $$ DECLARE history_scan_cluster_servers RECORD; BEGIN SELECT INTO history_scan_cluster_servers * FROM scan_cluster_servers WHERE scan_cluster_server_uuid=new.scan_cluster_server_uuid; INSERT INTO history.scan_cluster_servers (scan_cluster_server_uuid, scan_cluster_server_scan_cluster_uuid, scan_cluster_server_name, scan_cluster_server_arguments, scan_cluster_server_operations, scan_cluster_server_meta, modified_date) VALUES (history_scan_cluster_servers.scan_cluster_server_uuid, history_scan_cluster_servers.scan_cluster_server_scan_cluster_uuid, history_scan_cluster_servers.scan_cluster_server_host_uuid, history_scan_cluster_servers.scan_cluster_server_name, history_scan_cluster_servers.scan_cluster_server_arguments, history_scan_cluster_servers.scan_cluster_server_operations, history_scan_cluster_servers.modified_date); RETURN NULL; END; $$ LANGUAGE plpgsql; ALTER FUNCTION history_scan_cluster_servers() OWNER TO admin; CREATE TRIGGER trigger_scan_cluster_servers AFTER INSERT OR UPDATE ON scan_cluster_servers FOR EACH ROW EXECUTE PROCEDURE history_scan_cluster_servers(); -- Example CIB # pcs resource * srv07-el6 (ocf::alteeve:server): Stopped (disabled) * srv01-sql (ocf::alteeve:server): Started mk-a02n01 * srv02-lab1 (ocf::alteeve:server): Started mk-a02n01 * srv08-m2-psql (ocf::alteeve:server): Stopped (disabled) --