Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow comparing Hosts and VMs/Instances displayed as a nested list #6044

Merged
merged 7 commits into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/controllers/application_controller/ci_processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,6 @@ def pfx_for_vm_button_pressed(pressed)
"image"
elsif pressed.starts_with?("instance_")
"instance"
elsif pressed.starts_with?("vm_")
"vm"
elsif pressed.starts_with?("miq_template_")
"miq_template"
elsif pressed.starts_with?("orchestration_stack_")
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/cloud_network_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def button
when "custom_button"
custom_buttons
return
when 'instance_compare'
return comparemiq
when "instance_tag"
return tag("VmOrTemplate")
when "network_router_tag"
Expand Down
8 changes: 5 additions & 3 deletions app/controllers/cloud_subnet_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ def button
delete_subnets
when "cloud_subnet_edit"
javascript_redirect(:action => "edit", :id => checked_item_id)
when "cloud_subnet_new"
javascript_redirect(:action => "new")
when "custom_button"
custom_buttons
when 'instance_compare'
comparemiq
else
if params[:pressed] == "cloud_subnet_new"
javascript_redirect(:action => "new")
elsif !flash_errors? && @refresh_div == "main_div" && @lastaction == "show_list"
if !flash_errors? && @refresh_div == "main_div" && @lastaction == "show_list"
replace_gtl_main_div
else
render_flash
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/network_router_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def button
return tag("CloudSubnet")
when "custom_button"
custom_buttons
when 'instance_compare'
comparemiq
when "instance_tag"
return tag("VmOrTemplate")
when "network_router_add_interface"
Expand Down
8 changes: 5 additions & 3 deletions app/controllers/security_group_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def button
case params[:pressed]
when "instance_tag"
return tag("VmOrTemplate")
when 'instance_compare'
comparemiq
when "network_port_tag"
return tag("NetworkPort")
when "security_group_tag"
Expand All @@ -34,12 +36,12 @@ def button
delete_security_groups
when "security_group_edit"
javascript_redirect(:action => "edit", :id => checked_item_id(params))
when 'security_group_new'
javascript_redirect(:action => "new")
when "custom_button"
custom_buttons
else
if params[:pressed] == "security_group_new"
javascript_redirect(:action => "new")
elsif !flash_errors? && @refresh_div == "main_div" && @lastaction == "show_list"
if !flash_errors? && @refresh_div == "main_div" && @lastaction == "show_list"
replace_gtl_main_div
else
render_flash
Expand Down
32 changes: 22 additions & 10 deletions app/controllers/storage_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,26 @@ def button
"guest_",
"host_")

scanhosts if params[:pressed] == "host_scan"
analyze_check_compliance_hosts if params[:pressed] == "host_analyze_check_compliance"
check_compliance_hosts if params[:pressed] == "host_check_compliance"
refreshhosts if params[:pressed] == "host_refresh"
tag(Host) if params[:pressed] == "host_tag"
assign_policies(Host) if params[:pressed] == "host_protect"
edit_record if params[:pressed] == "host_edit"
deletehosts if params[:pressed] == "host_delete"
case params[:pressed]
when 'host_analyze_check_compliance'
analyze_check_compliance_hosts
when 'host_check_compliance'
check_compliance_hosts
when 'host_compare'
comparemiq
when 'host_delete'
deletehosts
when 'host_edit'
edit_record
when 'host_protect'
assign_policies(Host)
when 'host_refresh'
refreshhosts
when 'host_scan'
scanhosts
when 'host_tag'
tag(Host)
end

pfx = pfx_for_vm_button_pressed(params[:pressed])
# Handle Host power buttons
Expand All @@ -93,7 +105,7 @@ def button
else
process_vm_buttons(pfx)
return if ["host_tag", "#{pfx}_policy_sim", "host_scan", "host_refresh", "host_protect",
"#{pfx}_compare", "#{pfx}_tag", "#{pfx}_protect", "#{pfx}_retire",
'host_compare', "#{pfx}_compare", "#{pfx}_tag", "#{pfx}_protect", "#{pfx}_retire",
"#{pfx}_ownership", "#{pfx}_right_size", "#{pfx}_reconfigure"].include?(params[:pressed]) &&
@flash_array.nil? # Tag screen is showing, so return

Expand Down Expand Up @@ -126,7 +138,7 @@ def button
elsif !flash_errors? && @refresh_div == "main_div" && @lastaction == "show_list"
replace_gtl_main_div
else
javascript_flash
javascript_flash unless performed?
end
end

Expand Down
33 changes: 26 additions & 7 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@
show_list
tagging_edit
tag_edit_form_field_changed
),
) +
compare_get,
:post => %w(
attach_volume
detach_volume
Expand All @@ -552,13 +553,19 @@
form_field_changed
listnav_search_selected
quick_search
sections_field_changed
show
show_list
tagging_edit
tag_edit_form_field_changed
update
wait_for_task
) + adv_search_post + exp_post + save_post + dialog_runner_post
) +
adv_search_post +
compare_post +
dialog_runner_post +
exp_post +
save_post
},

:cloud_volume_snapshot => {
Expand Down Expand Up @@ -1618,7 +1625,8 @@
show
show_list
tagging_edit
),
) +
compare_get,
:post => %w(
button
create
Expand All @@ -1634,6 +1642,7 @@
wait_for_task
) +
adv_search_post +
compare_post +
save_post +
exp_post +
dialog_runner_post
Expand Down Expand Up @@ -1684,14 +1693,16 @@
show
show_list
tagging_edit
),
) +
compare_get,
:post => %w(
button
create
dynamic_checkbox_refresh
form_field_changed
listnav_search_selected
quick_search
sections_field_changed
show
show_list
tag_edit_form_field_changed
Expand All @@ -1700,6 +1711,7 @@
wait_for_task
) +
adv_search_post +
compare_post +
save_post +
exp_post +
dialog_runner_post
Expand All @@ -1716,14 +1728,16 @@
show
show_list
tagging_edit
),
) +
compare_get,
:post => %w(
button
create
dynamic_checkbox_refresh
form_field_changed
quick_search
listnav_search_selected
sections_field_changed
show
show_list
tag_edit_form_field_changed
Expand All @@ -1732,6 +1746,7 @@
wait_for_task
) +
adv_search_post +
compare_post +
save_post +
exp_post +
dialog_runner_post
Expand Down Expand Up @@ -1778,7 +1793,8 @@
show
show_list
tagging_edit
),
) +
compare_get,
:post => %w(
add_interface
add_interface_select
Expand All @@ -1798,6 +1814,7 @@
wait_for_task
) +
adv_search_post +
compare_post +
save_post +
exp_post +
dialog_runner_post
Expand Down Expand Up @@ -2779,7 +2796,8 @@
show
show_list
tagging_edit
),
) +
compare_get,
:post => %w(
button
listnav_search_selected
Expand All @@ -2793,6 +2811,7 @@
quick_search
) +
adv_search_post +
compare_post +
exp_post +
save_post
},
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/cloud_network_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@
controller.send(:button)
end
end

context 'comparing Instances displayed in a nested list of Cloud Network' do
let(:params) { {:pressed => 'instance_compare'} }

it 'calls comparemiq method for comparing Instances' do
expect(controller).to receive(:comparemiq)
controller.send(:button)
end
end
end

describe "#delete_networks" do
Expand Down
22 changes: 22 additions & 0 deletions spec/controllers/cloud_subnet_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,28 @@
end
end

describe '#button' do
before { controller.params = params }

context 'comparing Instances displayed in a nested list' do
let(:params) { {:pressed => 'instance_compare'} }

it 'calls comparemiq to compare Instances' do
expect(controller).to receive(:comparemiq)
controller.send(:button)
end
end

context 'adding new Cloud Subnet' do
let(:params) { {:pressed => 'cloud_subnet_new'} }

it 'redirects to action new' do
expect(controller).to receive(:javascript_redirect).with(:action => 'new')
controller.send(:button)
end
end
end

include_examples '#download_summary_pdf', :cloud_subnet_openstack

include_examples :shared_examples_for_cloud_subnet_controller, %w(openstack azure google amazon)
Expand Down
Loading