From cf65236eba14b94eafa2abd0c1e52bee0e8a0301 Mon Sep 17 00:00:00 2001 From: Jerry Keselman Date: Thu, 9 Aug 2018 15:54:02 -0400 Subject: [PATCH 1/2] rake evm:db:restore:remote mods for S3 When rake evm:db:restore:remote is issued with an S3 URI, specify the AWS region as an argument to be passed to EvmDatabaseOps --- lib/tasks/evm_dba.rake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/tasks/evm_dba.rake b/lib/tasks/evm_dba.rake index 5938509c61d..649ede3971f 100644 --- a/lib/tasks/evm_dba.rake +++ b/lib/tasks/evm_dba.rake @@ -172,6 +172,7 @@ namespace :evm do opt :uri, "Destination depot URI", :type => :string, :required => true opt :uri_username, "Destination depot username", :type => :string opt :uri_password, "Destination depot password", :type => :string + opt :uri_region, "Destination depot region", :type => :string opt :remote_file_name, "Destination depot filename", :type => :string opt :username, "Username", :type => :string opt :password, "Password", :type => :string @@ -183,9 +184,10 @@ namespace :evm do [:dbname, :username, :password, :hostname].each { |k| db_opts[k] = opts[k] if opts[k] } connect_opts = {} - [:uri, :uri_username, :uri_password, :remote_file_name].each { |k| connect_opts[k] = opts[k] if opts[k] } + [:uri, :uri_username, :uri_password, :uri_region, :remote_file_name].each { |k| connect_opts[k] = opts[k] if opts[k] } connect_opts[:username] = connect_opts.delete(:uri_username) if connect_opts[:uri_username] connect_opts[:password] = connect_opts.delete(:uri_password) if connect_opts[:uri_password] + connect_opts[:region] = connect_opts.delete(:uri_region) if connect_opts[:uri_region] EvmDatabaseOps.backup(db_opts, connect_opts) @@ -271,6 +273,7 @@ namespace :evm do opt :uri, "Destination depot URI", :type => :string, :required => true opt :uri_username, "Destination depot username", :type => :string opt :uri_password, "Destination depot password", :type => :string + opt :uri_region, "Destination depot region", :type => :string opt :username, "Username", :type => :string opt :password, "Password", :type => :string opt :hostname, "Hostname", :type => :string @@ -281,9 +284,10 @@ namespace :evm do [:dbname, :username, :password, :hostname].each { |k| db_opts[k] = opts[k] if opts[k] } connect_opts = {} - [:uri, :uri_username, :uri_password].each { |k| connect_opts[k] = opts[k] if opts[k] } + [:uri, :uri_username, :uri_password, :uri_region].each { |k| connect_opts[k] = opts[k] if opts[k] } connect_opts[:username] = connect_opts.delete(:uri_username) if connect_opts[:uri_username] connect_opts[:password] = connect_opts.delete(:uri_password) if connect_opts[:uri_password] + connect_opts[:region] = connect_opts.delete(:uri_region) if connect_opts[:uri_region] # If running through runner, disconnect any local connections ActiveRecord::Base.clear_all_connections! if ActiveRecord && ActiveRecord::Base From 348b1bd458a1a04f1829e0d3dd4309418d58b5ef Mon Sep 17 00:00:00 2001 From: Jerry Keselman Date: Fri, 10 Aug 2018 10:25:40 -0400 Subject: [PATCH 2/2] Rename --uri-region option to --aws-region Since the region option has nothing to do with the URI, but is AWS specific, rename the option appropriately, per review comments. --- lib/tasks/evm_dba.rake | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/tasks/evm_dba.rake b/lib/tasks/evm_dba.rake index 649ede3971f..6b0929df296 100644 --- a/lib/tasks/evm_dba.rake +++ b/lib/tasks/evm_dba.rake @@ -169,25 +169,25 @@ namespace :evm do task :remote do require 'trollop' opts = Trollop.options(EvmRakeHelper.extract_command_options) do - opt :uri, "Destination depot URI", :type => :string, :required => true - opt :uri_username, "Destination depot username", :type => :string - opt :uri_password, "Destination depot password", :type => :string - opt :uri_region, "Destination depot region", :type => :string - opt :remote_file_name, "Destination depot filename", :type => :string - opt :username, "Username", :type => :string - opt :password, "Password", :type => :string - opt :hostname, "Hostname", :type => :string - opt :dbname, "Database name", :type => :string + opt :uri, "Destination depot URI", :type => :string, :required => true + opt :uri_username, "Destination depot username", :type => :string + opt :uri_password, "Destination depot password", :type => :string + opt :aws_region, "Destination depot AWS region", :type => :string + opt :remote_file_name, "Destination depot filename", :type => :string + opt :username, "Username", :type => :string + opt :password, "Password", :type => :string + opt :hostname, "Hostname", :type => :string + opt :dbname, "Database name", :type => :string end db_opts = {} [:dbname, :username, :password, :hostname].each { |k| db_opts[k] = opts[k] if opts[k] } connect_opts = {} - [:uri, :uri_username, :uri_password, :uri_region, :remote_file_name].each { |k| connect_opts[k] = opts[k] if opts[k] } + [:uri, :uri_username, :uri_password, :aws_region, :remote_file_name].each { |k| connect_opts[k] = opts[k] if opts[k] } connect_opts[:username] = connect_opts.delete(:uri_username) if connect_opts[:uri_username] connect_opts[:password] = connect_opts.delete(:uri_password) if connect_opts[:uri_password] - connect_opts[:region] = connect_opts.delete(:uri_region) if connect_opts[:uri_region] + connect_opts[:region] = connect_opts.delete(:aws_region) if connect_opts[:aws_region] EvmDatabaseOps.backup(db_opts, connect_opts) @@ -270,24 +270,24 @@ namespace :evm do task :remote => :environment do require 'trollop' opts = Trollop.options(EvmRakeHelper.extract_command_options) do - opt :uri, "Destination depot URI", :type => :string, :required => true - opt :uri_username, "Destination depot username", :type => :string - opt :uri_password, "Destination depot password", :type => :string - opt :uri_region, "Destination depot region", :type => :string - opt :username, "Username", :type => :string - opt :password, "Password", :type => :string - opt :hostname, "Hostname", :type => :string - opt :dbname, "Database name", :type => :string + opt :uri, "Destination depot URI", :type => :string, :required => true + opt :uri_username, "Destination depot username", :type => :string + opt :uri_password, "Destination depot password", :type => :string + opt :aws_region, "Destination depot AWS region", :type => :string + opt :username, "Username", :type => :string + opt :password, "Password", :type => :string + opt :hostname, "Hostname", :type => :string + opt :dbname, "Database name", :type => :string end db_opts = {} [:dbname, :username, :password, :hostname].each { |k| db_opts[k] = opts[k] if opts[k] } connect_opts = {} - [:uri, :uri_username, :uri_password, :uri_region].each { |k| connect_opts[k] = opts[k] if opts[k] } + [:uri, :uri_username, :uri_password, :aws_region].each { |k| connect_opts[k] = opts[k] if opts[k] } connect_opts[:username] = connect_opts.delete(:uri_username) if connect_opts[:uri_username] connect_opts[:password] = connect_opts.delete(:uri_password) if connect_opts[:uri_password] - connect_opts[:region] = connect_opts.delete(:uri_region) if connect_opts[:uri_region] + connect_opts[:region] = connect_opts.delete(:aws_region) if connect_opts[:aws_region] # If running through runner, disconnect any local connections ActiveRecord::Base.clear_all_connections! if ActiveRecord && ActiveRecord::Base