Skip to content

Commit

Permalink
allow rails to be loaded in fix auth
Browse files Browse the repository at this point in the history
When objects are serialized into yaml blobs in tables,
we need to load our whole environment to handle the deserialization

This typically happens with miq_requests.options
  • Loading branch information
kbrock committed May 14, 2018
1 parent 85b25a1 commit eeb7aad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/fix_auth/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def parse(args, env = {})
opt :databaseyml, "Rewrite database.yml", :type => :boolean, :short => "y", :default => false
opt :db, "Upgrade database", :type => :boolean, :short => 'x', :default => false
opt :legacy_key, "Legacy Key", :type => :string, :short => "K"
opt :rails, "Load rails for those stuborn migrations", :type => :boolean, :short => nil, :default => false
end

options[:database] = args.first || "vmdb_production"
Expand Down
5 changes: 5 additions & 0 deletions tools/fix_auth/fix_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def fix_database_yml
FixDatabaseYml.run({:hardcode => options[:password]}.merge(run_options))
end

def load_rails
require File.expand_path("../../../config/environment.rb", __FILE__)
end

def set_passwords
MiqPassword.key_root = cert_dir if cert_dir
MiqPassword.add_legacy_key("v0_key", :v0)
Expand All @@ -83,6 +87,7 @@ def run

generate_password if options[:key]
fix_database_yml if options[:databaseyml]
load_rails if options[:rails]
fix_database_passwords if options[:db]
end
end
Expand Down

0 comments on commit eeb7aad

Please sign in to comment.