From dde4ff1736a6b474bb965fb2a9b4e97cfa122954 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Wed, 16 Oct 2019 09:56:22 -0400 Subject: [PATCH] Don't require modifying the source to purge vms 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 --- tools/purge_archived_vms.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/purge_archived_vms.rb b/tools/purge_archived_vms.rb index 85b0d618dd2..b03f86e684f 100755 --- a/tools/purge_archived_vms.rb +++ b/tools/purge_archived_vms.rb @@ -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) @@ -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