Changeset 39581
- Timestamp:
- May 27, 2016, 10:21:16 AM (10 years ago)
- File:
-
- 1 edited
-
trunk/tools/cleandsproduct.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/cleandsproduct.pl
r35328 r39581 19 19 use PS::IPP::Metadata::List qw( parse_md_list ); 20 20 21 use Date::Parse; 22 21 23 use PS::IPP::Config 1.01 qw( :standard ); 22 24 … … 37 39 my ($product, $datastore, $last_fileset, $keep_files, $verbose); 38 40 41 # If supplied, retention_days is the number of days that filesets in a data store will be preserved. 42 # The use_configured_publish_retention_days option tells us to get retention_days from the site config. 43 # The later is only used if retention-days is not supplied in the options. 44 # NOTE: if last_fileset is also given, clean up will stop after that fileset irrespective of whether 45 # subsequent filesets are older than the retention time. 46 47 my ($retention_days, $use_publish_retention_days); 48 39 49 # Parse the command-line arguments 40 50 GetOptions( 41 'product=s' => \$product, # product name42 'datastore=s' => \$datastore, #datastore uri51 'product=s' => \$product, # product name 52 'datastore=s' => \$datastore, # datastore uri 43 53 'last_fileset=s' => \$last_fileset, # last fileset to delete 44 'no_rm' => \$keep_files, # last fileset to delete 45 'verbose' => \$verbose, # Print stuff? 54 'last-fileset=s' => \$last_fileset, # more modern spelling for last option 55 'retention-days=s' => \$retention_days, # see above 56 'use-configured-publish-retention' => \$use_publish_retention_days, #see above 57 'no_rm' => \$keep_files, # remove fileset but leave files in place 58 'no-rm' => \$keep_files, # more modern spelling for last option 59 'verbose' => \$verbose, # Print stuff? 46 60 ) or pod2usage( 2 ); 47 61 … … 52 66 53 67 54 55 # since this needs to run on the MHPCC cluster there is no need to go to the 56 # proxy to get the datastore listing 57 $datastore = "http://ippc17/ds" if !$datastore; 58 # $datastore = "http://datastore.ipp.ifa.hawaii.edu" if !$datastore; 68 if (!$datastore) { 69 $datastore = metadataLookupStr($ipprc->{_siteConfig}, "DATA_STORE_ROOT_URL"); 70 die ("Unable to find DATA_STORE_ROOT_URL in siteConfig\n") unless $datastore; 71 } 59 72 60 73 my $uri = "$datastore/$product/index.txt"; 61 74 75 # XXX: I'm not sure why this bracket is here 62 76 { 63 77 my $command = "$dsproductls --uri $uri --extra --timeout 150"; … … 77 91 } 78 92 93 # if retention_days is specified, use that. Otherwise if requested use the publish config value from the siteConfig 94 if (!$retention_days and $use_publish_retention_days) { 95 $retention_days = metadataLookupS32($ipprc->{_siteConfig}, "DATA_STORE_PUBLISH_RETENTION_DAYS"); 96 die ("required value DATA_STORE_PUBLISH_RETENTION_DAYS not found in siteConfig\n") unless defined $retention_days; 97 } 98 99 # if $retention_days is set we are to clean only filesets registered before 100 # that date/time. Convert the limit to seconds. 101 my $clean_before; 102 if ($retention_days) { 103 $clean_before = time() - $retention_days * 86400; 104 } 105 79 106 foreach my $line (@lines) { 80 107 chomp $line; … … 82 109 83 110 my ($fsuri, $fs_name, $registered, $fs_type, $target_id, $stage, $stage_id) = split " ", $line; 111 112 if ($clean_before) { 113 # registered is in the format YYYY-MM-DDTHH:MM:SSZ. Date::Parse::str2time handles this. 114 my $ticks = str2time($registered); 115 if ($ticks > $clean_before) { 116 # This fileset and therefore subsequent ones in the list was registered after our end 117 # date. We're done. 118 last; 119 } 120 } 84 121 85 122 $command = "$dsreg --del $fs_name --product $product"; … … 96 133 last if $last_fileset and ($fs_name eq $last_fileset); 97 134 } 98 99 100 135 } 101 136
Note:
See TracChangeset
for help on using the changeset viewer.
