Tagging module PLCAPI - PLCAPI-dummynet-16
[plcapi.git] / planetlab4.sql
index 76e9937..3ee50a3 100644 (file)
@@ -37,7 +37,7 @@ CREATE TABLE plc_db_version (
     subversion integer NOT NULL DEFAULT 0
 ) WITH OIDS;
 
-INSERT INTO plc_db_version (version, subversion) VALUES (4, 8);
+INSERT INTO plc_db_version (version, subversion) VALUES (4, 9);
 
 --------------------------------------------------------------------------------
 -- Accounts
@@ -258,9 +258,10 @@ CREATE TABLE boot_states (
 ) WITH OIDS;
 INSERT INTO boot_states (boot_state) VALUES ('boot');
 INSERT INTO boot_states (boot_state) VALUES ('dbg');
+INSERT INTO boot_states (boot_state) VALUES ('diag');
+INSERT INTO boot_states (boot_state) VALUES ('disable');
 INSERT INTO boot_states (boot_state) VALUES ('inst');
 INSERT INTO boot_states (boot_state) VALUES ('rins');
-INSERT INTO boot_states (boot_state) VALUES ('rcnf');
 INSERT INTO boot_states (boot_state) VALUES ('new');
 
 -- Nodes
@@ -347,7 +348,7 @@ CREATE TABLE conf_files (
     error_cmd text, -- Shell command to execute if any error occurs
     ignore_cmd_errors bool NOT NULL DEFAULT false, -- Install file anyway even if an error occurs
     always_update bool NOT NULL DEFAULT false -- Always attempt to install file even if unchanged
-);
+) WITH OIDS;
 
 CREATE TABLE conf_file_node (
     conf_file_id integer REFERENCES conf_files NOT NULL, -- Configuration file identifier
@@ -835,6 +836,34 @@ CREATE TABLE node_session (
     UNIQUE (session_id) -- Sessions are unique
 ) WITH OIDS;
 
+
+
+-------------------------------------------------------------------------------
+-- PCU Types
+------------------------------------------------------------------------------
+CREATE TABLE pcu_types (
+    pcu_type_id serial PRIMARY KEY,
+    model text NOT NULL ,               -- PCU model name
+    name text                           -- Full PCU model name
+) WITH OIDS;
+CREATE INDEX pcu_types_model_idx ON pcu_types (model);
+
+CREATE TABLE pcu_protocol_type (
+    pcu_protocol_type_id serial PRIMARY KEY,
+    pcu_type_id integer REFERENCES pcu_types NOT NULL,  -- PCU type identifier
+    port integer NOT NULL,                              -- PCU port
+    protocol text NOT NULL,                             -- Protocol
+    supported boolean NOT NULL DEFAULT True             -- Does PLC support
+) WITH OIDS;
+CREATE INDEX pcu_protocol_type_pcu_type_id ON pcu_protocol_type (pcu_type_id);
+
+
+CREATE OR REPLACE VIEW pcu_protocol_types AS
+SELECT pcu_type_id,
+array_accum(pcu_protocol_type_id) as pcu_protocol_type_ids
+FROM pcu_protocol_type
+GROUP BY pcu_type_id;
+
 --------------------------------------------------------------------------------
 -- Message templates
 --------------------------------------------------------------------------------
@@ -884,6 +913,13 @@ GROUP BY event_id;
 --------------------------------------------------------------------------------
 -- Useful views
 --------------------------------------------------------------------------------
+CREATE OR REPLACE VIEW view_pcu_types AS
+SELECT
+pcu_types.pcu_type_id,
+pcu_types.model,
+pcu_types.name,
+COALESCE((SELECT pcu_protocol_type_ids FROM pcu_protocol_types WHERE pcu_protocol_types.pcu_type_id = pcu_types.pcu_type_id), '{}') AS pcu_protocol_type_ids
+FROM pcu_types;
 
 CREATE OR REPLACE VIEW view_events AS
 SELECT