Rex-JobControl

 view release on metacpan or  search on metacpan

lib/Rex/JobControl/Helper/Project/Job.pm  view on Meta::CPAN

  my $execute_path = "$job_path/execute/$job_id";

  my $logfile = "$execute_path/output.log";

  if ( !-f $logfile ) {
    $self->project->app->log->error(
      "This job doesn't have an output.log file.");
    return "No output.log found.";
  }

  my @loglines = eval { local ( @ARGV, $/ ) = ($logfile); <>; };

  return \@loglines;
}

sub create {
  my ( $self, %data ) = @_;

  my $job_path = File::Spec->catdir( $self->project->project_path,
    "jobs", $self->{directory} );

lib/Rex/JobControl/Helper/Project/Job.pm  view on Meta::CPAN


    # execute strategt = node
    # execute all steps on a server, than continue

  SERVER: for my $srv (@server) {

    STEP: for my $s ( @{ $self->steps } ) {

        if ( -f $self->project->project_path . "/next_server.txt" ) {
          $srv = eval {
            local ( @ARGV, $/ ) =
              ( $self->project->project_path . "/next_server.txt" );
            <>;
          };
          chomp $srv;
          unlink $self->project->project_path . "/next_server.txt";
        }

        my ( $rexfile_name, $task ) = split( /\//, $s );
        $rexfile_name = md5_hex($rexfile_name);
        my $rexfile = $self->project->get_rexfile($rexfile_name);

lib/Rex/JobControl/Mojolicious/Command/jobcontrol.pm  view on Meta::CPAN

  }

  if ( $command eq "deluser" ) {

    my $user;

    GetOptionsFromArray \@args, 'u|user=s' => sub { $user = $_[1] };

    my @lines =
      grep { !m/^$user:/ }
      eval { local (@ARGV) = ( $self->app->config->{auth}->{passwd} ); <>; };

    open( my $fh, ">", $self->app->config->{auth}->{passwd} ) or die($!);
    print $fh join( "\n", @lines );
    close($fh);
  }

  if ( $command eq "listuser" ) {
    my @lines =
      eval { local (@ARGV) = ( $self->app->config->{auth}->{passwd} ); <>; };
    chomp @lines;

    for my $l (@lines) {
      my ( $user, $pass ) = split( /:/, $l );
      print "> $user\n";
    }
  }

}

lib/Rex/JobControl/Mojolicious/Plugin/User.pm  view on Meta::CPAN

use base 'Mojolicious::Plugin';

sub register {
  my ( $plugin, $app ) = @_;

  $app->helper(
    get_user => sub {
      my ( $self, $uid ) = @_;

      my @lines =
        eval { local (@ARGV) = ( $self->app->config->{auth}->{passwd} ); <>; };
      chomp @lines;

      for my $l (@lines) {
        my ( $name, $pass ) = split( /:/, $l );
        if ( $name eq $uid ) {
          return { name => $name, password => $pass };
        }
      }

      return undef;



( run in 0.536 second using v1.01-cache-2.11-cpan-49f99fa48dc )