Changeset 2496


Ignore:
Timestamp:
11/30/21 14:55:37 (3 years ago)
Author:
nanardon
Message:

Add default value for state_dir, factorize it

Location:
trunk/LATMOS-Accounts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/bin/la-sync-manager

    r2023 r2496  
    146146{ 
    147147    my $LA = LATMOS::Accounts->new($config, noacl => 1); 
    148     if ($LA->val('_default_', 'state_dir')) { 
    149         $pidfile = $LA->val('_default_', 'state_dir') . '/sync-manager.pid'; 
     148    if (my $dir = $LA->state_dir) { 
     149        $pidfile = $dir . '/sync-manager.pid'; 
    150150    } 
    151151    if (my $mail = $LA->val('_network_', 'maillog')) { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts.pm

    r2495 r2496  
    9696 
    9797    $self 
     98} 
     99 
     100=head2 state_dir 
     101 
     102Return state_dir for this instance 
     103 
     104=cut 
     105 
     106sub state_dir { 
     107    my ( $self ) = @_; 
     108 
     109    return $self->val( '_default_', 'state_dir', '/var/lib/latmos-accounts' ); 
    98110} 
    99111 
     
    289301    my $sync = LATMOS::Accounts::Synchro->new( 
    290302        $labfrom, [ @labto ], 
    291         state_dir => ($self->val('_default_', 'state_dir') || undef), 
     303        state_dir => $self->state_dir, 
    292304        %options, 
    293305        name => $name, 
     
    340352sub call_batch_sync { 
    341353    my ($self) = @_; 
    342     if (my $sd = $self->val('_default_', 'state_dir')) { 
     354    if (my $sd = $self->state_dir) { 
    343355        if (open(my $fh, '<', $sd . '/sync-manager.pid')) { 
    344356            my $pid = <$fh> || ''; 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/SyncManager.pm

    r2439 r2496  
    6161sub ini { $_[0]->{ini} } 
    6262 
    63 =head2 LA 
    64  
    65 Return a LATMOS::Accounts setup for SynchM 
    66  
    67 =cut 
    68  
    69 sub LA { 
    70     my ( $self ) = @_; 
    71  
    72     return LATMOS::Accounts->new($self->{config}, noacl => 1, loguser => '@SyncManager'); 
    73 } 
    74  
    7563=head2 dbrev 
    7664 
     
    8169sub dbrev { 
    8270    my ($self) = @_; 
    83     my $LA = $self->LA; 
     71    my $LA = LATMOS::Accounts->new($self->{config}, noacl => 1); 
    8472    my $base = $LA->base; 
    8573    return $base->current_rev; 
     
    8876sub _load_state_ini { 
    8977    my ($self) = @_; 
    90     my $la = $self->LA; 
    91  
    92     my $state_file =  $la->val('_default_', 'state_dir', '/'); 
    93     $state_file .= '/la-sync-manager.ini'; 
     78    my $la = LATMOS::Accounts->new($self->{config}, noacl => 1); 
     79 
     80    my $state_file =  $la->state_dir . '/la-sync-manager.ini'; 
    9481    la_log(LA_DEBUG, "Status file is %s", $state_file); 
    9582    if ($state_file && ! -w $state_file) { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Buildnet.pm

    r2439 r2496  
    121121    return $self->{_bnet_state} if ($self->{_bnet_state}); 
    122122    # where trace goes: 
    123     my $state_file =  $self->_la->val('_default_', 'state_dir', '/'); 
    124     $state_file .= '/buildnet_state.ini'; 
     123    my $state_file =  $self->state_dir . '/buildnet_state.ini'; 
    125124    la_log(LA_DEBUG, "Status file is %s", $state_file); 
    126125    if ($state_file && ! -w $state_file) { 
     
    159158        '/', 
    160159        $self->_la->val('_network_', 'output_dir', 
    161             ($self->_la->val('_default_', 'state_dir'), $ozone->get_attributes('type')) 
     160            ($self->_la->state_dir, $ozone->get_attributes('type')) 
    162161        ) 
    163162    ); 
Note: See TracChangeset for help on using the changeset viewer.