Changeset 42444 for trunk/tools
- Timestamp:
- Apr 6, 2023, 6:00:06 PM (3 years ago)
- Location:
- trunk/tools/eam/rawfix.20230221/src
- Files:
-
- 12 deleted
- 5 edited
-
check_chip_locations.pl (modified) (5 diffs)
-
check_chip_locations.v0.pl (deleted)
-
check_md5s_dateobs.pl (modified) (4 diffs)
-
check_night_status.pl (modified) (5 diffs)
-
fix_chip_locations.pl (modified) (11 diffs)
-
fix_chip_locations_stage2.pl (deleted)
-
fix_chip_locations_stage3.pl (deleted)
-
get_md5s_dateobs.pl (deleted)
-
get_md5s_instances.pl (modified) (7 diffs)
-
get_md5s_instances_stage2.pl (deleted)
-
rawfix.ckchip_s3.pt (deleted)
-
rawfix.fixchip_s2.pt (deleted)
-
rawfix.fixchip_s3.pt (deleted)
-
rawfix.md5chk_s2.pt (deleted)
-
rawfix.md5sum_s2.pt (deleted)
-
rawfix.rsync_s1.pt (deleted)
-
rawfix.rsync_s2.pt (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rawfix.20230221/src/check_chip_locations.pl
r42441 r42444 13 13 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 14 14 15 # USAGE: check_chip_locations.pl --dateobs (night) --chiplist (file) --stage ( v0,v1,etc)16 # USAGE: check_chip_locations.pl --dateobs 2010/05/01 --chiplist gpc1.chips.txt --stage v015 # USAGE: check_chip_locations.pl --dateobs (night) --chiplist (file) --stage (0,1,etc) 16 # USAGE: check_chip_locations.pl --dateobs 2010/05/01 --chiplist gpc1.chips.txt --stage 0 17 17 18 18 my ($fulldate, $dateword, $chiplist, $stage, $topdir) = &parse_cmdopts; … … 31 31 # output files: 32 32 # instance lists by host: YYYYMMDD/HOSTNAME.inst.STAGE.txt 33 # chip states by chip: YYYYMMDD/CHIPNAME.uris. txt33 # chip states by chip: YYYYMMDD/CHIPNAME.uris.STAGE.txt 34 34 35 35 foreach my $chip_id (@chip_ids) { 36 36 37 37 my $outfh; 38 open ($outfh, ">$topdir/$dateword/$chip_id.uris. txt");38 open ($outfh, ">$topdir/$dateword/$chip_id.uris.$stage.txt"); 39 39 40 40 # get the list of chip neb paths for one chip … … 182 182 my $sql_chip_instances = "SELECT uri, host, available, xattr, cab_id from instance join storage_object using (so_id) join volume using (vol_id) where ext_id = '$ext_id'"; 183 183 my $rowref = $neb_dbh->selectall_arrayref( $sql_chip_instances ); 184 184 185 185 return ($rowref, $ext_id); 186 186 } … … 338 338 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 339 339 340 # check that stage is an integer 341 unless (&is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 342 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 343 340 344 # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?) 341 345 … … 405 409 } 406 410 407 411 sub is_integer { 412 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 413 } 414 408 415 # example of using the return value of arrayref: 409 416 -
trunk/tools/eam/rawfix.20230221/src/check_md5s_dateobs.pl
r42441 r42444 20 20 21 21 my $Nfail = 0; 22 my %failchips; 23 my %goodchips; 22 24 23 25 foreach my $instfile (@instlist) { … … 80 82 81 83 if ($md5tru ne $md5obs) { 82 print STDOUT "FAIL: $inst $state $md5tru $md5obs\n";83 $Nfail ++;84 &save_failure ($inst); 85 if ($DEBUG > 2) { print STDOUT "FAIL: $inst $state $md5tru $md5obs\n"; } 84 86 } else { 85 if ($DEBUG > 2) { 86 print STDOUT "$inst $state $md5tru = $md5obs\n"; 87 } 87 &save_goodchip ($inst); 88 if ($DEBUG > 2) { print STDOUT "$inst $state $md5tru = $md5obs\n"; } 88 89 } 89 90 } 90 91 } 91 92 93 # save both good and fail chip lists 94 open (OUTFILE, ">$topdir/$dateword/goodchips.$stage.txt"); 95 my @goodchipURIs = keys %goodchips; 96 foreach my $uri (@goodchipURIs) { 97 print OUTFILE "$uri\n"; 98 } 99 close (OUTFILE); 100 101 open (OUTFILE, ">$topdir/$dateword/failchips.$stage.txt"); 102 my @failchipURIs = keys %failchips; 103 foreach my $uri (@failchipURIs) { 104 print OUTFILE "$uri\n"; 105 } 106 close (OUTFILE); 107 108 109 ## we only report an error if we could not find the md5sum files or if the inst and md5s 110 ## files are inconsistent. In that case, we cannot check the md5s for all instances 111 ## if the md5sum is wrong for a chip, mark that chip and save it. It will be skipped in fix_chip_locations 92 112 if ($Nfail) { 93 113 print STDOUT "ERROR: $Nfail errors\n"; … … 105 125 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 106 126 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 107 pod2usage( -msg => "Define the stage (v0, v1, etc) with --stage", -exitval => 2) unless defined $stage; 127 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 128 129 # check that stage is an integer 130 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 131 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 108 132 109 133 # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?) … … 126 150 return $status; 127 151 } 152 153 sub neb_reverse { 154 155 my (@neb_path) = split /\//, $_[0]; 156 my $neb_key = $neb_path[-1]; 157 158 # Remove ins_id 159 $neb_key =~ s/^\d+\.//; 160 161 # Convert colons to slashes. 162 $neb_key =~ s%:%/%g; 163 164 # strip ending .fz added for compressed .fits images 165 $neb_key =~ s%.fz$%%; 166 return $neb_key; 167 } 168 169 sub save_failure { 170 my $nebfile = &neb_reverse($_[0]); 171 if (defined $failchips{$nebfile}) { 172 $failchips{$nebfile} ++; 173 } else { 174 $failchips{$nebfile} = 1; 175 } 176 return; 177 } 178 179 sub save_goodchip { 180 my $nebfile = &neb_reverse($_[0]); 181 if (defined $goodchips{$nebfile}) { 182 $goodchips{$nebfile} ++; 183 } else { 184 $goodchips{$nebfile} = 1; 185 } 186 return; 187 } 188 189 sub is_integer { 190 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 191 } -
trunk/tools/eam/rawfix.20230221/src/check_night_status.pl
r42415 r42444 11 11 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 12 12 13 # USAGE: check_night_status.pl --dateobs (night) --chiplist (file) 13 # USAGE: check_night_status.pl --dateobs (night) --chiplist (file) --stage (0,1,etc) 14 14 15 15 # we need to select targets for ITC copies of files currently only at ATRC: … … 17 17 # for each chip, target a single host? 18 18 19 my ($fulldate, $dateword, $chiplist ) = &parse_cmdopts;19 my ($fulldate, $dateword, $chiplist, $stage) = &parse_cmdopts; 20 20 21 21 # read the list of chip_ids: … … 36 36 foreach my $chip_id (@chip_ids) { 37 37 38 my $urifile = "$dateword/$chip_id.uris. txt";38 my $urifile = "$dateword/$chip_id.uris.$stage.txt"; 39 39 open (FILE, "$urifile"); 40 40 my @lines = <FILE>; … … 110 110 sub parse_cmdopts { 111 111 112 my ($dateobs, $chiplist );113 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist ) || pod2usage(2);112 my ($dateobs, $chiplist, $stage); 113 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist, 'stage=s' => \$stage) || pod2usage(2); 114 114 115 115 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 116 116 pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist; 117 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 118 119 # check that stage is an integer 120 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 121 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 122 117 123 118 124 # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?) … … 127 133 my $dateword = sprintf ("%4d%02d%02d", $date_year, $date_month, $date_day); 128 134 129 return ($fulldate, $dateword, $chiplist );135 return ($fulldate, $dateword, $chiplist, $stage); 130 136 } 131 137 138 139 sub is_integer { 140 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 141 } 142 -
trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl
r42441 r42444 12 12 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 13 13 14 # USAGE: fix_chip_locations.pl --dateobs (night) --chiplist (file) --stage ( v0,v1,etc)14 # USAGE: fix_chip_locations.pl --dateobs (night) --chiplist (file) --stage (0,1,etc) 15 15 16 16 # we need to select targets for ITC copies of files currently only at ATRC: … … 25 25 26 26 # choose ITC machines on which to place backup copies: 27 my @volarray = &get_neb_volumes; 27 my @vol_copy = &get_neb_volumes_copy; # array of neb hosts to copy data to at ITC 28 my %vol_good = &get_neb_volumes_good; # hash of valid neb hosts 28 29 my $volnum = 0; 29 30 30 31 my $Ngood = 0; 32 my $Ndead = 0; 31 33 my $Ngone = 0; 32 my $Ndead = 0;33 34 my $Nsing = 0; 34 35 my $Ndups = 0; … … 40 41 my $Ncul3 = 0; 41 42 43 # load the lists of good and fail chips 44 my $prev = $stage - 1; 45 my $goodfile = "$topdir/$dateword/goodchips.$prev.txt"; 46 my %goodchips; 47 if (-e $goodfile) { 48 open (GOODFILE, $goodfile); 49 my @lines = <GOODFILE>; 50 close (GOODFILE); 51 52 foreach my $line (@lines) { 53 chomp $line; 54 $goodchips{$line} = 1; 55 } 56 } 57 my $failfile = "$topdir/$dateword/failchips.$prev.txt"; 58 my %failchips; 59 if (-e $failfile) { 60 open (FAILFILE, $failfile); 61 my @lines = <FAILFILE>; 62 close (FAILFILE); 63 64 foreach my $line (@lines) { 65 chomp $line; 66 $failchips{$line} = 1; 67 } 68 } 69 42 70 foreach my $chip_id (@chip_ids) { 43 71 44 my $urifile = "$topdir/$dateword/$chip_id.uris.txt"; 45 open (FILE, $urifile); 46 my @lines = <FILE>; 47 close (FILE); 72 # read from chip_id file, update to next stage number 73 my $urifile = "$topdir/$dateword/$chip_id.uris.$stage.txt"; 74 if (! -e $urifile) { die "missing file $urifile\n"; } 75 open (URIFILE, $urifile); 76 my @lines = <URIFILE>; 77 close (URIFILE); 48 78 49 79 foreach my $line (@lines) { … … 61 91 my $md5sum = $words[3]; 62 92 93 my $haveMD5 = 0; 94 my $goodMD5 = 0; 95 if ($goodchips{$ext_id}) { $haveMD5 = 1; $goodMD5 = 1; } 96 if ($failchips{$ext_id}) { $haveMD5 = 1; } 97 98 99 # nothing to be done, or need be done for these: 63 100 if ($state eq "GOOD:") { $Ngood++; next; } 64 101 if ($state eq "DEAD:") { $Ndead++; next; } … … 66 103 67 104 # one copy at ITC: neb-replicate will create a copy at ATRC 105 # does not depend on existence of MD5sum 68 106 if ($state eq "SING:") { 69 107 my $status = &vsystem ("neb-replicate $ext_id"); … … 79 117 80 118 # one copy at ATRC: neb-replicate will create a copy at ITC iff we supply the target volume 119 # does not depend on existence of MD5sum 81 120 if ($state eq "SBCK:") { 82 my $tgtvol = $vol array[$volnum];121 my $tgtvol = $vol_copy[$volnum]; 83 122 my $status = &vsystem ("neb-replicate --volume $tgtvol $ext_id"); 84 123 if ($status) { print STDERR "FAIL SBCK: neb-replicate : $ext_id on $tgtvol\n"; next; } … … 92 131 } 93 132 94 # these are done in stage 2: 95 if ($state eq "DUPS:") { $Ndups++; next; } 96 if ($state eq "XBCK:") { $Nxbck++; next; } 97 98 # these are done in stage 3: 99 if ($state eq "CUL1:") { $Ncul1++; next; } 100 if ($state eq "CUL2:") { $Ncul2++; next; } 101 if ($state eq "CUL3:") { $Ncul3++; next; } 133 # multiple copies @ ITC, but none at ATRC. use neb-replicate to make copies 134 # skip if we do not know the state of the md5sum 135 if ($state eq "DUPS:") { 136 if ($haveMD5 && $goodMD5) { 137 my $status = &vsystem ("neb-replicate $ext_id"); 138 if ($status) { print STDERR "FAIL DUPS: neb-replicate : $ext_id\n"; next; } 139 my ($newfile, $newhost, $newxattr) = &get_new_instance ($ext_id); 140 unless ($newxattr == 1) { die "new instance is not at ATRC? $ext_id : $newfile : $newhost : $newxattr\n"; } 141 open (OUTFILE, ">>$topdir/$dateword/$newhost.inst.$stage.txt"); 142 print OUTFILE "$newfile $datast $md5sum\n"; 143 close (OUTFILE); 144 } 145 $Ndups++; 146 next; 147 } 148 149 # multiple copies @ ATRC, but none @ ITC: neb-replicate will create a copy at ITC iff we supply the target volume 150 # skip if we do not know the state of the md5sum 151 if ($state eq "XBCK:") { 152 if ($haveMD5 && $goodMD5) { 153 my $tgtvol = $vol_copy[$volnum]; 154 my $status = &vsystem ("neb-replicate --volume $tgtvol $ext_id"); 155 if ($status) { print STDERR "FAIL XBCK: neb-replicate : $ext_id on $tgtvol\n"; next; } 156 my ($newfile, $newhost, $newxattr) = &get_new_instance ($ext_id); 157 unless ($newxattr == 0) { die "new instance is not at ITC? $ext_id : $newfile : $newhost : $newxattr\n"; } 158 open (OUTFILE, ">>$topdir/$dateword/$newhost.inst.$stage.txt"); 159 print OUTFILE "$newfile $datast $md5sum\n"; 160 close (OUTFILE); 161 } 162 $Nxbck++; 163 next; 164 } 165 166 # one copy at ITC: neb-replicate will create a copy at ATRC 167 # skip if we do not know the state of the md5sum 168 if (($state eq "CUL1:") || ($state eq "CUL2:") || ($state eq "CUL3:")) { 169 170 if ($haveMD5 && $goodMD5) { 171 # get info for all instances of this chip 172 # returns a reference to the array of instance data 173 # also strips neb://hostname.volnum/ from nebname and returns as ext_id 174 my ($inforows, $ext_id) = &get_chip_instances ($ext_id); 175 176 my ($main_keep, $back_keep, $cull_list_r) = &check_instance_xattr ($inforows, $ext_id); 177 178 if ($main_keep eq "") { print STDERR "FAIL $state: missing ITC copy for $ext_id\n"; next; } 179 if ($back_keep eq "") { print STDERR "FAIL $state: missing ATRC copy for $ext_id\n"; next; } 180 181 my $NcullTotal = @$cull_list_r; 182 foreach my $instance (@$cull_list_r) { 183 my ($volname) = $instance =~ m|file:///data/([0-9a-zA-Z]*\.[0-9])/\S*|; 184 unless (defined $vol_good{$volname}) { die "ERROR: invalid volume name $volname\n"; } 185 # print STDERR "neb-cull $state: $ext_id $volname ($main_keep $back_keep)\n"; 186 my $status = &vsystem ("neb-cull --volume $volname $ext_id"); 187 if ($status) { print STDERR "FAIL CULL: neb-replicate : $ext_id\n"; next; } 188 } 189 # print STDERR "Ncull Total $NcullTotal\n"; 190 } 191 192 # these are done in stage 3: 193 if ($state eq "CUL1:") { $Ncul1++; next; } 194 if ($state eq "CUL2:") { $Ncul2++; next; } 195 if ($state eq "CUL3:") { $Ncul3++; next; } 196 } 102 197 } 103 198 $volnum ++; … … 136 231 } 137 232 138 # get the list of chip neb paths for one chip 139 sub get_neb_volumes { 233 sub get_chip_instances { 234 235 my $ext_id = $_[0]; 236 237 my $sql_chip_instances = "SELECT uri, host, available, xattr, cab_id from instance join storage_object using (so_id) join volume using (vol_id) where ext_id = '$ext_id'"; 238 my $rowref = $neb_dbh->selectall_arrayref( $sql_chip_instances ); 239 240 return ($rowref, $ext_id); 241 } 242 243 # select 1 instance with xattr = 0, 1 with xattr = 1. 244 # the rest should be culled. 245 246 sub check_instance_xattr { 247 248 my $rowref = $_[0]; 249 my $ext_id = $_[1]; 250 251 my @inforows = @$rowref; 252 my $Nrows = @inforows; 253 254 if ($DEBUG > 5) { print "found $Nrows instances\n"; } 255 256 # get user_copies for this storage_object 257 my $main_keep = ""; 258 my $back_keep = ""; 259 my @cull_list = (); 260 261 # xattr = 0 means instance @ ITC (main) 262 # xattr = 1 means instance @ ATRC (back) 263 for (my $j = 0; $j < $Nrows; $j ++) { 264 my $valref = $inforows[$j]; 265 my @values = @$valref; 266 267 # the number of returned values per row must match the query above (in get_chip_instances) 268 my $Nvalue = @values; 269 if ($Nvalue != 5) { 270 print STDERR "ERROR : INVALID DB XATTR RESPONSE: $ext_id\n"; 271 next; 272 } 273 274 my $instance = $values[0]; 275 my $hostname = $values[1]; 276 my $xattr = $values[3]; 277 278 if (($xattr == 0) && ($main_keep eq "")) { $main_keep = $instance; next; } 279 if (($xattr == 1) && ($back_keep eq "")) { $back_keep = $instance; next; } 280 281 # if we make it here, we already have an instance at this location 282 push (@cull_list, $instance); 283 } 284 return ($main_keep, $back_keep, \@cull_list); 285 } 286 287 # get the list of neb hosts to copy data to at ITC 288 sub get_neb_volumes_copy { 140 289 141 290 my @volarray; … … 164 313 } 165 314 315 # get the list of valid neb hosts (ITC or ATRC) 316 sub get_neb_volumes_good { 317 318 my %volarray; 319 320 my $sql_neb_volumes = "select name from mountedvol where ((xattr = 0) or (xattr = 1))"; 321 if ($DEBUG > 4) { print "sql: $sql_neb_volumes\n"; } 322 323 my $rowref = $neb_dbh->selectall_arrayref( $sql_neb_volumes ); 324 my @tmparray = @$rowref; 325 my $Nrows = @tmparray; 326 327 if ($DEBUG > 4) { print "found $Nrows possible volumes\n"; } 328 329 foreach my $valref (@tmparray) { 330 my @values = @$valref; 331 # there should only be a single value (only name selected above) 332 my $Nvalues = @values; 333 if ($Nvalues == 0) { print "ERROR: missing uri\n"; next; } 334 if ($Nvalues > 1) { print "ERROR: too many uri entries?\n"; next; } 335 336 $volarray{$values[0]} = 1; 337 if ($DEBUG > 4) { print "$values[0]\n"; } 338 } 339 340 return %volarray; 341 } 342 166 343 # read the list of chip_ids: 167 344 sub load_chip_list { … … 194 371 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 195 372 pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist; 196 pod2usage( -msg => "Define the stage ( v0, v1, etc) with --stage", -exitval => 2) unless defined $stage;373 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 197 374 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 198 375 376 # check that stage is an integer 377 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 378 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 379 199 380 # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?) 200 381 … … 248 429 sub vsystem { 249 430 print STDERR "@_\n"; 250 # return 0;431 # return 0; 251 432 my $status = system ("@_"); 252 433 return $status; 253 434 } 435 436 sub is_integer { 437 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 438 } 439 -
trunk/tools/eam/rawfix.20230221/src/get_md5s_instances.pl
r42441 r42444 11 11 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 12 12 13 # USAGE: get_md5s_instances.pl --hostname (hostname) --input (file) --stage ( v0,v1,etc)13 # USAGE: get_md5s_instances.pl --hostname (hostname) --input (file) --stage (0,1,etc) 14 14 15 15 my ($myhost, $input, $stage) = &parse_cmdopts; … … 26 26 27 27 if ($output eq $input) { die "output file ($output) matches input file ($input)\n"; } 28 29 # read in both instance 30 my $out_hash_r; 28 31 if (-e $output) { 29 # check that all instances are in the output file? 30 print "$output exists, skipping\n"; 31 exit 0; 32 $out_hash_r = &load_output_list ($output); 32 33 } 33 34 34 open (OUTFILE, "> $output");35 open (OUTFILE, ">>$output"); 35 36 36 37 # foreach my $instance (@$ins_list_r) { … … 41 42 my $md5sum_tru = $md5_list_r->[$i]; 42 43 44 # if the instance is already in the output file, skip it 45 if (defined $out_hash_r) { 46 my $name = $out_hash_r->{$instance}; 47 if (defined $name) { 48 print STDERR "skipping $instance (already in output)\n"; 49 next; 50 } 51 } 52 43 53 my $filename = $instance; 44 54 $filename =~ s|file://||; 45 55 46 56 # check for the existence of the file first: 47 57 unless (-e $filename) { … … 63 73 exit 0; 64 74 65 # read the list of chip_ids:75 # read the instance info 66 76 sub load_instance_list { 67 77 my $infile = $_[0]; … … 88 98 } 89 99 100 # read the instance list in the output file 101 sub load_output_list { 102 my $infile = $_[0]; 103 104 my (%out_hash); 105 106 open(FILE,$infile) or die "cannot open file $infile\n"; 107 108 my @lines = <FILE>; 109 110 foreach my $line (@lines) { 111 chomp $line; 112 if ($line =~ /^\s*#/) { next; } # skip lines with leading # 113 my @words = split (/\s+/,$line); 114 115 if (@words != 4) { die "error in input $infile : $line\n"; } 116 $out_hash{$words[0]} = 1; 117 } 118 close (FILE); 119 120 return (\%out_hash); 121 } 122 90 123 sub parse_cmdopts { 91 124 … … 95 128 pod2usage( -msg => "Provide the input list with --input", -exitval => 2) unless defined $input; 96 129 pod2usage( -msg => "Define the host machine with --hostname", -exitval => 2) unless defined $myhost; 97 pod2usage( -msg => "Define the stage (v0, v1, etc) with --stage", -exitval => 2) unless defined $stage; 130 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 131 132 # check that stage is an integer 133 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 134 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 98 135 99 136 return ($myhost, $input, $stage); … … 106 143 return $status; 107 144 } 145 146 sub is_integer { 147 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 148 } 149
Note:
See TracChangeset
for help on using the changeset viewer.
