Skip to content

Instantly share code, notes, and snippets.

@cben
Last active September 24, 2017 16:32
Show Gist options
  • Save cben/bcd08bc40742276541fb117f5317b7a3 to your computer and use it in GitHub Desktop.
Save cben/bcd08bc40742276541fb117f5317b7a3 to your computer and use it in GitHub Desktop.
Running manageiq from user's database dump
diff --git a/app/models/miq_database.rb b/app/models/miq_database.rb
index 2d5d51041e..4ad616df54 100644
--- a/app/models/miq_database.rb
+++ b/app/models/miq_database.rb
@@ -52,8 +52,8 @@ class MiqDatabase < ApplicationRecord
def self.seed
db = first || new
- db.session_secret_token ||= SecureRandom.hex(64)
- db.csrf_secret_token ||= SecureRandom.hex(64)
+ db.session_secret_token = SecureRandom.hex(64) # DEBUG was ||=
+ db.csrf_secret_token = SecureRandom.hex(64) # DEBUG was ||=

Dunno if this is documented elsewhere, this is what I came up with.

The problem is that a complete DB dump has their Users I don't (and shouldn't) know password to. Plus some things [weasel words — I don't really know!] are encrypted by secret token I don't (and shouldn't) have. But I want to login into UI to play with the system, and try to reproduce their problems.

  1. apply above patch
  2. start rails server — this resets secret token to a new secret token
  3. in rails console:
g = MiqGroup.in_my_region.find_by(description: "EvmGroup-super_administrator")
u = User.create!(name: "TMP", userid: "admin", password: "smartvm", current_group: g, miq_groups: [g])
  1. open http://localhost:3000, login as admin/smartvm 🎉

Now before starting any workers, it's prudent to deleting/disabling any existing providers, so my ManageIQ doesn't try to connect to their systems. On Gaprindashvili it's possible to mark provider paused; before that, this might work:

Authentication.pluck(:resource_type, :resource_id, :authtype, :status)
Endpoint.pluck(:resource_type, :resource_id, :role)

Authentication.where(resource_type: "ExtManagementSystem").each { |a| a.authtype = "#{a.authtype}_DISABLED"; a.status = "DISABLED"; a.save! }
Endpoint.all.each { |e| e.role = "#{e.role}_DISABLED"; e.save! }

Also running with network offline might make sense (to avoid things like Policy sending people emails etc...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment