Skip to content

Commit

Permalink
Don't require modifying the source to purge vms
Browse files Browse the repository at this point in the history
Use an ENV var to indicate if vms should be deleted or just report what
would be deleted rather than requiring people to modify the tool's
source
  • Loading branch information
agrare committed Oct 16, 2019
1 parent b7c9523 commit dde4ff1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/purge_archived_vms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Delete any records older than this:
ARCHIVE_CUTOFF = Time.now.utc - 1.month
# If true, do not delete anything; only report:
REPORT_ONLY = true
REPORT_ONLY = ActiveModel::Type::Boolean.new.cast(ENV.fetch("REPORT_ONLY", true))

old_logger = $log
$log = VMDBLogger.new(STDOUT)
Expand Down Expand Up @@ -36,6 +36,7 @@
end

$log.info("Completed purging archived VMs. #{REPORT_ONLY ? 'Found' : 'Purged'} #{archived} archived VMs.")
$log.info("To cleanup archived VMs re-run with REPORT_ONLY=false #{$PROGRAM_NAME}")

$log.close
$log = old_logger

0 comments on commit dde4ff1

Please sign in to comment.