Changeset 14

Show
Ignore:
Timestamp:
08/25/09 15:27:27 (5 years ago)
Author:
robert
Message:

add ip address columns for storage nodes, modify node setting function to use ip for updates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ddl/cornea.sql

    r13 r14  
    9393    total_storage bigint NOT NULL, 
    9494    used_storage bigint NOT NULL, 
     95    ip text NOT NULL,  
    9596    fqdn text NOT NULL, 
    9697    location text NOT NULL, 
     
    133134-- 
    134135 
    135 CREATE FUNCTION set_storage_node(in_state text, in_total_storage bigint, in_used_storage bigint, in_location text, in_fqdn text) RETURNS void 
     136CREATE OR REPLACE FUNCTION set_storage_node(in_state text, in_total_storage bigint, in_used_storage bigint, in_location text, in_fqdn text, in_ip text) RETURNS void 
    136137    LANGUAGE plpgsql 
    137138    AS $$ 
    138139DECLARE 
    139         v_storage_node_id storage_node%storage_node_id
     140        v_storage_node_id storage_node.storage_node_id%type
    140141BEGIN 
    141     SELECT storage_node_id FROM storage_node WHERE fqdn=$5 INTO v_storage_node_id; 
     142    SELECT storage_node_id FROM storage_node WHERE ip=$6 INTO v_storage_node_id; 
    142143    IF NOT FOUND THEN 
    143        insert into storage_node (state, total_storage , used_storage ,fqdn, location) values  
    144                                         ($1, $2, $3, $5, $4);    
     144       insert into storage_node (state, total_storage, used_storage, fqdn, location, ip) values  
     145                                        ($1, $2, $3, $5, $4, $6);    
    145146    ELSE 
    146        update storage_node set state=$1, total_storage=$2, used_storage=$3, 
    147                                        modified_at = current_timestamp, 
    148                                        location= ( CASE WHEN $4 IS NULL THEN location ELSE $4 END) 
     147       update storage_node set state=$1, total_storage=$2, used_storage=$3,  
     148                                       modified_at = current_timestamp,  
     149                                       location= ( CASE WHEN $4 IS NULL THEN location ELSE $4 END), 
     150                                       fqdn= ( CASE WHEN $5 IS NULL THEN fqdn ELSE $4 END) 
    149151       where storage_node_id = v_storage_node_id; 
    150152    END IF; 
     
    246248 
    247249ALTER TABLE ONLY storage_node 
     250    ADD CONSTRAINT storage_node_ip_uidx UNIQUE (ip); 
     251 
     252 
     253-- 
     254-- Name: storage_node_fqdn_uidx; Type: CONSTRAINT; Schema: cornea; Owner: cornea; Tablespace:  
     255-- 
     256 
     257ALTER TABLE ONLY storage_node 
    248258    ADD CONSTRAINT storage_node_fqdn_uidx UNIQUE (fqdn); 
    249259