From 7deb5ac9de2b94a685dbd61dc77a8eafa91f5c38 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Thu, 7 Sep 2017 16:22:37 -0400 Subject: [PATCH] Make tools easier to run Support users running these as an executable, a ruby script, or through rails runner: ./tools/db_ping_remote.rb ruby tools/db_ping_remote.rb bin/rails r tools/db_ping_remote.rb Add executable permission Add shebang for ruby Load rails automatically for tools that require rails [skip ci] Similar to #14169 --- tools/create_evm_snapshot.rb | 3 +++ tools/db_ping_remote.rb | 1 + tools/db_printers/print_ae_tree.rb | 4 +++- tools/db_printers/print_ems_metadata.rb | 3 +++ tools/db_printers/print_ems_metadata_full.rb | 3 +++ tools/db_printers/print_network.rb | 3 +++ tools/db_printers/print_relationships.rb | 3 +++ tools/db_printers/print_scsi.rb | 3 +++ tools/db_printers/print_vmdb_database.rb | 3 +++ tools/dba.rb | 3 +++ tools/delete_all_error_timeout_queue_messages.rb | 3 +++ tools/delete_ems_metadata_relationships.rb | 3 +++ tools/doc/reportable_fields_to_csv.rb | 3 +++ tools/doc/reports_to_csv.rb | 3 +++ tools/evm_dump.rb | 3 +++ tools/export_tags.rb | 3 +++ tools/feature_support_matrix.rb | 1 + tools/fix_binary_blobs_and_parts_size_column.rb | 3 +++ tools/fix_column_ordering.rb | 3 +++ tools/fix_disk_sizes.rb | 3 +++ tools/fix_vm_relationships.rb | 3 +++ tools/import_tags.rb | 3 +++ tools/import_v4_provision_dialogs.rb | 3 +++ tools/kill_provision.rb | 3 +++ tools/ldap_ping.rb | 3 +++ tools/list_evm_snapshots.rb | 2 ++ tools/log_processing/broker_registry_counts.rb | 3 ++- tools/log_processing/ems_refresh_timings.rb | 3 ++- tools/log_processing/perf_timings.rb | 4 +++- tools/log_processing/split_log_by_pid_tid.rb | 4 +++- tools/metrics_capture_gap.rb | 3 +++ tools/metrics_destroy_for_time_profile.rb | 3 +++ tools/metrics_populate_retro_tags.rb | 3 +++ tools/purge_archived_vms.rb | 3 +++ tools/purge_ems_events.rb | 3 +++ tools/purge_host_unknown_records.rb | 3 +++ tools/purge_metrics.rb | 1 + tools/purge_miq_report_results.rb | 1 + tools/purge_orphaned_tag_values.rb | 1 + tools/rebuild_provision_request.rb | 1 + tools/rm_evm_snapshots.rb | 2 ++ tools/show_host_file_entries_for_vnc.rb | 3 +++ tools/vim_collect_inventory.rb | 3 +++ tools/vim_collect_perf_history.rb | 3 +++ tools/vm_retirement.rb | 3 +++ 45 files changed, 119 insertions(+), 5 deletions(-) mode change 100644 => 100755 tools/create_evm_snapshot.rb mode change 100644 => 100755 tools/db_ping_remote.rb mode change 100644 => 100755 tools/db_printers/print_ae_tree.rb mode change 100644 => 100755 tools/db_printers/print_ems_metadata.rb mode change 100644 => 100755 tools/db_printers/print_ems_metadata_full.rb mode change 100644 => 100755 tools/db_printers/print_network.rb mode change 100644 => 100755 tools/db_printers/print_relationships.rb mode change 100644 => 100755 tools/db_printers/print_scsi.rb mode change 100644 => 100755 tools/db_printers/print_vmdb_database.rb mode change 100644 => 100755 tools/dba.rb mode change 100644 => 100755 tools/delete_all_error_timeout_queue_messages.rb mode change 100644 => 100755 tools/delete_ems_metadata_relationships.rb mode change 100644 => 100755 tools/doc/reportable_fields_to_csv.rb mode change 100644 => 100755 tools/doc/reports_to_csv.rb mode change 100644 => 100755 tools/evm_dump.rb mode change 100644 => 100755 tools/export_tags.rb mode change 100644 => 100755 tools/fix_binary_blobs_and_parts_size_column.rb mode change 100644 => 100755 tools/fix_column_ordering.rb mode change 100644 => 100755 tools/fix_disk_sizes.rb mode change 100644 => 100755 tools/fix_vm_relationships.rb mode change 100644 => 100755 tools/import_tags.rb mode change 100644 => 100755 tools/import_v4_provision_dialogs.rb mode change 100644 => 100755 tools/kill_provision.rb mode change 100644 => 100755 tools/ldap_ping.rb mode change 100644 => 100755 tools/log_processing/broker_registry_counts.rb mode change 100644 => 100755 tools/log_processing/ems_refresh_timings.rb mode change 100644 => 100755 tools/log_processing/perf_timings.rb mode change 100644 => 100755 tools/log_processing/split_log_by_pid_tid.rb mode change 100644 => 100755 tools/metrics_capture_gap.rb mode change 100644 => 100755 tools/metrics_destroy_for_time_profile.rb mode change 100644 => 100755 tools/metrics_populate_retro_tags.rb mode change 100644 => 100755 tools/purge_archived_vms.rb mode change 100644 => 100755 tools/purge_ems_events.rb mode change 100644 => 100755 tools/purge_host_unknown_records.rb mode change 100644 => 100755 tools/purge_metrics.rb mode change 100644 => 100755 tools/purge_miq_report_results.rb mode change 100644 => 100755 tools/purge_orphaned_tag_values.rb mode change 100644 => 100755 tools/rebuild_provision_request.rb mode change 100644 => 100755 tools/show_host_file_entries_for_vnc.rb mode change 100644 => 100755 tools/vim_collect_inventory.rb mode change 100644 => 100755 tools/vim_collect_perf_history.rb mode change 100644 => 100755 tools/vm_retirement.rb diff --git a/tools/create_evm_snapshot.rb b/tools/create_evm_snapshot.rb old mode 100644 new mode 100755 index 69232608ee3..5ebb12ef9e3 --- a/tools/create_evm_snapshot.rb +++ b/tools/create_evm_snapshot.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + def usage puts "Error: Must pass only one of the following:" puts " --vm=" diff --git a/tools/db_ping_remote.rb b/tools/db_ping_remote.rb old mode 100644 new mode 100755 index 15235f01121..2b553590973 --- a/tools/db_ping_remote.rb +++ b/tools/db_ping_remote.rb @@ -1,3 +1,4 @@ +#!/usr/bin/env ruby require File.expand_path('../config/environment', __dir__) require 'io/console' diff --git a/tools/db_printers/print_ae_tree.rb b/tools/db_printers/print_ae_tree.rb old mode 100644 new mode 100755 index 077661618ed..9e95f955c03 --- a/tools/db_printers/print_ae_tree.rb +++ b/tools/db_printers/print_ae_tree.rb @@ -1,5 +1,7 @@ -# Rails.logger.level = $log.level = 0 +#!/usr/bin/env ruby +require File.expand_path('../../config/environment', __dir__) +# Rails.logger.level = $log.level = 0 def print_ae_tree(nodes, indent = "") nodes.sort_by { |n| n.name.downcase }.each do |node| title = node.class.name.demodulize[5..-1] diff --git a/tools/db_printers/print_ems_metadata.rb b/tools/db_printers/print_ems_metadata.rb old mode 100644 new mode 100755 index daaec7ac6c4..f54fb0dbd0e --- a/tools/db_printers/print_ems_metadata.rb +++ b/tools/db_printers/print_ems_metadata.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../../config/environment', __dir__) + def print_subtree(subtree, indent = '') subtree = subtree.sort_by { |obj, _children| [obj.class.name, obj.name.downcase] } subtree.each do |obj, children| diff --git a/tools/db_printers/print_ems_metadata_full.rb b/tools/db_printers/print_ems_metadata_full.rb old mode 100644 new mode 100755 index 30afba82829..5e00389809c --- a/tools/db_printers/print_ems_metadata_full.rb +++ b/tools/db_printers/print_ems_metadata_full.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../../config/environment', __dir__) + def print_subtree(subtree, indent = '') subtree = subtree.sort_by { |obj, _children| [obj.class.name, obj.name.downcase] } subtree.each do |obj, children| diff --git a/tools/db_printers/print_network.rb b/tools/db_printers/print_network.rb old mode 100644 new mode 100755 index db1ba7263bf..44fe424fd86 --- a/tools/db_printers/print_network.rb +++ b/tools/db_printers/print_network.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../../config/environment', __dir__) + def print_switch(indent, switch) puts "#{indent}Switch: #{switch.name}" switch.lans.order("lower(name)").each do |lan| diff --git a/tools/db_printers/print_relationships.rb b/tools/db_printers/print_relationships.rb old mode 100644 new mode 100755 index 7a60627d745..17cefa5b4d6 --- a/tools/db_printers/print_relationships.rb +++ b/tools/db_printers/print_relationships.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../../config/environment', __dir__) + def print_rels(subtree, indent = '') subtree = subtree.sort_by { |rel, _children| rel.resource_pair } subtree.each do |rel, children| diff --git a/tools/db_printers/print_scsi.rb b/tools/db_printers/print_scsi.rb old mode 100644 new mode 100755 index 1adff949bdb..d41e62f49c3 --- a/tools/db_printers/print_scsi.rb +++ b/tools/db_printers/print_scsi.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../../config/environment', __dir__) + Host.all.each do |host| puts "Host: #{host.name} (id: #{host.id})" diff --git a/tools/db_printers/print_vmdb_database.rb b/tools/db_printers/print_vmdb_database.rb old mode 100644 new mode 100755 index a43f765957a..c08740cbf47 --- a/tools/db_printers/print_vmdb_database.rb +++ b/tools/db_printers/print_vmdb_database.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../../config/environment', __dir__) + def print_records(recs, indent = '') recs = recs.sort_by { |r| r.name.downcase } recs.each do |r| diff --git a/tools/dba.rb b/tools/dba.rb old mode 100644 new mode 100755 index 63b865a6835..7961457d984 --- a/tools/dba.rb +++ b/tools/dba.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + module Dba def self.select(*args) ActiveRecord::Base.connection.send(:select, *args) diff --git a/tools/delete_all_error_timeout_queue_messages.rb b/tools/delete_all_error_timeout_queue_messages.rb old mode 100644 new mode 100755 index c51e5a06de9..18656a680e0 --- a/tools/delete_all_error_timeout_queue_messages.rb +++ b/tools/delete_all_error_timeout_queue_messages.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + cond = {:state => ["error", "timeout"]} puts "Deleting #{MiqQueue.where(cond).count} queue messages" diff --git a/tools/delete_ems_metadata_relationships.rb b/tools/delete_ems_metadata_relationships.rb old mode 100644 new mode 100755 index 54d94b15f83..4baa7496f6f --- a/tools/delete_ems_metadata_relationships.rb +++ b/tools/delete_ems_metadata_relationships.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + puts "Deleting ems_metadata Relationships..." Relationship.where(:relationship => "ems_metadata").delete_all puts "Deleting ems_metadata Relationships...Complete" diff --git a/tools/doc/reportable_fields_to_csv.rb b/tools/doc/reportable_fields_to_csv.rb old mode 100644 new mode 100755 index e48ef8827ff..5696a2d7c2a --- a/tools/doc/reportable_fields_to_csv.rb +++ b/tools/doc/reportable_fields_to_csv.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../../config/environment', __dir__) + models = MiqReport.reportable_models.collect do |m| [Dictionary.gettext(m, :type => :model, :notfound => :titleize).pluralize, m] end.sort diff --git a/tools/doc/reports_to_csv.rb b/tools/doc/reports_to_csv.rb old mode 100644 new mode 100755 index 626b72d672c..21fed77c076 --- a/tools/doc/reports_to_csv.rb +++ b/tools/doc/reports_to_csv.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../../config/environment', __dir__) + require 'csv' CSV.open("reports.csv", "w") do |csv| csv << %w(Name Title Group Sorting Graph Filter) diff --git a/tools/evm_dump.rb b/tools/evm_dump.rb old mode 100644 new mode 100755 index 8319df329c5..29dc1e8a870 --- a/tools/evm_dump.rb +++ b/tools/evm_dump.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + LOG_DIR = "./" logfile = File.join(LOG_DIR, "evm_dump.log") File.delete(logfile) if File.exist?(logfile) diff --git a/tools/export_tags.rb b/tools/export_tags.rb old mode 100644 new mode 100755 index d1ec6eab17c..8770563738d --- a/tools/export_tags.rb +++ b/tools/export_tags.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + output = ARGV[0] raise "No output file provided" if output.nil? diff --git a/tools/feature_support_matrix.rb b/tools/feature_support_matrix.rb index 38d06bd6f66..11ac932df8c 100755 --- a/tools/feature_support_matrix.rb +++ b/tools/feature_support_matrix.rb @@ -1,3 +1,4 @@ +#!/usr/bin/env ruby require File.expand_path('../config/environment', __dir__) require 'csv' diff --git a/tools/fix_binary_blobs_and_parts_size_column.rb b/tools/fix_binary_blobs_and_parts_size_column.rb old mode 100644 new mode 100755 index 4626cc3b10f..f8d2d286ff6 --- a/tools/fix_binary_blobs_and_parts_size_column.rb +++ b/tools/fix_binary_blobs_and_parts_size_column.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + puts "Fixing BinaryBlob and BinaryBlobPart sizes" blob_ids = BinaryBlobPart.select(:binary_blob_id).where("size != LENGTH(data)") diff --git a/tools/fix_column_ordering.rb b/tools/fix_column_ordering.rb old mode 100644 new mode 100755 index 1f3c1d74cc3..620a887f4a7 --- a/tools/fix_column_ordering.rb +++ b/tools/fix_column_ordering.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + $LOAD_PATH << Rails.root.join("tools") require 'column_ordering/column_ordering' diff --git a/tools/fix_disk_sizes.rb b/tools/fix_disk_sizes.rb old mode 100644 new mode 100755 index 563fc223293..95e387dc659 --- a/tools/fix_disk_sizes.rb +++ b/tools/fix_disk_sizes.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + def getDinfo(vim) dinfo = [] vim.virtualMachinesByMor.each do |_k, v| diff --git a/tools/fix_vm_relationships.rb b/tools/fix_vm_relationships.rb old mode 100644 new mode 100755 index 91a02bfa51b..8a81f041aeb --- a/tools/fix_vm_relationships.rb +++ b/tools/fix_vm_relationships.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + ### Used to fix VM to Parent Resource Pool relationship problems. # Normally seen when user clicks on a VM to view VM summary page. # Error is displayed "Couldn't find Relationship with id=XXXX [vm_or_template/tree_select]" diff --git a/tools/import_tags.rb b/tools/import_tags.rb old mode 100644 new mode 100755 index 71c48428443..48bb8a83dd1 --- a/tools/import_tags.rb +++ b/tools/import_tags.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + input = ARGV[0] raise "No input file provided" if input.nil? diff --git a/tools/import_v4_provision_dialogs.rb b/tools/import_v4_provision_dialogs.rb old mode 100644 new mode 100755 index 5e8b99c4fd6..2812a76226b --- a/tools/import_v4_provision_dialogs.rb +++ b/tools/import_v4_provision_dialogs.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + # Convert v4-style provisioning dialogs from Ruby files into YAML format # and store in the miq_dialogs table. Dir.glob(Rails.root.join("db/fixtures/*.rb")) do |dialog_file| diff --git a/tools/kill_provision.rb b/tools/kill_provision.rb old mode 100644 new mode 100755 index 4f47f9a04df..e0964c7f74e --- a/tools/kill_provision.rb +++ b/tools/kill_provision.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + st = Time.now @stop_message = "Provisioning stopped by external script." @processed = [] diff --git a/tools/ldap_ping.rb b/tools/ldap_ping.rb old mode 100644 new mode 100755 index 140ed90e47f..58e81f0d862 --- a/tools/ldap_ping.rb +++ b/tools/ldap_ping.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + LOG_DIR = "./" logfile = File.join(LOG_DIR, "ldap_ping.log") # File.delete(logfile) if File.exist?(logfile) diff --git a/tools/list_evm_snapshots.rb b/tools/list_evm_snapshots.rb index 8baec8ee2ee..c75091147be 100755 --- a/tools/list_evm_snapshots.rb +++ b/tools/list_evm_snapshots.rb @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) require 'rubygems' require 'log4r' require 'VMwareWebService/MiqVim' diff --git a/tools/log_processing/broker_registry_counts.rb b/tools/log_processing/broker_registry_counts.rb old mode 100644 new mode 100755 index 0f011a019b0..5775d54a0c6 --- a/tools/log_processing/broker_registry_counts.rb +++ b/tools/log_processing/broker_registry_counts.rb @@ -1,4 +1,5 @@ -RAILS_ROOT = ENV["RAILS_ENV"] ? Rails.root : File.expand_path(File.join(__dir__, %w(.. ..))) +#!/usr/bin/env ruby +RAILS_ROOT = File.expand_path(File.join(__dir__, %w(.. ..))) require 'manageiq-gems-pending' require 'miq_logger_processor' diff --git a/tools/log_processing/ems_refresh_timings.rb b/tools/log_processing/ems_refresh_timings.rb old mode 100644 new mode 100755 index 7d1f025173b..11759cefa3c --- a/tools/log_processing/ems_refresh_timings.rb +++ b/tools/log_processing/ems_refresh_timings.rb @@ -1,4 +1,5 @@ -RAILS_ROOT = ENV['RAILS_ENV'] ? Rails.root : File.expand_path(File.join(__dir__, %w(.. ..))) +#!/usr/bin/env ruby +RAILS_ROOT = File.expand_path(File.join(__dir__, %w(.. ..))) require 'manageiq-gems-pending' require 'miq_logger_processor' diff --git a/tools/log_processing/perf_timings.rb b/tools/log_processing/perf_timings.rb old mode 100644 new mode 100755 index 56b133a02ed..32437932fe9 --- a/tools/log_processing/perf_timings.rb +++ b/tools/log_processing/perf_timings.rb @@ -1,4 +1,6 @@ -RAILS_ROOT = ENV["RAILS_ENV"] ? Rails.root : File.expand_path(File.join(__dir__, %w(.. ..))) +#!/usr/bin/env ruby + +RAILS_ROOT = File.expand_path(File.join(__dir__, %w(.. ..))) require 'manageiq-gems-pending' require 'miq_logger_processor' diff --git a/tools/log_processing/split_log_by_pid_tid.rb b/tools/log_processing/split_log_by_pid_tid.rb old mode 100644 new mode 100755 index 0bf95675302..2e5a0ca7858 --- a/tools/log_processing/split_log_by_pid_tid.rb +++ b/tools/log_processing/split_log_by_pid_tid.rb @@ -1,4 +1,6 @@ -RAILS_ROOT = ENV["RAILS_ENV"] ? Rails.root : File.expand_path(File.join(__dir__, %w(.. ..))) +#!/usr/bin/env ruby + +RAILS_ROOT = File.expand_path(File.join(__dir__, %w(.. ..))) require 'manageiq-gems-pending' require 'miq_logger_processor' diff --git a/tools/metrics_capture_gap.rb b/tools/metrics_capture_gap.rb old mode 100644 new mode 100755 index 162fcd8798f..f617f21165a --- a/tools/metrics_capture_gap.rb +++ b/tools/metrics_capture_gap.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + if ARGV.length != 2 puts "Usage: rails runner #{$0} start_date end_date" puts diff --git a/tools/metrics_destroy_for_time_profile.rb b/tools/metrics_destroy_for_time_profile.rb old mode 100644 new mode 100755 index 7795ef94402..9504363c9fa --- a/tools/metrics_destroy_for_time_profile.rb +++ b/tools/metrics_destroy_for_time_profile.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + if ARGV.length != 1 puts "Usage: rails runner #{$0} time_profile_id" exit 1 diff --git a/tools/metrics_populate_retro_tags.rb b/tools/metrics_populate_retro_tags.rb old mode 100644 new mode 100755 index b0c192ed99f..2af0ed5e8c8 --- a/tools/metrics_populate_retro_tags.rb +++ b/tools/metrics_populate_retro_tags.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + # Rails.logger.level = 0 start_ts, end_ts, id_spec = ARGV diff --git a/tools/purge_archived_vms.rb b/tools/purge_archived_vms.rb old mode 100644 new mode 100755 index bc91ab15157..43d0ed60488 --- a/tools/purge_archived_vms.rb +++ b/tools/purge_archived_vms.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + # Delete any records older than this: ARCHIVE_CUTOFF = Time.now.utc - 1.month # If true, do not delete anything; only report: diff --git a/tools/purge_ems_events.rb b/tools/purge_ems_events.rb old mode 100644 new mode 100755 index a20bfebc6d3..9534c758c6e --- a/tools/purge_ems_events.rb +++ b/tools/purge_ems_events.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + KEEP_EVENTS = 6.months PURGE_WINDOW = 1000 diff --git a/tools/purge_host_unknown_records.rb b/tools/purge_host_unknown_records.rb old mode 100644 new mode 100755 index c3b6070fb23..4196d786793 --- a/tools/purge_host_unknown_records.rb +++ b/tools/purge_host_unknown_records.rb @@ -1,2 +1,5 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + class HostUnknown < Host; end HostUnknown.destroy_all diff --git a/tools/purge_metrics.rb b/tools/purge_metrics.rb old mode 100644 new mode 100755 index 27788d4c925..5ea90684360 --- a/tools/purge_metrics.rb +++ b/tools/purge_metrics.rb @@ -1,3 +1,4 @@ +#!/usr/bin/env ruby require File.expand_path('../config/environment', __dir__) require 'trollop' diff --git a/tools/purge_miq_report_results.rb b/tools/purge_miq_report_results.rb old mode 100644 new mode 100755 index 0c4b6392981..54e7ad0bcfa --- a/tools/purge_miq_report_results.rb +++ b/tools/purge_miq_report_results.rb @@ -1,3 +1,4 @@ +#!/usr/bin/env ruby require File.expand_path('../config/environment', __dir__) require 'trollop' diff --git a/tools/purge_orphaned_tag_values.rb b/tools/purge_orphaned_tag_values.rb old mode 100644 new mode 100755 index 6a5aa981434..0bed9ab43d8 --- a/tools/purge_orphaned_tag_values.rb +++ b/tools/purge_orphaned_tag_values.rb @@ -1,3 +1,4 @@ +#!/usr/bin/env ruby require File.expand_path('../config/environment', __dir__) require 'trollop' diff --git a/tools/rebuild_provision_request.rb b/tools/rebuild_provision_request.rb old mode 100644 new mode 100755 index 4503ca61197..713f92e7f70 --- a/tools/rebuild_provision_request.rb +++ b/tools/rebuild_provision_request.rb @@ -1,3 +1,4 @@ +#!/usr/bin/env ruby require File.expand_path('../config/environment', __dir__) require 'trollop' require 'rest-client' diff --git a/tools/rm_evm_snapshots.rb b/tools/rm_evm_snapshots.rb index b828ba5728a..3a00f1740eb 100755 --- a/tools/rm_evm_snapshots.rb +++ b/tools/rm_evm_snapshots.rb @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) require 'rubygems' require 'log4r' require 'VMwareWebService/MiqVim' diff --git a/tools/show_host_file_entries_for_vnc.rb b/tools/show_host_file_entries_for_vnc.rb old mode 100644 new mode 100755 index e2a0a7cf2f8..fcaa9946ef8 --- a/tools/show_host_file_entries_for_vnc.rb +++ b/tools/show_host_file_entries_for_vnc.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + ManageIQ::Providers::Vmware::Host.all.each do |host| if host.ipaddress.blank? STDERR.puts "Host ID=#{host.id.inspect}, Name=#{host.name.inspect} has no IP Address" diff --git a/tools/vim_collect_inventory.rb b/tools/vim_collect_inventory.rb old mode 100644 new mode 100755 index 1a6fb1dc6c7..d9069c93311 --- a/tools/vim_collect_inventory.rb +++ b/tools/vim_collect_inventory.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + require 'trollop' ARGV.shift if ARGV.first == "--" # Handle when called through script/runner opts = Trollop.options do diff --git a/tools/vim_collect_perf_history.rb b/tools/vim_collect_perf_history.rb old mode 100644 new mode 100755 index 9b5b5ae124f..0fdff3f379f --- a/tools/vim_collect_perf_history.rb +++ b/tools/vim_collect_perf_history.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + require 'trollop' ARGV.shift if ARGV.first == "--" # Handle when called through script/runner opts = Trollop.options do diff --git a/tools/vm_retirement.rb b/tools/vm_retirement.rb old mode 100644 new mode 100755 index c993019c834..87cfeb83e3a --- a/tools/vm_retirement.rb +++ b/tools/vm_retirement.rb @@ -1,3 +1,6 @@ +#!/usr/bin/env ruby +require File.expand_path('../config/environment', __dir__) + def header output = "Name\tOwner\tOwner Userid\tOwning Group\tRetired?\tRetirement Date\tRetirement Warning" output += "\n"