Changeset 920 for LATMOS-Accounts


Ignore:
Timestamp:
04/17/12 13:41:37 (12 years ago)
Author:
nanardon
Message:
  • add 'user' attribute to nethost to make difference between user and admin
  • really commit change done by la-sql-upgrade
Location:
LATMOS-Accounts
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/Changes

    r863 r920  
    11Revision history for Perl extension LATMOS::Accounts. 
     2 
     33.0.1 
     4    - add user attributes to nethost to store poeple using the computer if it is 
     5      not the owner (make difference between user and admin). 
    26 
    373.0.0 
  • LATMOS-Accounts/bin/la-sql-upgrade.in

    r914 r920  
    2424    'b|base=s'       => \my $base, 
    2525    'a|attributes=s' => \my $attributes_file, 
     26    'no-commit'      => \my $nocommit, 
     27    'v|verbose'      => \my $verbose, 
    2628) or pod2usage(); 
    2729 
     
    4446=cut 
    4547 
     48$| = 1; # autoflush 
     49 
    4650my $LA = LATMOS::Accounts->new($config, noacl => 1); 
    4751my $labase = $LA->base($base); 
     
    6064        q{DROP TRIGGER IF EXISTS check_zone_name_unity_tg ON netzone}, 
    6165        q{DROP FUNCTION IF EXISTS check_zone_name_unity()}, 
    62         q{ALTER TABLE nethost_attributes_ips DROP CONSTRAINT nethost_is_single_ip} 
     66        q{ALTER TABLE nethost_attributes_ips DROP CONSTRAINT 
     67          nethost_is_single_ip}, 
    6368        q{INSERT INTO settings(varname, val) VALUES ('schema_version', 3)}, 
     69        ], 
     70    }, 
     71    { 
     72        ver => 4, 
     73        sql => [ 
     74            q{ 
     75            CREATE OR REPLACE FUNCTION nethost_sort_fields() 
     76              RETURNS trigger AS 
     77              $BODY$BEGIN 
     78 
     79              IF (TG_OP='INSERT') then 
     80              IF (new.attr='ip') THEN 
     81              insert into nethost_attributes_ips VALUES (new.*); 
     82              RETURN NULL; 
     83              END IF; 
     84 
     85              IF (new.attr='macaddr') THEN 
     86              insert into nethost_attributes_macs VALUES (new.*); 
     87              RETURN NULL; 
     88              END IF; 
     89 
     90              IF (new.attr='owner') THEN 
     91              insert into nethost_attributes_users VALUES (new.*); 
     92              RETURN NULL; 
     93              END IF; 
     94 
     95              IF (new.attr='user') THEN 
     96              insert into nethost_attributes_users VALUES (new.*); 
     97              RETURN NULL; 
     98              END IF; 
     99              end if; 
     100 
     101 
     102              if (TG_OP='DELETE') THEN 
     103              RETURN old; 
     104              else 
     105              RETURN new; 
     106              end if; 
     107              END;$BODY$ 
     108            LANGUAGE plpgsql VOLATILE 
     109            COST 100; 
     110            }, 
    64111        ], 
    65112    }, 
     
    78125            my $sqlv = $sql; 
    79126            $sqlv =~ s/^/  /mg; 
    80             warn '  >' . $sqlv . "\n"; 
     127            if ($verbose) { 
     128                warn '  >' . $sqlv . "\n"; 
     129            } else { 
     130                print 'x'; 
     131            } 
    81132        } 
    82         $dbi->do($sql) or die "Erreur :\\"; 
     133        $dbi->do($sql) or die "Erreur :\\" . $dbi->errstr . "\n"; 
    83134    } 
    84     print '  >  Updating schema_version to ' . $maj->{ver} . "\n"; 
     135 
     136    print "\n"; 
     137 
     138    print 'Updating schema_version to ' . $maj->{ver} . "\n"; 
     139 
    85140    $dbi->do( 
    86141        'UPDATE settings SET val = ? where varname = ?', 
     
    88143        $maj->{ver}, 'schema_version' 
    89144    ); 
     145    print "Done\n\n"; 
    90146 
    91147} 
     
    112168}; 
    113169 
     170if ($nocommit) { 
     171    $dbi->rollback; 
     172} else { 
     173    $dbi->commit; 
     174} 
    114175print "Process terminated successfully\n"; 
    115 $dbi->rollback; 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm

    r882 r920  
    1515our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; 
    1616 
    17 my $SCHEMA_VERSION = 3; 
     17my $SCHEMA_VERSION = 4; 
    1818 
    1919=head1 NAME 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r861 r920  
    8282            }, 
    8383            owner   => {  
     84                reference => 'user', 
     85                delayed => 1, 
     86            }, 
     87            user    => { 
    8488                reference => 'user', 
    8589                delayed => 1, 
  • LATMOS-Accounts/sqldata/attributes.csv

    r861 r920  
    4040"nethost","description","" 
    4141"nethost","owner","" 
     42"nethost","user","" 
    4243"nethost","ip","" 
    4344"nethost","macaddr","" 
Note: See TracChangeset for help on using the changeset viewer.