⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myproxy-replicate

📁 代理服务器源代码 供大家学习使用,希望大家喜欢
💻
📖 第 1 页 / 共 2 页
字号:
    for my $s (@{$slaves})    {      print "OPTIONS: $myproxy_store\n$options $s\n\n" if( $dbglvl > 2 );      ($exitstatus, $output) = runcmd( "$myproxy_store $options $s" );      if( $exitstatus != 0 )      {        $ret = 1;      }      print STDERR "STATUS: $exitstatus\n $output\n" if( $dbglvl > 0 );    }    $options = undef;  }  return $ret;}#### parse_datafile( repository, datafile )#### Read the data file and use the information in it to create the option## list for replication. ##sub parse_datafile{  my $rep   = shift;  my $fname = shift;  my $options = undef;  open( FN, "$rep/$fname" ) or return undef;  for my $value (<FN>)  {    my( $tag, $val ) = split( /\=/, $value );    # OWNER creds->owner_name    # where does this come from?  It seems like it is something that is passed    # but not flaged.  If this is true, how do we get it to replicate?    if( $value =~ /OWNER=(.*)/ )    {    }    # LIFETIME -c    elsif( $value =~ /LIFETIME=(.*)/ )    {      $options .= "-t " . $1 / $SECONDS_PER_HOUR . " ";    }    # NAME -k creds->credname    elsif( $value =~ /NAME=(.*)/ )    {      $options .= "-k $1 ";    }    # DESCRIPTION -K creds->creddesc    elsif( $value =~ /DESCRIPTION=(.*)/ )    {      $options .= "-K $1 ";    }    # RETRIEVERS -r creds->retrievers    # what about anonymous retrievers?    elsif( $value =~ /RETRIEVERS=(.*)/ )    {      $options .= "-x -r \"$1\" ";    }    # RENEWERS -R creds->renewers    # what about anonymous renewers?    elsif( $value =~ /RENEWERS=(.*)/ )    {      $options .= "-x -R \"$1\" ";    }    # KEYRETRIEVERS -E creds->keyretrieve    elsif( $value =~ /KEYRETRIEVERS=(.*)/ )    {      $options .= "-x -E \"$1\" ";    }    # END_OPTIONS    elsif( $tag eq "END_OPTIONS" )    {    }  }  close FN;  # Find out what name should be attached to the file when it is stored by  # the server.  my ($name, $ext) = split /\./, $fname;  my ($uname, $oname ) = split /-/, $name;  $options .= "-l $uname ";  return $options;}#### missing_files( repository, files )#### Look at the last snapshot of the repository on the master.  Compare it## to the current list of files in the repository.  If any are missing## from the repository, they must have been deleted, so we need to delete## them. ##sub missing_files{  my $rep   = shift;  my @files = @_;  my @delfiles;  open FD, "$rep/$MYPROXY_DELETED_FILE" or return undef;  my @fd = <FD>;  for my $r (@fd)  {    my $fnd = 0;    chomp($r);    for my $f (@files)    {      chomp($f);      $fnd = 1 if( $f eq $r );    }    if( !$fnd )    {      push @delfiles, $r;    }  }      return \@delfiles}#### delete_files( repostiroy, files, slaves )#### Using the list of files that are to be deleted, send a destroy command## to each of the listed slaves.##sub delete_files{  my $rep    = shift;  my $files  = shift;  my $slaves = shift;  my ($exitstatus, $output);  my $ret = 0;  for my $f (@{$files->{'del'}})  {    my ($name, $ext) = split /\./, $f;    my ($uname, $oname ) = split /-/, $name;    my $options = "-l $uname ";    $options .= "-k $oname " if( length($oname) > 0 );    for my $s (@{$slaves})    {      print "OPTIONS: myproxy_destroy\n$options $s -v\n\n" if( $dbglvl > 2 );      ($exitstatus, $output) = runcmd( "$myproxy_destroy $options $s -v" );      if( ($exitstatus != 0) && !($output =~ /No such file or directory/) )      {print "Bad delete\n";        $ret = 1;        # For now do nothing about this.  myproxy-server neeeds to be modified        # to return more error information.  There is no way to tell why this        # failed.        #        # There are several problems with the current retry scheme.  If we do        # not update the date and directory snap shot.  The next time around        # we are going to have problems.  Resending myproxy-destroy commands        # to servers where the cred has already been destroied returns an        # error message.  This will just cause an infinate cycle of failures.        #        # If we log the deletes and then rerun them we can run into problems        # with missing creds.  If we have a case where a cred is stored but        # the store fails and then before the next replicate, the user         # destories that cred we will have a problem with the destory.  The        # server will have no idea what we are trying to destroy and return        # an error.  Again, we end up in an infinate cycle of destories.        #        # If we log both the stores and destories we still have problems.  Is        # we do a store and it fails and we log it, then the user destories        # the cred before the next replicate.  We try and do a store on a         # cred that is not there.  This causes an error.  Then the destory        # runs and we end up with another error.  Now we have two infinate        # cycles going.        #        # We need a better solution!  I still like the idea of just taring        # the directory and coping it over to each slave.        #      }      print STDERR "STATUS: $exitstatus\n $output\n" if( $dbglvl > 0 );    }    $options = undef;  }  return $ret;}#### runcmd( command )#### Run a MyProxy command and capture the exit value and the output##sub runcmd {  my ($command) = @_;  my $pid = open3(*Writer, *Reader, 0, "exec $command") ||         die "failed to run $command";  close(Writer);  my @output = <Reader>;  close(Reader);  waitpid($pid, 0);  my $exitstatus = $?;  my $output = join('', @output);  return ($exitstatus, $output);}sub write_timestamp{  my $rep = shift;  open FD, ">$rep/$MYPROXY_REPLICATE_FILE";  print FD $new_rep_time;  close FD;}sub write_delete_file{  my $rep = shift;  open FD, ">$rep/$MYPROXY_DELETED_FILE" or die      print "ERROR: $rep/$MYPROXY_DELETED_FILE could not be opened!\n";  for (@file_list)  {    print FD "$_\n";  }  close FD;}#### findish_up( repository )#### Update the .myproxy_replicate with the current timesamp.  Update## .myproxy_delete with the current snapshot of the repository.##sub finish_up{  my $rep = shift;  open FD, ">$rep/$MYPROXY_REPLICATE_FILE";  print FD $new_rep_time;  close FD;  open FD, ">$rep/$MYPROXY_DELETED_FILE" or die      print "ERROR: $rep/$MYPROXY_DELETED_FILE could not be opened!\n";  for (@file_list)  {    print FD "$_\n";  }  close FD;}__END__=head1 NAMEB<myproxy-replicate> - Stores data from the MyProxy master repository to allthe slave servers.=head1 SYNOPSISB<myproxy-replicate> [options] ...  Options:     [-verbose|-v]                      Print copious output     [-help|-h]                         Print usage     [-storage|-r]=<path to repository> Directory of the MyProxy repository.     [-config|-c]=<path to config file> Directory of the MyProxy Server                                        configuration file.     [-debug|-d]                        Run in debug mode =head1 DESCRIPTIONB<myproxy-replicate> Replicates data. This utility will read a specified MyProxy repository and send any new orchanged data to a slave MyProxy server.  The slave servers are specified in the B<myproxy-server.config(5)> file.  This utility will need to run at some specified interval in order to keepthe slave repositories semi current with the Master repository.  This canbest be accomplished using cron, or some similar mechanism.=head1 OPTIONS=over 8=item B<-v>, B<-verbose>Enables verbose debugging output to the terminal.=item B<-h>, B<-help>Displays command usage text and exits.=item B<-u>, B<-usage>Displays command usage text and exits.=item B<-r> I<dir>, B<-storage> I<dir>Specifies the location of the credential storage directory.The directory must be accessible only by the user running theB<myproxy-server> process for security reasons.  Default: /var/myproxy or $GLOBUS_LOCATION/var/myproxyA=item B<-c> I<file>, B<-config> I<file>Specifies the location of the myproxy-server configuration file.Default: /etc/myproxy-server.config or          $GLOBUS_LOCA-TION/etc/myproxy-server.config=back=head1 SEE ALSOmyproxy-init(1) myproxy-store(1) myproxy-retrieve(1) myproxy-delegate(1)myproxy-server(8) myproxy-server.config(5)=head1 AUTHOR=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -