Skip to content

Commit

Permalink
Merge pull request #2757 from lgalis/fix_vm_transform_from_infra_prov…
Browse files Browse the repository at this point in the history
…ider

VM Transform not working from a provider page
  • Loading branch information
martinpovolny authored Nov 18, 2017
2 parents a786a25 + 23e8e87 commit 80fb23f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
2 changes: 2 additions & 0 deletions app/controllers/application_controller/ci_processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module ApplicationController::CiProcessing
include Mixins::Actions::VmActions::Reconfigure
helper_method :supports_reconfigure_disks?
include Mixins::Actions::VmActions::PolicySimulation
include Mixins::Actions::VmActions::Transform

include Mixins::Actions::HostActions::Discover
include Mixins::Actions::HostActions::Power
Expand Down Expand Up @@ -1063,6 +1064,7 @@ def process_vm_buttons(pfx)
when "#{pfx}_terminate" then terminatevms
when "instance_add_security_group" then add_security_group_vms
when "instance_remove_security_group" then remove_security_group_vms
when "vm_transform" then vm_transform
end
end

Expand Down
27 changes: 27 additions & 0 deletions app/controllers/mixins/actions/vm_actions/transform.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Mixins
module Actions
module VmActions
module Transform
def vm_transform
dialog = Dialog.find_by(:label => 'Transform VM')
if params.key?(:id)
vm = Vm.find_by(:id => params[:id].to_i)
@right_cell_text = _("Transform VM %{name} to RHV") % {:name => vm.name}
dialog_initialize(
dialog.resource_actions.first,
:header => @right_cell_text,
:target_id => vm.id,
:target_kls => Vm.name
)
else
@right_cell_text = _("Transform VMs to RHV")
simple_dialog_initialize(
dialog.resource_actions.first,
:header => @right_cell_text
)
end
end
end
end
end
end
20 changes: 0 additions & 20 deletions app/controllers/vm_infra_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,4 @@ def simple_dialog_initialize(ra, options)
javascript_redirect(:action => 'dialog_load')
end
end

def vm_transform
dialog = Dialog.find_by(:label => 'Transform VM')
if params.key?(:id)
vm = Vm.find_by(:id => params[:id].to_i)
@right_cell_text = _("Transform VM %{name} to RHV") % {:name => vm.name}
dialog_initialize(
dialog.resource_actions.first,
:header => @right_cell_text,
:target_id => vm.id,
:target_kls => Vm.name
)
else
@right_cell_text = _("Transform VMs to RHV")
simple_dialog_initialize(
dialog.resource_actions.first,
:header => @right_cell_text
)
end
end
end
7 changes: 7 additions & 0 deletions spec/controllers/ems_infra_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@
post :button, :params => {:pressed => "host_analyze_check_compliance", :id => ems_infra.id, :format => :js}
expect(controller.send(:flash_errors?)).not_to be_truthy
end

it "when vm_transform is pressed" do
ems_infra = FactoryGirl.create(:ems_vmware)
expect(controller).to receive(:vm_transform)
post :button, :params => {:pressed => "vm_transform", :id => ems_infra.id, :format => :js}
expect(controller.send(:flash_errors?)).not_to be_truthy
end
end

describe "#create" do
Expand Down

0 comments on commit 80fb23f

Please sign in to comment.