Changeset 1201


Ignore:
Timestamp:
12/27/12 18:26:32 (11 years ago)
Author:
nanardon
Message:

add tools to reset (bug #3)

Location:
trunk/LATMOS-Accounts
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/MANIFEST

    r1197 r1201  
    99bin/la-expired-reminder 
    1010bin/la-find-expired 
    11 bin/la-sql-freeip 
    1211bin/la-gen-passwd 
    1312bin/la-graph.pl 
     
    2423bin/la-sql-edit-form 
    2524bin/la-sql-exchange-ip 
     25bin/la-sql-freeip 
    2626bin/la-sql-list-request 
    2727bin/la-sql-loadatt 
     
    3232bin/la-sql-valid-request 
    3333bin/la-sync 
     34bin/la-sync-ctl 
    3435bin/la-sync-manager 
    3536bin/la-sync-process 
  • trunk/LATMOS-Accounts/Makefile.PL

    r1197 r1201  
    5050        bin/la-sync 
    5151        bin/la-sync-manager 
     52        bin/la-sync-ctl 
    5253        bin/la-warn-expire 
    5354        bin/la-sql-freeip 
  • trunk/LATMOS-Accounts/bin/la-sync

    r985 r1201  
    8383 
    8484if ($batch) { 
     85    warn "Using la-sync -b is deprecated, use la-sync-ctl -s instead\n"; 
    8586    exit ($LA->call_batch_sync ? 0 : 1); 
    8687} 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/SyncManager.pm

    r1200 r1201  
    190190} 
    191191 
     192=head2 reset_module_checkpoint($module) 
     193 
     194Reset the checkpoint for module C<$module> to force it to run at next 
     195synchronisation. 
     196 
     197=cut 
     198 
     199sub reset_module_checkpoint { 
     200    my ($self, $module) = @_; 
     201    if (!$self->ini->SectionExists($module)) { 
     202        la_log LA_ERR, "Cannot run inexistant module %s", $module; 
     203        return; 
     204    } 
     205 
     206    my $modtype = $self->ini->val($module, 'type', $module); 
     207    my $task = LATMOS::Accounts::Task->new( 
     208        $modtype, 
     209        config => $self->{config}, 
     210        name   => $module, 
     211        syncm  => $self, 
     212    ) 
     213        or do { 
     214        la_log(LA_ERR, 'Cannot load module %s', $modtype); 
     215        return; 
     216    }; 
     217    $task->init or do { 
     218        la_log LA_ERR, "Cannot init module %s", $_; 
     219        return; 
     220    }; 
     221 
     222    my $ini = $self->_load_state_ini or return; 
     223 
     224    $ini->delval($module, 'rev'); 
     225    $ini->newval($module, 'time', 0); 
     226    $ini->SetParameterComment( 
     227        $module, 'time', 
     228        'Reset to 0 the ' . scalar(localtime(time)), 
     229    ); 
     230 
     231    $task->reset_checkpoint; # Specific reset 
     232    $ini->RewriteConfig; 
     233} 
     234 
    1922351; 
    193236 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task.pm

    r1200 r1201  
    9090} 
    9191 
     92=head2 reset_checkpoint 
     93 
     94Reset the checkpoint to 0 to force the module to be run again 
     95 
     96=cut 
     97 
     98sub reset_checkpoint { 
     99    return 1; 
     100} 
     101 
    921021; 
    93103 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Buildnet.pm

    r1195 r1201  
    814814} 
    815815 
     816sub reset_checkpoint { 
     817    my ($self) = @_; 
     818    foreach my $zone ($self->_base->search_objects('netzone')) { 
     819        my $ozone = $self->_base->get_object('netzone', $zone) 
     820            or next; 
     821 
     822        $self->_bnet_state->newval($ozone->id, 'dbrev', 0); 
     823        la_log LA_DEBUG, "Zone checkpoint reset for %s", $ozone->id; 
     824        $self->_bnet_state->SetParameterComment( 
     825            $ozone->id, 'dbrev', 
     826            'Reset checkpoint the ' . scalar(localtime)); 
     827    } 
     828 
     829    $self->_write_state_file; 
     830} 
     831 
    8168321; 
    817833 
Note: See TracChangeset for help on using the changeset viewer.