Skip to content

Commit

Permalink
Merge pull request #17059 from jrafanie/configure_server_settings_cle…
Browse files Browse the repository at this point in the history
…anup

Configure server settings cleanup
  • Loading branch information
bdunne authored Feb 28, 2018
2 parents 8d1899f + 29e49af commit cb2642a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tools/configure_server_settings.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env ruby
require File.expand_path("../config/environment", __dir__)
require 'bundler/setup'
require 'trollop'

TYPES = %w(string integer boolean symbol float).freeze

opts = Trollop.options(ARGV) do
banner "USAGE: #{__FILE__} -s <server id> -p <settings path separated by a /> -v <new value>\n" \
"Example (String): #{__FILE__} -s 1 -p reporting/history/keep_reports -v 3.months\n" \
"Example (String): #{__FILE__} -s 1 -p reporting/history/keep_reports -v 3.months\n" \
"Example (Integer): #{__FILE__} -s 1 -p workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/count -v 1 -t integer\n" \
"Example (Boolean): #{__FILE__} -s 1 -p ui/mark_translated_strings -v true -t boolean\n" \
"Example (Symbol): #{__FILE__} -s 1 -p workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/poll_method -v escalate -t symbol\n" \
"Example (Float): #{__FILE__} -s 1 -p capacity/profile/1/vcpu_commitment_ratio -v 1.5 -t float"
"Example (Symbol): #{__FILE__} -s 1 -p workers/worker_base/queue_worker_base/ems_metrics_collector_worker/defaults/poll_method -v escalate -t symbol\n" \
"Example (Float): #{__FILE__} -s 1 -p capacity/profile/1/vcpu_commitment_ratio -v 1.5 -t float"

opt :dry_run, "Dry Run", :short => "d"
opt :serverid, "Server Id", :short => "s", :type => :integer, :required => true
Expand Down Expand Up @@ -46,6 +46,8 @@
opts[:value].to_f
end

# load rails after checking CLI args so we can report args errors as fast as possible
require File.expand_path("../config/environment", __dir__)
server = MiqServer.where(:id => opts[:serverid]).take
unless server
puts "Unable to find server with id [#{opts[:serverid]}]"
Expand Down

0 comments on commit cb2642a

Please sign in to comment.