Skip to content

Commit

Permalink
Fix Remove Selected Items from Inventory button for Images, Instances
Browse files Browse the repository at this point in the history
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1601955

Fix the button by adding support for destroy to VmOrTemplate model.
  • Loading branch information
Hilda Stastna committed Jul 31, 2018
1 parent 12b109c commit 43b7615
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
Binary file added 10x8x196x1271531924805.backup
Binary file not shown.
1 change: 1 addition & 0 deletions app/models/mixins/supports_feature_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module SupportsFeatureMixin
:external_logging => 'Launch External Logging UI',
:swift_service => 'Swift storage service',
:delete => 'Deletion',
:destroy => 'Destroy',
:delete_aggregate => 'Host Aggregate Deletion',
:delete_floating_ip => 'Floating IP Deletion',
:delete_security_group => 'Security Group Deletion',
Expand Down
1 change: 1 addition & 0 deletions app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,7 @@ def self.includes_template?(ids)
end

supports_not :snapshots
supports :destroy

# Stop showing Reconfigure VM task unless the subclass allows
def reconfigurable?
Expand Down
57 changes: 57 additions & 0 deletions tools/set_db_from.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env ruby
require File.expand_path('../config/environment', __dir__)
# ./tools/set_db_from.rb 10.8.198.207 case_01809078 i ~/Downloads/vmdb_production_dump u
def ip
ARGV[0]
end

def local_db_name
ARGV[1]
end

def was_good?(was_good)
was_good ? 'OK' : 'FAIL'
end

only_import = ARGV[2] == 'i'
only_users = ARGV[4] == 'u'

tn = Time.now.to_i
backup_file = "#{ip.gsub '.','x'}#{tn}.backup"
remote_backup_file = "/var/www/#{backup_file}"
ssh_pass_command = "sshpass -p \"smartvm\""
ssh_strict_check = "ssh -o BatchMode=yes -o StrictHostKeyChecking=no user@#{ip} \"exit\""
backup_file = ARGV[3] if ARGV[3]

puts "Hello!"

unless only_import
was_good = system ssh_strict_check
puts "ssh_strict_check: #{was_good?(was_good)}"

was_good = system "#{ssh_pass_command} ssh root@#{ip} \"pg_dump -Fc vmdb_production > #{remote_backup_file}\" "
puts "backed up db on remote(#{remote_backup_file}): #{was_good?(was_good)}"

was_good = system "#{ssh_pass_command} scp root@#{ip}:#{remote_backup_file} ./"
puts "downloaded db to local: #{was_good?(was_good)}"
end

unless only_users
was_good = system 'bundle exec rake db:create'
puts "be rake db:create: #{was_good?(was_good)}"

was_good = system "pg_restore -U root -d #{local_db_name} -F custom #{backup_file}"
puts "pg_restore: #{was_good?(was_good)}"

was_good = system 'bundle exec rake db:migrate'
puts "be rake db:migrate: #{was_good?(was_good)}"

was_good = system "ruby ./tools/fix_auth.rb -P smartvm #{local_db_name}"
puts "fix auth: #{was_good?(was_good)}"
end

was_good = system "bundle exec bin/rails r \"User.all.each do |user| puts user.userid; user.update_attributes(:password => 'smartvm') end\""
puts "users update: #{was_good?(was_good)}"

was_good = system "services memcached restart"
puts "services restart memcached: #{was_good?(was_good)}"

0 comments on commit 43b7615

Please sign in to comment.