diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 380ceeb818f..00e59d86b9f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -431,12 +431,6 @@ def report_data @view.table = filter_parent_name_tenant(@view.table) end - # Foreman has some unassigned rows which needs to be added after view is fetched - if options && options[:unassigned_profile_row] && options[:unassigned_configuration_profile] - options[:unassigned_profile_row][:id] ||= options[:unassigned_profile_row]['manager_id'] - @view.table.data.push(options[:unassigned_profile_row]) - @targets_hash[options[:unassigned_profile_row]['id']] = options[:unassigned_configuration_profile] - end render :json => { :settings => settings, :data => view_to_hash(@view, true), @@ -1990,8 +1984,6 @@ def controller_for_common_methods "vm" when 'automation_manager' "automation_manager_provider" - when 'provider_foreman' - "configuration_manager_provider" when "generic_object_definition" # tagging for nested list on the generic object class "generic_object" when "ansible_playbook" diff --git a/app/controllers/application_controller/advanced_search.rb b/app/controllers/application_controller/advanced_search.rb index 682da67a9c6..7a966adab0c 100644 --- a/app/controllers/application_controller/advanced_search.rb +++ b/app/controllers/application_controller/advanced_search.rb @@ -185,10 +185,7 @@ def adv_search_redraw_listnav_and_main end def adv_search_redraw_left_div - if x_active_tree.to_s == "configuration_manager_cs_filter_tree" - build_accordions_and_trees - load_or_clear_adv_search - elsif @edit[:in_explorer] || %w[storage_tree configuration_scripts_tree svcs_tree].include?(x_active_tree.to_s) + if @edit[:in_explorer] || %w[storage_tree configuration_scripts_tree svcs_tree].include?(x_active_tree.to_s) tree_type = x_active_tree.to_s.sub(/_tree/, '').to_sym builder = TreeBuilder.class_for_type(tree_type) tree = builder.new(x_active_tree, @sb) diff --git a/app/controllers/application_controller/ci_processing.rb b/app/controllers/application_controller/ci_processing.rb index b16291c62cd..1300c54c85b 100644 --- a/app/controllers/application_controller/ci_processing.rb +++ b/app/controllers/application_controller/ci_processing.rb @@ -143,7 +143,7 @@ def process_elements(elements, klass, task, display_name = nil, order_field = ni end def explorer_controller? - %w[vm_cloud vm_infra vm_or_template infra_networking].include?(controller_name) + %w[vm_cloud vm_infra vm_or_template infra_networking automation_manager].include?(controller_name) end def process_element_destroy(element, klass, name) @@ -306,7 +306,7 @@ def manager_button_operation(method, display_name) def process_managers(managers, task) controller_class = request.parameters[:controller] provider_class = case controller_class - when 'provider_foreman' then ManageIQ::Providers::ConfigurationManager + when 'ems_configuration' then ManageIQ::Providers::ConfigurationManager when 'automation_manager' then ManageIQ::Providers::AutomationManager end diff --git a/app/controllers/application_controller/explorer.rb b/app/controllers/application_controller/explorer.rb index 4699050a03d..d327f738457 100644 --- a/app/controllers/application_controller/explorer.rb +++ b/app/controllers/application_controller/explorer.rb @@ -43,8 +43,7 @@ def x_history 'start' => :s1, 'stop' => :s1, 'suspend' => :s1, 'reset' => :s1, 'terminate' => :s1, 'pause' => :s1, 'shelve' => :s1, 'shelve_offload' => :s1, 'chargeback' => :s1, - 'foreman_pause' => :s1, 'foreman_resume' => :s1, 'manager_pause' => :s1, - 'manager_resume' => :s1, + 'manager_pause' => :s1, 'manager_resume' => :s1, # group 2 'clone' => :s2, 'compare' => :s2, 'drift' => :s2, @@ -55,6 +54,7 @@ def x_history 'tag' => :s2, 'timeline' => :s2, 'resize' => :s2, 'live_migrate' => :s2, 'attach' => :s2, 'detach' => :s2, 'evacuate' => :s2, 'service_dialog' => :s2, 'transform' => :s2, + 'manager_configuration_script_service_dialog' => :s2, 'transform_mass' => :s2, 'associate_floating_ip' => :s2, 'disassociate_floating_ip' => :s2, @@ -71,8 +71,7 @@ def x_history def x_button model, action = pressed2model_action(params[:pressed]) - - allowed_models = %w[common image instance vm miq_template provider automation storage configscript infra_networking automation_manager_provider configuration_manager_provider] + allowed_models = %w[common image instance vm miq_template provider automation storage infra_networking automation_manager_provider] raise ActionController::RoutingError, 'invalid button action' unless allowed_models.include?(model) @@ -100,7 +99,7 @@ def x_button send(method, Storage) when 'infra_networking' send(method, Switch) - when 'automation_manager_provider', 'configuration_manager_provider' + when 'automation_manager_provider' send(method) else send(method, VmOrTemplate) diff --git a/app/controllers/automation_manager_controller.rb b/app/controllers/automation_manager_controller.rb index 1ede45457be..bf770027e25 100644 --- a/app/controllers/automation_manager_controller.rb +++ b/app/controllers/automation_manager_controller.rb @@ -7,6 +7,7 @@ class AutomationManagerController < ApplicationController include Mixins::GenericSessionMixin include Mixins::ManagerControllerMixin + include Mixins::AutomationManagerControllerMixin include Mixins::ExplorerPresenterMixin include Mixins::EmsCommon::Core include Mixins::EmsCommon::PauseResume @@ -446,7 +447,7 @@ def valid_configuration_script_record?(configuration_script_record) configuration_script_record.try(:id) end - def configscript_service_dialog + def automation_manager_configuration_script_service_dialog assert_privileges("automation_manager_configuration_script_service_dialog") cs = ConfigurationScript.find_by(:id => params[:miq_grid_checks] || params[:id]) @edit = {:rec_id => cs.id} diff --git a/app/controllers/configuration_profile_controller.rb b/app/controllers/configuration_profile_controller.rb new file mode 100644 index 00000000000..e3ef471807e --- /dev/null +++ b/app/controllers/configuration_profile_controller.rb @@ -0,0 +1,52 @@ +class ConfigurationProfileController < ApplicationController + include Mixins::GenericListMixin + include Mixins::GenericShowMixin + include Mixins::GenericSessionMixin + include Mixins::BreadcrumbsMixin + + before_action :check_privileges + before_action :get_session_data + after_action :cleanup_action + after_action :set_session_data + + def self.display_methods + %w[configured_systems] + end + + def button + @edit = session[:edit] # Restore @edit for adv search box + params[:display] = @display if display_methods.include?(@display) # Were we displaying nested list + + # Handle Toolbar Policy Tag Button + @refresh_div = "main_div" # Default div for button.rjs to refresh + + if params[:pressed].starts_with?("configured_system_") # Handle buttons from sub-items screen + tag(ConfiguredSystem) if params[:pressed] == "configured_system_tag" + provision if params[:pressed] == "configured_system_provision" + end + + if @refresh_div == "main_div" && @lastaction == "show_list" + replace_gtl_main_div + else + render_flash unless performed? + end + end + + def show_list + opts = {:no_checkboxes => true} + process_show_list(opts) + end + + private + + def breadcrumbs_options + { + :breadcrumbs => [ + {:title => _("Configuration Profile")}, + {:title => _("Profiles"), :url => controller_url}, + ], + } + end + + menu_section :conf +end diff --git a/app/controllers/configured_system_controller.rb b/app/controllers/configured_system_controller.rb new file mode 100644 index 00000000000..a9e65b0d07b --- /dev/null +++ b/app/controllers/configured_system_controller.rb @@ -0,0 +1,50 @@ +class ConfiguredSystemController < ApplicationController + include Mixins::GenericListMixin + include Mixins::GenericShowMixin + include Mixins::GenericSessionMixin + include Mixins::BreadcrumbsMixin + include Mixins::ManagerControllerMixin + + before_action :check_privileges + before_action :get_session_data + after_action :cleanup_action + after_action :set_session_data + + def self.table_name + @table_name ||= "configured_system" + end + + def button + @edit = session[:edit] # Restore @edit for adv search box + + # Handle Toolbar Policy Tag Button + @refresh_div = "main_div" # Default div for button.rjs to refresh + model = self.class.model + tag(model) if params[:pressed] == "configured_system_tag" + provision if params[:pressed] == "configured_system_provision" + render_flash unless performed? + end + + def show_list + options = {:named_scope => :under_configuration_managers} + process_show_list(options) + end + + private + + def textual_group_list + [%i[properties relationships environment], %i[os tenancy tags]] + end + helper_method :textual_group_list + + def breadcrumbs_options + { + :breadcrumbs => [ + {:title => _("Configuration Management")}, + {:title => _("Configured Systems"), :url => controller_url}, + ], + } + end + + menu_section :conf +end diff --git a/app/controllers/ems_configuration_controller.rb b/app/controllers/ems_configuration_controller.rb new file mode 100644 index 00000000000..2f295665d1f --- /dev/null +++ b/app/controllers/ems_configuration_controller.rb @@ -0,0 +1,113 @@ +class EmsConfigurationController < ApplicationController + include Mixins::GenericListMixin + include Mixins::GenericShowMixin + include Mixins::GenericSessionMixin + include Mixins::BreadcrumbsMixin + include Mixins::GenericFormMixin + include Mixins::ManagerControllerMixin + include Mixins::FindRecord + + before_action :check_privileges + before_action :get_session_data + after_action :cleanup_action + after_action :set_session_data + + def self.model + ManageIQ::Providers::ConfigurationManager + end + + def self.table_name + @table_name ||= "ems_configuration" + end + + def self.display_methods + %w[configuration_profiles configured_systems] + end + + def button + @edit = session[:edit] # Restore @edit for adv search box + params[:display] = @display if display_methods.include?(@display) # Were we displaying nested list + + # Handle Toolbar Policy Tag Button + @refresh_div = "main_div" # Default div for button.rjs to refresh + model = self.class.model + tag(model) if params[:pressed] == "#{params[:controller]}_tag" + return if ["#{params[:controller]}_tag"].include?(params[:pressed]) && @flash_array.nil? # Tag screen showing + + if params[:pressed].starts_with?("configured_system_") # Handle buttons from sub-items screen + tag(ConfiguredSystem) if params[:pressed] == "configured_system_tag" + provision if params[:pressed] == "configured_system_provision" + end + + case params[:pressed] + when 'ems_configuration_edit_provider' + edit + when 'ems_configuration_add_provider' + new + when "ems_configuration_refresh_provider" + refresh + when "ems_configuration_delete_provider" + delete + end + + if single_delete_test + single_delete_redirect + elsif (params[:pressed].ends_with?("_edit_provider") || params[:pressed] == "ems_configuration_add_provider") && @flash_array.nil? + if @flash_array + show_list + replace_gtl_main_div + else + javascript_redirect(:action => @refresh_partial, :id => @redirect_id) + end + elsif @refresh_div == "main_div" && @lastaction == "show_list" + replace_gtl_main_div + else + render_flash unless performed? + end + end + + private + + def self.model_to_name(_provmodel) + Dictionary.gettext('ems_configuration', :type => :ui_title, :translate => false) + end + + def manager_prefix + "configuration_manager" + end + + def privilege_prefix + "ems_configuration" + end + + def refresh + assert_privileges("ems_configuration_refresh_provider") + manager_button_operation('refresh_ems', _('Refresh')) + end + + def concrete_model + ManageIQ::Providers::ConfigurationManager + end + + def provider_class + ManageIQ::Providers::Foreman::Provider + end + + def breadcrumbs_options + { + :breadcrumbs => [ + {:title => _("Configuration Management")}, + {:title => _("Providers"), :url => controller_url}, + ], + } + end + + def set_redirect_vars + @in_a_form = true + @redirect_controller = "ems_configuration" + @redirect_id = @provider_manager.id if @provider_manager.try(:id) + @refresh_partial = @provider_manager.try(:id) ? "edit" : "new" + end + + menu_section :conf +end diff --git a/app/controllers/mixins/automation_manager_controller_mixin.rb b/app/controllers/mixins/automation_manager_controller_mixin.rb new file mode 100644 index 00000000000..b0c689d1889 --- /dev/null +++ b/app/controllers/mixins/automation_manager_controller_mixin.rb @@ -0,0 +1,363 @@ +module Mixins + module AutomationManagerControllerMixin + extend ActiveSupport::Concern + + included do + include Mixins::GenericFormMixin + include Mixins::FindRecord + end + + def index + redirect_to(:action => 'explorer') + end + + def show_list + flash_to_session + redirect_to(:action => 'explorer') + end + + def explorer + @explorer = true + @lastaction = "explorer" + + # if AJAX request, replace right cell, and return + if request.xml_http_request? + replace_right_cell + return + end + + if params[:accordion] + self.x_active_tree = "#{params[:accordion]}_tree" + self.x_active_accord = params[:accordion] + end + if params[:button] + @miq_after_onload = "miqAjax('/#{controller_name}/x_button?pressed=#{params[:button]}');" + end + + build_accordions_and_trees + + params.instance_variable_get(:@parameters).merge!(session[:exp_parms]) if session[:exp_parms] # Grab any explorer parm overrides + session.delete(:exp_parms) + @in_a_form = false + + render :layout => "application" + end + + def identify_record(id, klass = self.class.model) + type, _id = parse_nodetype_and_id(x_node) + klass = TreeBuilder.get_model_for_prefix(type).constantize if type + record = super(id, klass) + record + end + + def tree_autoload + @view ||= session[:view] + super + end + + def change_tab + @sb[:active_tab] = params[:tab_id] + replace_right_cell + end + + def cs_edit_get_form_vars + copy_params_if_present(@edit[:new], params, %i[name description dialog_name]) + @edit[:new][:draft] = params[:draft] == "true" if params[:draft] + end + + def cs_form_field_changed + id = params[:id] + return unless load_edit("cs_edit__#{id}", "replace_cell__explorer") + + cs_edit_get_form_vars + render :update do |page| + page << javascript_prologue + page << javascript_hide("buttons_off") + page << javascript_show("buttons_on") + end + end + + def show(id = nil) + @flash_array = [] if params[:display] + @sb[:action] = nil + + @display = params[:display] || "main" + @lastaction = "show" + @record = if managed_group_record? + find_record(managed_group_kls, id || params[:id]) + else + find_record(ConfiguredSystem, id || params[:id]) + end + return if record_no_longer_exists?(@record) + + @explorer = true if request.xml_http_request? # Ajax request means in explorer + + @gtl_url = "/show" + end + + def tree_select + @lastaction = "explorer" + @flash_array = nil + self.x_active_tree = params[:tree] if params[:tree] + self.x_node = params[:id] + load_or_clear_adv_search + apply_node_search_text if x_active_tree == "#{manager_prefix}_providers_tree".to_sym + + if action_name == "reload" + replace_right_cell(:replace_trees => [x_active_accord]) + else + @sb[:active_tab] = if active_tab_configured_systems? + 'configured_systems' + else + 'summary' + end + replace_right_cell unless @edit && @edit[:adv_search_applied] && MiqExpression.quick_search?(@edit[:adv_search_applied][:exp]) + end + end + + def accordion_select + @lastaction = "explorer" + + @sb["#{controller_name.underscore}_search_text".to_sym] ||= {} + @sb["#{controller_name.underscore}_search_text".to_sym]["#{x_active_accord}_search_text"] = @search_text + + self.x_active_accord = params[:id].sub(/_accord$/, '') + self.x_active_tree = "#{x_active_accord}_tree" + + @search_text = @sb["#{controller_name.underscore}_search_text".to_sym]["#{x_active_accord}_search_text"] + + load_or_clear_adv_search + replace_right_cell(:replace_trees => [x_active_accord]) + end + + private + + def tag_action + (params[:action] == 'x_button' && %w[automation_manager_provider_tag configuration_manager_provider_tag].include?(params[:pressed])) || (params[:action] == 'tagging' && params[:pressed] == 'reset') + end + + def replace_right_cell(options = {}) + if tag_action + render_tagging_form + return + end + replace_trees = options[:replace_trees] + return if @in_a_form + + @explorer = true + @in_a_form = false + @sb[:action] = nil + trees = rebuild_trees(replace_trees) + + record_showing = leaf_record + presenter = rendering_objects + get_tagdata(@record) if @record.try(:taggings) + update_partials(record_showing, presenter) # replace_search_box is called whithin update_partials + handle_bottom_cell(presenter) + reload_trees_by_presenter(presenter, trees) + rebuild_toolbars(record_showing, presenter) + presenter[:provider_paused] = provider_paused?(@record) + presenter[:right_cell_text] = @right_cell_text + presenter[:osf_node] = x_node # Open, select, and focus on this node + + render :json => presenter.for_render + end + + def display_node(id, _mode) + if @record.nil? + self.x_node = "root" + get_node_info("root") + else + show_record(id) + model_string = ui_lookup(:model => @record.class.to_s) + @right_cell_text = _("%{model} \"%{name}\"") % {:name => @record.name, :model => model_string} + end + end + + def sync_form_to_instance + @provider.name = params[:name] + @provider.url = params[:url] + @provider.verify_ssl = params[:verify_ssl].eql?("on") || params[:verify_ssl].eql?("true") + @provider.zone = Zone.find_by(:name => params[:zone].to_s) if params[:zone] + end + + def provider_list(id, model) + return provider_node(id, model) if id + + options = {:model => model.to_s} + @right_cell_text = _("All %{title} Providers") % {:title => self.class.model_to_name(model)} + process_show_list(options) + end + + def configured_system_list(id, model) + return configured_system_node(id, model) if id + + if x_active_tree == :automation_manager_cs_filter_tree + options = {:model => model.to_s} + @right_cell_text = _("All %{title} Configured Systems") % {:title => self.class.model_to_name(model)} + process_show_list(options) + end + end + + def configured_system_node(id, model) + @record = @configured_system_record = find_record(ConfiguredSystem, id) + display_node(id, model) + end + + def display_adv_searchbox + !(@configured_system_record || @configuration_script_record || @in_a_form || group_summary_tab_selected?) + end + + def miq_search_node + options = {:model => model_from_active_tree(x_active_tree)} + if x_active_tree == :configuration_scripts_tree + options = {:model => "ConfigurationScript", + :gtl_dbname => "automation_manager_configuration_scripts"} + end + process_show_list(options) + @right_cell_text = x_active_tree == :configuration_scripts_tree ? _("All Ansible Tower Job Templates") : _("All Configured Systems") + end + + def render_form + presenter = rendering_objects + @in_a_form = true + @sb[:action] = params[:action] + presenter.update(:main_div, r[:partial => 'form', :locals => {:controller => controller_name}]) + update_title(presenter) + rebuild_toolbars(false, presenter) + handle_bottom_cell(presenter) + presenter.update(:breadcrumbs, r[:partial => 'layouts/breadcrumbs']) + + render :json => presenter.for_render + end + + def render_tagging_form + return if %w[cancel save].include?(params[:button]) + + @in_a_form = true + @right_cell_text = _("Edit Tags") + clear_flash_msg + presenter = rendering_objects + update_tagging_partials(presenter) + update_title(presenter) + rebuild_toolbars(false, presenter) + handle_bottom_cell(presenter) + presenter.update(:breadcrumbs, r[:partial => 'layouts/breadcrumbs']) + + render :json => presenter.for_render + end + + def render_service_dialog_form + @in_a_form = true + clear_flash_msg + presenter = rendering_objects + update_service_dialog_partials(presenter) + rebuild_toolbars(false, presenter) + handle_bottom_cell(presenter, true) + presenter[:right_cell_text] = @right_cell_text + + render :json => presenter.for_render + end + + def update_title(presenter) + @right_cell_text = + case action_name + when "new" then _("Add a new Provider") + when "edit" then _("Edit Provider") + end + presenter[:right_cell_text] = @right_cell_text + end + + def apply_node_search_text + setup_search_text_for_node + previous_nodetype = search_text_type(@sb["#{controller_name.underscore}_search_text".to_sym][:previous_node]) + current_nodetype = search_text_type(@sb["#{controller_name.underscore}_search_text".to_sym][:current_node]) + + @sb["#{controller_name.underscore}_search_text".to_sym]["#{previous_nodetype}_search_text"] = @search_text + @search_text = @sb["#{controller_name.underscore}_search_text".to_sym]["#{current_nodetype}_search_text"] + @sb["#{controller_name.underscore}_search_text".to_sym]["#{x_active_accord}_search_text"] = @search_text + end + + def setup_search_text_for_node + @sb["#{controller_name.underscore}_search_text".to_sym] ||= {} + @sb["#{controller_name.underscore}_search_text".to_sym][:current_node] ||= x_node + @sb["#{controller_name.underscore}_search_text".to_sym][:previous_node] = @sb["#{controller_name.underscore}_search_text".to_sym][:current_node] + @sb["#{controller_name.underscore}_search_text".to_sym][:current_node] = x_node + end + + def replace_search_box(presenter, locals = {}) + super(presenter, locals) + + presenter[:clear_gtl_list_grid] = @gtl_type && @gtl_type != 'list' + end + + def handle_bottom_cell(presenter, hide_form_buttons = false) + # Handle bottom cell + if @pages || @in_a_form + if (@pages && !@in_a_form) || hide_form_buttons + presenter.hide(:form_buttons_div) + elsif @in_a_form + presenter.remove_paging.show(:form_buttons_div) + end + presenter.show(:paging_div) + else + presenter.hide(:paging_div) + end + end + + def rebuild_toolbars(record_showing, presenter) + if group_summary_tab_selected? + center_tb = "blank_view_tb" + record_showing = true + end + + if !@in_a_form && !@sb[:action] + center_tb ||= center_toolbar_filename + c_tb = build_toolbar(center_tb) + v_tb = build_toolbar(record_showing ? "x_summary_view_tb" : "x_gtl_view_tb") + end + + presenter.reload_toolbars(:center => c_tb, :view => v_tb) + + presenter.set_visibility(c_tb.present? || v_tb.present?, :toolbar) + + presenter[:record_id] = @record.try(:id) + + # Hide/show searchbox depending on if a list is showing + presenter.set_visibility(display_adv_searchbox, :adv_searchbox_div) + presenter[:clear_search_toggle] = clear_search_status + + presenter.hide(:blocker_div) unless @edit && @edit[:adv_search_open] + presenter.hide(:quicksearchbox) + presenter[:hide_modal] = true + + presenter[:lock_sidebar] = @in_a_form + end + + def construct_edit_for_audit + @edit ||= {} + @edit[:current] = {:name => @provider.name, + :url => @provider.url, + :verify_ssl => @provider.verify_ssl} + @edit[:new] = {:name => params[:name], + :url => params[:url], + :verify_ssl => params[:verify_ssl]} + end + + def breadcrumb_name(_model) + "#{ui_lookup(:ui_title => 'foreman')} #{_('Provider')}" + end + + def tagging_explorer_controller? + @explorer + end + + def valid_configured_system_record?(configured_system_record) + configured_system_record.try(:id) + end + + def title + _("Providers") + end + end +end diff --git a/app/controllers/mixins/manager_controller_mixin.rb b/app/controllers/mixins/manager_controller_mixin.rb index 424511b4875..6a31819a498 100644 --- a/app/controllers/mixins/manager_controller_mixin.rb +++ b/app/controllers/mixins/manager_controller_mixin.rb @@ -7,15 +7,6 @@ module ManagerControllerMixin include Mixins::FindRecord end - def index - redirect_to(:action => 'explorer') - end - - def show_list - flash_to_session - redirect_to(:action => 'explorer') - end - def find_or_build_provider @provider = provider_class.new if params[:id] == "new" @provider ||= find_record(self.class.model, params[:id]).provider @@ -24,7 +15,6 @@ def find_or_build_provider def add_provider find_or_build_provider sync_form_to_instance - update_authentication_provider(:save) end @@ -56,7 +46,7 @@ def save_provider else add_flash(_("%{model} \"%{name}\" was updated") % {:model => model, :name => @provider.name}) end - replace_right_cell(:replace_trees => [x_active_accord]) + @explorer ? replace_right_cell(:replace_trees => [x_active_accord]) : javascript_redirect(:action => @lastaction, :id => params[:id]) else @provider.errors.each do |field, msg| @sb[:action] = nil @@ -70,11 +60,11 @@ def cancel_provider @in_a_form = false @sb[:action] = nil if params[:id] == "new" - add_flash(_("Add of Provider was cancelled by the user")) + flash_to_session(_("Add of Provider was cancelled by the user")) else - add_flash(_("Edit of Provider was cancelled by the user")) + flash_to_session(_("Edit of Provider was cancelled by the user")) end - replace_right_cell + @explorer ? replace_right_cell : javascript_redirect(:action => @lastaction, :id => params[:id]) end def authentication_validate @@ -94,126 +84,23 @@ def authentication_validate render_flash_json(msg, level) end - def explorer - @explorer = true - @lastaction = "explorer" - - # if AJAX request, replace right cell, and return - if request.xml_http_request? - replace_right_cell - return - end - - if params[:accordion] - self.x_active_tree = "#{params[:accordion]}_tree" - self.x_active_accord = params[:accordion] - end - - build_accordions_and_trees - - params.instance_variable_get(:@parameters).merge!(session[:exp_parms]) if session[:exp_parms] # Grab any explorer parm overrides - session.delete(:exp_parms) - @in_a_form = false - - render :layout => "application" - end - - def identify_record(id, klass = self.class.model) - type, _id = parse_nodetype_and_id(x_node) - klass = TreeBuilder.get_model_for_prefix(type).constantize if type - record = super(id, klass) - record - end - - def tree_autoload - @view ||= session[:view] - super - end - - def change_tab - @sb[:active_tab] = params[:tab_id] - replace_right_cell - end - - def cs_edit_get_form_vars - copy_params_if_present(@edit[:new], params, %i[name description dialog_name]) - @edit[:new][:draft] = params[:draft] == "true" if params[:draft] - end - - def cs_form_field_changed - id = params[:id] - return unless load_edit("cs_edit__#{id}", "replace_cell__explorer") - - cs_edit_get_form_vars - render :update do |page| - page << javascript_prologue - page << javascript_hide("buttons_off") - page << javascript_show("buttons_on") - end - end - - def show(id = nil) - @flash_array = [] if params[:display] - @sb[:action] = nil - - @display = params[:display] || "main" - @lastaction = "show" - @record = if managed_group_record? - find_record(managed_group_kls, id || params[:id]) - else - find_record(ConfiguredSystem, id || params[:id]) - end - return if record_no_longer_exists?(@record) - - @explorer = true if request.xml_http_request? # Ajax request means in explorer - - @gtl_url = "/show" - end - - def tree_select - @lastaction = "explorer" - @flash_array = nil - self.x_active_tree = params[:tree] if params[:tree] - self.x_node = params[:id] - load_or_clear_adv_search - apply_node_search_text if x_active_tree == "#{manager_prefix}_providers_tree".to_sym - - if action_name == "reload" - replace_right_cell(:replace_trees => [x_active_accord]) - else - @sb[:active_tab] = if active_tab_configured_systems? - 'configured_systems' - else - 'summary' - end - replace_right_cell unless @edit && @edit[:adv_search_applied] && MiqExpression.quick_search?(@edit[:adv_search_applied][:exp]) - end - end - - def accordion_select - @lastaction = "explorer" - - @sb["#{controller_name.underscore}_search_text".to_sym] ||= {} - @sb["#{controller_name.underscore}_search_text".to_sym]["#{x_active_accord}_search_text"] = @search_text - - self.x_active_accord = params[:id].sub(/_accord$/, '') - self.x_active_tree = "#{x_active_accord}_tree" - - @search_text = @sb["#{controller_name.underscore}_search_text".to_sym]["#{x_active_accord}_search_text"] - - load_or_clear_adv_search - replace_right_cell(:replace_trees => [x_active_accord]) - end - def new assert_privileges("#{privilege_prefix}_add_provider") + @explorer = true if explorer_controller? @provider_manager = concrete_model.new @server_zones = Zone.visible.in_my_region.order(Zone.arel_table[:name].lower).pluck(:description, :name) @sb[:action] = params[:action] - render_form + if @explorer + render_form + else + set_redirect_vars + end end def edit + assert_privileges("#{privilege_prefix}_edit_provider") + @explorer = true if explorer_controller? + @server_zones = Zone.visible.in_my_region.order('lower(description)').pluck(:description, :name) @server_zones = Zone.visible.in_my_region.order(Zone.arel_table[:name].lower).pluck(:description, :name) case params[:button] when "cancel" @@ -222,20 +109,23 @@ def edit add_provider save_provider else - assert_privileges("#{privilege_prefix}_edit_provider") manager_id = params[:miq_grid_checks] || params[:id] || find_checked_items[0] @provider_manager = find_record(concrete_model, manager_id) @providerdisplay_type = self.class.model_to_name(@provider_manager.type) @sb[:action] = params[:action] - render_form + if @explorer + render_form + else + set_redirect_vars + end end end def refresh + @explorer = true if explorer_controller? assert_privileges("#{privilege_prefix}_refresh_provider") - @explorer = true manager_button_operation('refresh_ems', _('Refresh')) - replace_right_cell + replace_right_cell if @explorer end def form_fields @@ -259,208 +149,6 @@ def form_fields private - def tag_action - (params[:action] == 'x_button' && %w[automation_manager_provider_tag configuration_manager_provider_tag].include?(params[:pressed])) || (params[:action] == 'tagging' && params[:pressed] == 'reset') - end - - def replace_right_cell(options = {}) - if tag_action - render_tagging_form - return - end - replace_trees = options[:replace_trees] - return if @in_a_form - - @explorer = true - @in_a_form = false - @sb[:action] = nil - trees = rebuild_trees(replace_trees) - - record_showing = leaf_record - presenter = rendering_objects - get_tagdata(@record) if @record.try(:taggings) - update_partials(record_showing, presenter) # replace_search_box is called whithin update_partials - handle_bottom_cell(presenter) - reload_trees_by_presenter(presenter, trees) - rebuild_toolbars(record_showing, presenter) - presenter[:provider_paused] = provider_paused?(@record) - presenter[:right_cell_text] = @right_cell_text - presenter[:osf_node] = x_node # Open, select, and focus on this node - - render :json => presenter.for_render - end - - def display_node(id, _mode) - if @record.nil? - self.x_node = "root" - get_node_info("root") - else - show_record(id) - model_string = ui_lookup(:model => @record.class.to_s) - @right_cell_text = _("%{model} \"%{name}\"") % {:name => @record.name, :model => model_string} - end - end - - def sync_form_to_instance - @provider.name = params[:name] - @provider.url = params[:url] - @provider.verify_ssl = params[:verify_ssl].eql?("on") || params[:verify_ssl].eql?("true") - @provider.zone = Zone.find_by(:name => params[:zone].to_s) if params[:zone] - end - - def provider_list(id, model) - return provider_node(id, model) if id - - options = {:model => model.to_s} - @right_cell_text = _("All %{title} Providers") % {:title => self.class.model_to_name(model)} - process_show_list(options) - end - - def configured_system_list(id, model) - return configured_system_node(id, model) if id - - if x_active_tree == :configuration_manager_cs_filter_tree || x_active_tree == :automation_manager_cs_filter_tree - options = {:model => model.to_s} - @right_cell_text = _("All %{title} Configured Systems") % {:title => self.class.model_to_name(model)} - process_show_list(options) - end - end - - def configured_system_node(id, model) - @record = @configured_system_record = find_record(ConfiguredSystem, id) - display_node(id, model) - end - - def display_adv_searchbox - !(@configured_system_record || @configuration_script_record || @in_a_form || group_summary_tab_selected?) - end - - def miq_search_node - options = {:model => model_from_active_tree(x_active_tree)} - if x_active_tree == :configuration_scripts_tree - options = {:model => "ConfigurationScript", - :gtl_dbname => "automation_manager_configuration_scripts"} - end - process_show_list(options) - @right_cell_text = x_active_tree == :configuration_scripts_tree ? _("All Ansible Tower Job Templates") : _("All Configured Systems") - end - - def render_form - presenter = rendering_objects - @in_a_form = true - @sb[:action] = params[:action] - presenter.update(:main_div, r[:partial => 'form', :locals => {:controller => controller_name}]) - update_title(presenter) - rebuild_toolbars(false, presenter) - handle_bottom_cell(presenter) - presenter.update(:breadcrumbs, r[:partial => 'layouts/breadcrumbs']) - - render :json => presenter.for_render - end - - def render_tagging_form - return if %w[cancel save].include?(params[:button]) - - @in_a_form = true - @right_cell_text = _("Edit Tags") - clear_flash_msg - presenter = rendering_objects - update_tagging_partials(presenter) - update_title(presenter) - rebuild_toolbars(false, presenter) - handle_bottom_cell(presenter) - presenter.update(:breadcrumbs, r[:partial => 'layouts/breadcrumbs']) - - render :json => presenter.for_render - end - - def render_service_dialog_form - @in_a_form = true - clear_flash_msg - presenter = rendering_objects - update_service_dialog_partials(presenter) - rebuild_toolbars(false, presenter) - handle_bottom_cell(presenter, true) - presenter[:right_cell_text] = @right_cell_text - - render :json => presenter.for_render - end - - def update_title(presenter) - @right_cell_text = - case action_name - when "new" then _("Add a new Provider") - when "edit" then _("Edit Provider") - end - presenter[:right_cell_text] = @right_cell_text - end - - def apply_node_search_text - setup_search_text_for_node - previous_nodetype = search_text_type(@sb["#{controller_name.underscore}_search_text".to_sym][:previous_node]) - current_nodetype = search_text_type(@sb["#{controller_name.underscore}_search_text".to_sym][:current_node]) - - @sb["#{controller_name.underscore}_search_text".to_sym]["#{previous_nodetype}_search_text"] = @search_text - @search_text = @sb["#{controller_name.underscore}_search_text".to_sym]["#{current_nodetype}_search_text"] - @sb["#{controller_name.underscore}_search_text".to_sym]["#{x_active_accord}_search_text"] = @search_text - end - - def setup_search_text_for_node - @sb["#{controller_name.underscore}_search_text".to_sym] ||= {} - @sb["#{controller_name.underscore}_search_text".to_sym][:current_node] ||= x_node - @sb["#{controller_name.underscore}_search_text".to_sym][:previous_node] = @sb["#{controller_name.underscore}_search_text".to_sym][:current_node] - @sb["#{controller_name.underscore}_search_text".to_sym][:current_node] = x_node - end - - def replace_search_box(presenter, locals = {}) - super(presenter, locals) - - presenter[:clear_gtl_list_grid] = @gtl_type && @gtl_type != 'list' - end - - def handle_bottom_cell(presenter, hide_form_buttons = false) - # Handle bottom cell - if @pages || @in_a_form - if (@pages && !@in_a_form) || hide_form_buttons - presenter.hide(:form_buttons_div) - elsif @in_a_form - presenter.remove_paging.show(:form_buttons_div) - end - presenter.show(:paging_div) - else - presenter.hide(:paging_div) - end - end - - def rebuild_toolbars(record_showing, presenter) - if group_summary_tab_selected? - center_tb = "blank_view_tb" - record_showing = true - end - - if !@in_a_form && !@sb[:action] - center_tb ||= center_toolbar_filename - c_tb = build_toolbar(center_tb) - v_tb = build_toolbar(record_showing ? "x_summary_view_tb" : "x_gtl_view_tb") - end - - presenter.reload_toolbars(:center => c_tb, :view => v_tb) - - presenter.set_visibility(c_tb.present? || v_tb.present?, :toolbar) - - presenter[:record_id] = @record.try(:id) - - # Hide/show searchbox depending on if a list is showing - presenter.set_visibility(display_adv_searchbox, :adv_searchbox_div) - presenter[:clear_search_toggle] = clear_search_status - - presenter.hide(:blocker_div) unless @edit && @edit[:adv_search_open] - presenter.hide(:quicksearchbox) - presenter[:hide_modal] = true - - presenter[:lock_sidebar] = @in_a_form - end - def construct_edit_for_audit @edit ||= {} @edit[:current] = {:name => @provider.name, @@ -471,20 +159,34 @@ def construct_edit_for_audit :verify_ssl => params[:verify_ssl]} end - def breadcrumb_name(_model) - "#{ui_lookup(:ui_title => 'foreman')} #{_('Provider')}" - end + def provision + assert_privileges("configured_system_provision") + provisioning_ids = find_records_with_rbac(ConfiguredSystem, checked_or_params).ids - def tagging_explorer_controller? - @explorer - end + unless ConfiguredSystem.provisionable?(provisioning_ids) + add_flash(_("Provisioning is not supported for at least one of the selected systems"), :error) + replace_right_cell if explorer_controller? + return + end - def valid_configured_system_record?(configured_system_record) - configured_system_record.try(:id) + if ConfiguredSystem.common_configuration_profiles_for_selected_configured_systems(provisioning_ids) + javascript_redirect(:controller => "miq_request", + :action => "prov_edit", + :prov_id => provisioning_ids, + :org_controller => "configured_system", + :escape => false) + else + render_flash(n_("No common configuration profiles available for the selected configured system", + "No common configuration profiles available for the selected configured systems", + provisioning_ids.size), :error) + end end - def title - _("Providers") + def sync_form_to_instance + @provider.name = params[:name] + @provider.url = params[:url] + @provider.verify_ssl = params[:verify_ssl].eql?("on") || params[:verify_ssl].eql?("true") + @provider.zone = Zone.find_by(:name => params[:zone].to_s) if params[:zone] end end end diff --git a/app/controllers/mixins/sandbox.rb b/app/controllers/mixins/sandbox.rb index 7a7f8e1793e..1bb08b9a454 100644 --- a/app/controllers/mixins/sandbox.rb +++ b/app/controllers/mixins/sandbox.rb @@ -49,8 +49,6 @@ def x_active_tree condition_tree containers_tree containers_filter_tree - configuration_manager_cs_filter_tree - configuration_manager_providers_tree customization_templates_tree datacenter_tree datastore_tree @@ -78,7 +76,6 @@ def x_active_tree protect_tree pxe_image_types_tree pxe_servers_tree - configuration_manager_providers_tree rbac_tree reports_tree roles_by_server_tree diff --git a/app/controllers/provider_foreman_controller.rb b/app/controllers/provider_foreman_controller.rb deleted file mode 100644 index f5776c62aae..00000000000 --- a/app/controllers/provider_foreman_controller.rb +++ /dev/null @@ -1,521 +0,0 @@ -class ProviderForemanController < ApplicationController - before_action :check_privileges - before_action :get_session_data - - after_action :cleanup_action - after_action :set_session_data - - include Mixins::GenericSessionMixin - include Mixins::ManagerControllerMixin - include Mixins::ExplorerPresenterMixin - include Mixins::EmsCommon::Core - include Mixins::EmsCommon::PauseResume - include Mixins::BreadcrumbsMixin - - def self.model - ManageIQ::Providers::ConfigurationManager - end - - def self.table_name - @table_name ||= "provider_foreman" - end - - def self.model_to_name(provmodel) - if provmodel.include?("ManageIQ::Providers::Foreman") - Dictionary.gettext('foreman', :type => :ui_title, :translate => false) - end - end - - def concrete_model - ManageIQ::Providers::ConfigurationManager - end - - def managed_group_kls - ConfigurationProfile - end - - def manager_prefix - 'configuration_manager' - end - - def privilege_prefix - 'provider_foreman' - end - - def provision - assert_privileges("provider_foreman_configured_system_provision") if x_active_accord == :configuration_manager_providers - assert_privileges("configured_system_provision") if x_active_accord == :configuration_manager_cs_filter - provisioning_ids = find_records_with_rbac(ConfiguredSystem, checked_or_params).ids - - unless ConfiguredSystem.provisionable?(provisioning_ids) - add_flash(_("Provisioning is not supported for at least one of the selected systems"), :error) - replace_right_cell - return - end - - if ConfiguredSystem.common_configuration_profiles_for_selected_configured_systems(provisioning_ids) - javascript_redirect(:controller => "miq_request", - :action => "prov_edit", - :prov_id => provisioning_ids, - :org_controller => "configured_system", - :escape => false) - else - add_flash(n_("No common configuration profiles available for the selected configured system", - "No common configuration profiles available for the selected configured systems", - provisioning_ids.size), :error) - replace_right_cell - end - end - - def tagging - @explorer = true - case x_active_accord - when :configuration_manager_providers - assert_privileges("configuration_manager_provider_tag") - tagging_edit(class_for_provider_node.to_s, false) - when :configuration_manager_cs_filter - assert_privileges("configured_system_tag") - tagging_edit('ConfiguredSystem', false) - end - render_tagging_form - end - - def load_or_clear_adv_search - adv_search_build(model_from_active_tree(x_active_tree)) - session[:edit] = @edit - @explorer = true - - if x_active_tree == :configuration_manager_cs_filter_tree && params[:button] != 'saveit' # Configured Systems accordion - @nodetype, id = parse_nodetype_and_id(valid_active_node(x_node)) - search_id = @nodetype == "root" ? 0 : id - search_id = @edit[@expkey][:selected][:id] if params[:button] == "save" - listnav_search_selected(search_id) if !params.key?(:search_text) && params[:action] != 'x_show' # Clear or set the adv search filter - if @edit[:adv_search_applied] && - MiqExpression.quick_search?(@edit[:adv_search_applied][:exp]) && - %w[reload tree_select].include?(params[:action]) - self.x_node = params[:id] - quick_search_show # User will input the value - end - elsif provider_active_tree? && x_node != 'root' # Providers accordion, without Advanced Search - listnav_search_selected(0) - end - end - - # Display provider through Tenant's textual summary - def show - @explorer = true - @lastaction = "explorer" - - build_accordions_and_trees - - params[:action] = 'tree-select' - provider_node(params[:id], ExtManagementSystem.find_by(:id => params[:id]).type) - - render :layout => "application" - end - - def x_show - tree_record unless unassigned_configuration_profile?(params[:id]) - - if request.format.js? && !@record - check_for_unassigned_configuration_profile - return - end - - generic_x_show - end - - def tree_record - @record = case x_active_tree - when :configuration_manager_providers_tree then configuration_manager_providers_tree_rec - when :configuration_manager_cs_filter_tree then configuration_manager_cs_filter_tree_rec - end - end - - def check_for_unassigned_configuration_profile - if action_name == "x_show" - unassigned_configuration_profile?(params[:id]) ? tree_select : tree_select_unprovisioned_configured_system - elsif action_name == "tree_select" - tree_select_unprovisioned_configured_system - else - redirect_to(:action => "explorer") - end - end - - def tree_select_unprovisioned_configured_system - if unassigned_configuration_profile?(x_node) - params[:id] = "cs-#{params[:id]}" - tree_select - else - redirect_to(:action => "explorer") - end - end - - def class_for_provider_node - nodes = x_node.split('-') - case nodes.first - when "root" then ManageIQ::Providers::ConfigurationManager - when "fr" then ConfigurationProfile - when "cp", "cs" then ConfiguredSystem - when "xx" then - case nodes.second - when "fr" then ManageIQ::Providers::ConfigurationManager - when "csf" then ConfiguredSystem - end - else - nodes.include?("unassigned") ? ConfiguredSystem : ManageIQ::Providers::ConfigurationManager - end - end - - def configuration_manager_providers_tree_rec - find_record(class_for_provider_node, params[:id]) - end - - def configuration_manager_cs_filter_tree_rec - nodes = x_node.split('-') - case nodes.first - when "root", "xx" then find_record(ConfiguredSystem, params[:id]) - when "ms" then find_record(ConfiguredSystem, params[:id]) - end - end - - def show_record(_id = nil) - @display = params[:display] || "main" unless pagination_or_gtl_request? - @lastaction = "show" - - if @record.nil? - add_flash(_("Error: Record no longer exists in the database"), :error) - if request.xml_http_request? && params[:id] # Is this an Ajax request clicking on a node that no longer exists? - @delete_node = params[:id] # Set node to be removed from the tree - end - return - end - - return unless @display == 'main' - @showtype = "main" - end - - def validate_before_save? - true - end - - def provider_active_tree? - x_active_tree == :configuration_manager_providers_tree - end - helper_method(:provider_active_tree?) - - private - - def provider_foreman_pause - pause_or_resume_emss(:pause => true) - end - - def provider_foreman_resume - pause_or_resume_emss(:resume => true) - end - - def textual_group_list - [%i[properties environment os], %i[tenancy tags]] - end - helper_method :textual_group_list - - def provider_class - ManageIQ::Providers::Foreman::Provider - end - - def features - [ - { - :role => "providers_accord", - :role_any => true, - :name => :configuration_manager_providers, - :title => _("Providers") - }, - { - :role => "configured_systems_filter_accord", - :role_any => true, - :name => :configuration_manager_cs_filter, - :title => _("Configured Systems") - } - ].map { |hsh| ApplicationController::Feature.new_with_hash(hsh) } - end - - def get_node_info(treenodeid, show_list = true) - @sb[:action] = nil - @nodetype, id = parse_nodetype_and_id(valid_active_node(treenodeid)) - @show_list = show_list - - model = TreeBuilder.get_model_for_prefix(@nodetype) - if model == "Hash" - model = TreeBuilder.get_model_for_prefix(id) - id = nil - end - - options = case model - when "ManageIQ::Providers::Foreman::ConfigurationManager" - provider_list(id, model) - when "ConfigurationProfile" - configuration_profile_node(id, model) - when "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem", "ConfiguredSystem" - configured_system_list(id, model) - when "MiqSearch" - miq_search_node - else - if unassigned_configuration_profile?(treenodeid) - configuration_profile_node(id, model) - else - default_node - end - end - @right_cell_text += _(" (Names with \"%{search_text}\")") % {:search_text => @search_text} if @search_text.present? - @right_cell_text += @edit[:adv_search_applied][:text] if x_tree && x_tree[:tree] == :configuration_manager_cs_filter_tree && @edit && @edit[:adv_search_applied] - - if @view && @pages - {:view => @view, :pages => @pages} - else - options - end - end - - def provider_node(id, model) - @record = provider = find_record(ExtManagementSystem, id) - if provider.nil? - self.x_node = "root" - get_node_info("root") - else - @no_checkboxes = true - case @record.type - when "ManageIQ::Providers::Foreman::ConfigurationManager" - options = {:model => "ConfigurationProfile", :match_via_descendants => 'ConfiguredSystem', :named_scope => [[:with_manager, provider.id]]} - @show_list ? process_show_list(options) : options.merge!(update_options) - unassigned_profiles = add_unassigned_configuration_profile_record(provider.id) - options.merge!(unassigned_profiles) unless unassigned_profiles.nil? - record_model = ui_lookup(:model => self.class.model_to_name(model || TreeBuilder.get_model_for_prefix(@nodetype))) - @right_cell_text = _("Configuration Profiles under %{record_model} Provider \"%{name}\"") % { - :name => provider.name, - :record_model => record_model - } - end - end - options - end - - def configuration_profile_node(id, model) - @record = @configuration_profile_record = model ? find_record(ConfigurationProfile, id) : ConfigurationProfile.new - if @configuration_profile_record.nil? - self.x_node = "root" - get_node_info("root") - else - options = {:model => "ConfiguredSystem"} - options[:named_scope] = if empty_configuration_profile_record?(@configuration_profile_record) - [[:with_manager, id], [:without_configuration_profile_id]] - else - [[:with_configuration_profile_id, @configuration_profile_record.id]] - end - @show_list ? process_show_list(options) : options.merge!(update_options) - record_model = ui_lookup(:model => model || TreeBuilder.get_model_for_prefix(@nodetype)) - if @sb[:active_tab] == 'configured_systems' - configuration_profile_right_cell_text(model) - else - @showtype = 'main' - @pages = nil - @right_cell_text = _("%{model} \"%{name}\"") % {:name => @configuration_profile_record.name, :model => record_model} - end - end - options - end - - def default_node - return unless x_node == "root" - if provider_active_tree? - options = {:model => "ManageIQ::Providers::ConfigurationManager"} - @show_list ? process_show_list(options) : options.merge!(update_options) - @right_cell_text = _("All Configuration Management Providers") - elsif x_active_tree == :configuration_manager_cs_filter_tree - options = {:model => "ConfiguredSystem"} - @show_list ? process_show_list(options) : options.merge!(update_options) - @right_cell_text = _("All Configured Systems") - end - options - end - - def rebuild_trees(replace_trees) - build_replaced_trees(replace_trees, %i[configuration_manager_providers configuration_manager_cs_filter]) - end - - def leaf_record - get_node_info(x_node) - @delete_node = params[:id] if @replace_trees - type, _id = parse_nodetype_and_id(x_node) - type && %w[ConfiguredSystem].include?(TreeBuilder.get_model_for_prefix(type)) - end - - def configuration_profile_record?(node = x_node) - type, _id = parse_nodetype_and_id(node) - type && %w[ConfigurationProfile].include?(TreeBuilder.get_model_for_prefix(type)) - end - - def foreman_provider_record?(node = x_node) - node = node.split("-").last if node.split("-").first == 'xx' - type, _id = node.split("-") - type && ["ManageIQ::Providers::Foreman::ConfigurationManager"].include?(TreeBuilder.get_model_for_prefix(type)) - end - - def provider_record?(node = x_node) - foreman_provider_record?(node) - end - - def search_text_type(node) - return "provider" if provider_record?(node) - return "configuration_profile" if configuration_profile_record?(node) - node - end - - def update_partials(record_showing, presenter) - if record_showing && valid_configured_system_record?(@configured_system_record) - get_tagdata(@record) - presenter.hide(:form_buttons_div) - presenter.update(:main_div, r[:partial => "layouts/textual_groups_generic"]) - elsif @in_a_form - partial_locals = {:controller => controller_name} - @right_cell_text = - if @sb[:action] == "#{controller_name}_add_provider" - _("Add a new Configuration Management Provider") - elsif @sb[:action] == "#{controller_name}_edit_provider" - _("Edit Provider") - end - partial = 'form' - presenter.update(:main_div, r[:partial => partial, :locals => partial_locals]) - elsif valid_configuration_profile_record?(@configuration_profile_record) - presenter.hide(:form_buttons_div) - presenter.update(:main_div, r[:partial => "configuration_profile", - :locals => {:controller => controller_name}]) - elsif ManageIQ::Providers::ConfigurationManager.none? && provider_active_tree? - presenter.update(:main_div, r[:partial => "layouts/empty", - :locals => {:add_message => _("Add a new Configuration Management Provider"), - :documentation => ::Settings.docs.configuration_provider}]) - else - presenter.update(:main_div, r[:partial => 'layouts/x_gtl']) - end - presenter.update(:breadcrumbs, r[:partial => 'layouts/breadcrumbs']) - - replace_search_box(presenter, :nameonly => provider_active_tree?) - end - - def group_summary_tab_selected? - @configuration_profile_record && @sb[:active_tab] == 'summary' - end - - def active_tab_configured_systems? - (%w[x_show x_search_by_name].include?(action_name) && configuration_profile_record?) || - unassigned_configuration_profile?(x_node) - end - - def unassigned_configuration_profile?(node) - _type, _pid, nodeinfo = parse_nodetype_and_id(node) - nodeinfo == "unassigned" - end - - def empty_configuration_profile_record?(configuration_profile_record) - configuration_profile_record.try(:id).nil? - end - - def valid_configuration_profile_record?(configuration_profile_record) - configuration_profile_record.try(:id) - end - - def list_row_id(row) - if row['name'] == _("Unassigned Profiles Group") && row['id'].nil? - "-#{row['manager_id']}-unassigned" - else - row['id'].to_s - end - end - - def configuration_profile_right_cell_text(model) - record_model = ui_lookup(:model => model || TreeBuilder.get_model_for_prefix(@nodetype)) - return if @sb[:active_tab] != 'configured_systems' - @right_cell_text = if valid_configuration_profile_record?(@configuration_profile_record) - _("Configured Systems under %{record_model} \"%{name}\"") % - {:record_model => record_model, - :name => @configuration_profile_record.name} - else - _("Configured Systems under Unassigned Profiles Group") - end - end - - def add_unassigned_configuration_profile_record(provider_id) - unprovisioned_configured_systems = - ConfiguredSystem.where(:manager_id => provider_id, :configuration_profile_id => nil).count - - return if unprovisioned_configured_systems.zero? - - unassigned_configuration_profile_desc = unassigned_configuration_profile_name = _("Unassigned Profiles Group") - unassigned_configuration_profile = ConfigurationProfile.new - unassigned_configuration_profile.manager_id = provider_id - unassigned_configuration_profile.name = unassigned_configuration_profile_name - unassigned_configuration_profile.description = unassigned_configuration_profile_desc - - unassigned_profile_row = { - 'x_show_id' => "-#{provider_id}-unassigned", - 'description' => unassigned_configuration_profile_desc, - 'total_configured_systems' => unprovisioned_configured_systems, - 'configuration_environment_name' => unassigned_configuration_profile.configuration_environment_name, - 'my_zone' => unassigned_configuration_profile.my_zone, - 'region_description' => unassigned_configuration_profile.region_description, - 'name' => unassigned_configuration_profile_name, - 'manager_id' => provider_id - } - - unless @view.table.kind_of?(Hash) - add_unassigned_configuration_profile_record_to_view(unassigned_profile_row, unassigned_configuration_profile) - end - { - :unassigned_profile_row => unassigned_profile_row, - :unassigned_configuration_profile => unassigned_configuration_profile - } - end - - def add_unassigned_configuration_profile_record_to_view(unassigned_profile_row, unassigned_configuration_profile) - @view.table.data.push(unassigned_profile_row) - @targets_hash[unassigned_profile_row['id']] = unassigned_configuration_profile - end - - def update_options(options = {}) - options ||= {} - options[:dbname] = case x_active_accord - when :configuration_manager_providers - case options[:model] - when 'ConfiguredSystem' - :cm_configured_systems - when 'ConfigurationProfile' - :cm_configuration_profiles - else - :cm_providers - end - when :configuration_manager_cs_filter - :cm_configured_systems - end - options[:gtl_dbname] = options[:dbname] - options - end - private :update_options - - def process_show_list(options = {}) - options.merge!(update_options(options)) - process_show_list_options(options) - super - end - - def breadcrumbs_options - { - :breadcrumbs => [ - {:title => _("Configuration")}, - {:title => _("Management")}, - ], - :record_title => :hostname, - } - end - - menu_section :conf -end diff --git a/app/controllers/restful_redirect_controller.rb b/app/controllers/restful_redirect_controller.rb index cc3a973f0c3..6eca4b84c39 100644 --- a/app/controllers/restful_redirect_controller.rb +++ b/app/controllers/restful_redirect_controller.rb @@ -6,8 +6,8 @@ def index when 'ExtManagementSystem' record = ExtManagementSystem.find_by(:id => params[:id]) if record - if %w[ManageIQ::Providers::ConfigurationManager].include?(record.type) || record.type.starts_with?('ManageIQ::Providers::Foreman') - redirect_to(:controller => 'provider_foreman', :action => 'show', :id => params[:id]) + if record.kind_of?(EmsConfiguration) + redirect_to(:controller => 'ems_configuration', :action => 'show', :id => params[:id]) elsif %w[ManageIQ::Providers::AnsibleTower::AutomationManager].include?(record.type) redirect_to(:controller => 'automation_manager', :action => 'show', :id => params[:id]) elsif %w[ManageIQ::Providers::EmbeddedAnsible::AutomationManager].include?(record.type) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a8463f44312..a3be2b998ea 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -218,8 +218,6 @@ def url_for_db(db, action = "show", item = nil) :show => @id) elsif @host && %w[Patch GuestApplication].include?(db) return url_for_only_path(:controller => "host", :action => @lastaction, :id => @host, :show => @id) - elsif %w[ConfiguredSystem ConfigurationProfile].include?(db) - return url_for_only_path(:controller => "provider_foreman", :action => @lastaction, :id => @record, :show => @id) else controller, action = db_to_controller(db, action) return url_for_only_path(:controller => controller, :action => action, :id => @id) @@ -281,14 +279,9 @@ def view_to_url(view, parent = nil) elsif ["Vm"].include?(view.db) && parent && request.parameters[:controller] != "vm" # this is to handle link to a vm in vm explorer from service explorer return url_for_only_path(:controller => "vm_or_template", :action => "show") + "/" - elsif %w[ConfigurationProfile].include?(view.db) && - request.parameters[:controller] == "provider_foreman" - return url_for_only_path(:action => action, :id => nil) + "/" elsif %w[ManageIQ::Providers::AutomationManager::InventoryRootGroup EmsFolder].include?(view.db) && request.parameters[:controller] == "automation_manager" return url_for_only_path(:action => action, :id => nil) + "/" - elsif %w[ConfiguredSystem].include?(view.db) && (request.parameters[:controller] == "provider_foreman" || request.parameters[:controller] == "automation_manager") - return url_for_only_path(:action => action, :id => nil) + "/" elsif %w[MiqWidget ConfigurationScript MiqReportResult].include?(view.db) && @@ -422,6 +415,7 @@ def db_to_controller(db, action = "show") controller = request.parameters[:controller] when "OrchestrationStackOutput", "OrchestrationStackParameter", "OrchestrationStackResource", "ManageIQ::Providers::CloudManager::OrchestrationStack", + "ManageIQ::Providers::ConfigurationManager", "ManageIQ::Providers::AnsibleTower::AutomationManager::Job", "ConfigurationScript" controller = request.parameters[:controller] when "ContainerVolume" @@ -755,7 +749,9 @@ def display_adv_search? cloud_volume_snapshot cloud_volume_type configuration_job + configuration_profile configuration_scripts + configured_system container container_build container_group @@ -769,6 +765,7 @@ def display_adv_search? container_template ems_cloud ems_cluster + ems_configuration ems_container ems_infra ems_middleware @@ -791,7 +788,6 @@ def display_adv_search? orchestration_stack persistent_volume physical_server - provider_foreman resource_pool retired security_group @@ -880,7 +876,7 @@ def adv_search_show_alias_checkbox? end def pressed2model_action(pressed) - pressed =~ /^(ems_cluster|miq_template|infra_networking|automation_manager_provider|configuration_manager_provider)_(.*)$/ ? [$1, $2] : pressed.split('_', 2) + pressed =~ /^(ems_cluster|miq_template|infra_networking|automation_manager_provider)_(.*)$/ ? [$1, $2] : pressed.split('_', 2) end def model_for_vm(record) @@ -911,11 +907,6 @@ def model_from_active_tree(tree) case tree when :automation_manager_cs_filter_tree "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem" - when :configuration_manager_cs_filter_tree - "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem" - when :configuration_manager_providers_tree - "ManageIQ::Providers::Foreman::ConfigurationManager" if x_node.include?("fr") - "ManageIQ::Providers::ConfigurationManager" if x_node == "root" when :instances_filter_tree "ManageIQ::Providers::CloudManager::Vm" when :images_filter_tree @@ -937,8 +928,6 @@ def configuration_manager_scripts_tree(tree) case tree when :automation_manager_cs_filter_tree, :automation_manager_providers_tree "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem" - when :configuration_manager_cs_filter_tree - "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem" when :configuration_scripts_tree "ConfigurationScript" end @@ -1072,7 +1061,9 @@ def pdf_page_size_style cloud_volume_type condition configuration_job + configuration_profile configuration_script_source + configured_system container container_build container_dashboard @@ -1089,6 +1080,7 @@ def pdf_page_size_style ems_block_storage ems_cloud ems_cluster + ems_configuration ems_container ems_infra ems_infra_dashboard @@ -1183,9 +1175,7 @@ def tree_with_advanced_search? %i[ automation_manager_providers_tree automation_manager_cs_filter_tree - configuration_manager_cs_filter_tree configuration_scripts_tree - configuration_manager_providers_tree images_tree images_filter_tree instances_tree diff --git a/app/helpers/application_helper/listnav.rb b/app/helpers/application_helper/listnav.rb index 5a3dd401212..155d535ee35 100644 --- a/app/helpers/application_helper/listnav.rb +++ b/app/helpers/application_helper/listnav.rb @@ -15,6 +15,8 @@ def render_listnav_filename cloud_volume_snapshot cloud_volume_type configuration_job + configuration_profile + configured_system container container_build container_group @@ -28,6 +30,7 @@ def render_listnav_filename container_template ems_cloud ems_cluster + ems_configuration ems_container ems_infra ems_middleware diff --git a/app/helpers/application_helper/page_layouts.rb b/app/helpers/application_helper/page_layouts.rb index f9c184ca3b0..4d0e34f7ad6 100644 --- a/app/helpers/application_helper/page_layouts.rb +++ b/app/helpers/application_helper/page_layouts.rb @@ -189,6 +189,7 @@ def show_adv_search? cloud_volume_snapshot cloud_volume_type configuration_job + configured_system container container_build container_group @@ -202,6 +203,7 @@ def show_adv_search? container_template ems_cloud ems_cluster + ems_configuration ems_container ems_infra ems_middleware @@ -224,7 +226,6 @@ def show_adv_search? orchestration_stack persistent_volume physical_server - provider_foreman resource_pool retired security_group diff --git a/app/helpers/application_helper/title.rb b/app/helpers/application_helper/title.rb index c351dffe02e..da7e589d744 100644 --- a/app/helpers/application_helper/title.rb +++ b/app/helpers/application_helper/title.rb @@ -75,8 +75,6 @@ def title_from_layout(layout) _("Reports") when "ops" _("Configuration") - when "provider_foreman" - _("Configuration Management") when "pxe" _("PXE") when "switch" diff --git a/app/helpers/application_helper/toolbar/configuration_script_center.rb b/app/helpers/application_helper/toolbar/configuration_script_center.rb index ef791f3229a..13186046f7a 100644 --- a/app/helpers/application_helper/toolbar/configuration_script_center.rb +++ b/app/helpers/application_helper/toolbar/configuration_script_center.rb @@ -1,13 +1,13 @@ class ApplicationHelper::Toolbar::ConfigurationScriptCenter < ApplicationHelper::Toolbar::Basic button_group('configuration_script_vmdb', [ select( - :configuration_script_vmdb_choice, + :automation_manager_configuration_script_vmdb_choice, nil, t = N_('Configuration'), t, :items => [ button( - :configscript_service_dialog, + :automation_manager_configuration_script_service_dialog, 'pficon pficon-add-circle-o fa-lg', t = N_('Create Service Dialog from this Template'), t), @@ -21,7 +21,7 @@ class ApplicationHelper::Toolbar::ConfigurationScriptCenter < ApplicationHelper: :enabled => true, :items => [ button( - :configuration_script_tag, + :automation_manager_configuration_script_tag, 'pficon pficon-edit fa-lg', N_('Edit Tags for this Template'), N_('Edit Tags'), diff --git a/app/helpers/application_helper/toolbar/configuration_scripts/policy_mixin.rb b/app/helpers/application_helper/toolbar/configuration_scripts/policy_mixin.rb index 0a7c7e440dd..7946d8e2b21 100644 --- a/app/helpers/application_helper/toolbar/configuration_scripts/policy_mixin.rb +++ b/app/helpers/application_helper/toolbar/configuration_scripts/policy_mixin.rb @@ -1,13 +1,13 @@ module ApplicationHelper::Toolbar::ConfigurationScripts::PolicyMixin def self.included(included_class) - included_class.button_group('provider_foreman_policy', - [included_class.select(:provider_foreman_policy_choice, + included_class.button_group('automation_manager_policy', + [included_class.select(:automation_manager_configuration_script_policy_choice, nil, t = N_('Policy'), t, :items => [ included_class.button( - :configuration_script_tag, + :automation_manager_configuration_script_tag, 'pficon pficon-edit fa-lg', N_('Edit Tags for this Job Template'), N_('Edit Tags'), diff --git a/app/helpers/application_helper/toolbar/configuration_scripts_center.rb b/app/helpers/application_helper/toolbar/configuration_scripts_center.rb index 216c4d9e9d9..6831bc428a4 100644 --- a/app/helpers/application_helper/toolbar/configuration_scripts_center.rb +++ b/app/helpers/application_helper/toolbar/configuration_scripts_center.rb @@ -1,13 +1,13 @@ class ApplicationHelper::Toolbar::ConfigurationScriptsCenter < ApplicationHelper::Toolbar::Basic button_group('configuration_script_vmdb', [ select( - :configuration_script_vmdb_choice, + :automation_manager_configuration_script_vmdb_choice, nil, t = N_('Configuration'), t, :items => [ button( - :configscript_service_dialog, + :automation_manager_configuration_script_service_dialog, 'pficon pficon-add-circle-o fa-lg', t = N_('Create Service Dialog from this Template'), t, diff --git a/app/helpers/application_helper/toolbar/configured_system/foreman/lifecycle_mixin.rb b/app/helpers/application_helper/toolbar/configured_system/foreman/lifecycle_mixin.rb deleted file mode 100644 index dc3b9a07f7a..00000000000 --- a/app/helpers/application_helper/toolbar/configured_system/foreman/lifecycle_mixin.rb +++ /dev/null @@ -1,24 +0,0 @@ -module ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::LifecycleMixin - def self.included(included_class) - included_class.button_group('provider_foreman_lifecycle', [ - included_class.select( - :provider_foreman_lifecycle_choice, - nil, - N_('Lifecycle'), - :enabled => true, - :items => [ - included_class.button( - :configured_system_provision, - 'pficon pficon-add-circle-o fa-lg', - N_('Provision Configured Systems'), - :url => "provision", - :url_parms => "main_div", - :send_checked => true, - :enabled => false, - :onwhen => "1+", - :klass => ApplicationHelper::Button::ConfiguredSystemProvision), - ] - ), - ]) - end -end diff --git a/app/helpers/application_helper/toolbar/configured_system/foreman/policy_mixin.rb b/app/helpers/application_helper/toolbar/configured_system/foreman/policy_mixin.rb deleted file mode 100644 index 278d75b464c..00000000000 --- a/app/helpers/application_helper/toolbar/configured_system/foreman/policy_mixin.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::PolicyMixin - def self.included(included_class) - included_class.button_group('provider_foreman_policy', [ - included_class.select( - :provider_foreman_policy_choice, - nil, - N_('Policy'), - :items => [ - included_class.button( - :configured_system_tag, - 'pficon pficon-edit fa-lg', - N_('Edit Tags for this Configured System'), - N_('Edit Tags'), - :url => "tagging", - :url_parms => "main_div", - :send_checked => true, - :enabled => false, - :onwhen => "1+"), - ] - ), - ]) - end -end diff --git a/app/helpers/application_helper/toolbar/configured_system_center.rb b/app/helpers/application_helper/toolbar/configured_system_center.rb new file mode 100644 index 00000000000..7e077d1876a --- /dev/null +++ b/app/helpers/application_helper/toolbar/configured_system_center.rb @@ -0,0 +1,17 @@ +class ApplicationHelper::Toolbar::ConfiguredSystemCenter < ApplicationHelper::Toolbar::Basic + button_group('configured_system_policy', [ + select( + :configured_system_policy_choice, + nil, + t = N_('Policy'), + t, + :items => [ + button( + :configured_system_tag, + 'pficon pficon-edit fa-lg', + N_('Edit Tags for this Configured System'), + N_('Edit Tags')), + ] + ), + ]) +end diff --git a/app/helpers/application_helper/toolbar/configured_systems_center.rb b/app/helpers/application_helper/toolbar/configured_systems_center.rb index 7c004171f5a..80515eb0728 100644 --- a/app/helpers/application_helper/toolbar/configured_systems_center.rb +++ b/app/helpers/application_helper/toolbar/configured_systems_center.rb @@ -1,4 +1,39 @@ class ApplicationHelper::Toolbar::ConfiguredSystemsCenter < ApplicationHelper::Toolbar::Basic - include ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::LifecycleMixin - include ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::PolicyMixin + button_group('configuration_manager_lifecycle', [ + select( + :configuration_manager_lifecycle_choice, + nil, + N_('Lifecycle'), + :enabled => true, + :items => [ + button( + :configured_system_provision, + 'pficon pficon-add-circle-o fa-lg', + N_('Provision Configured Systems'), + :url_parms => "main_div", + :send_checked => true, + :enabled => false, + :onwhen => "1+", + :klass => ApplicationHelper::Button::ConfiguredSystemProvision), + ] + ), + ]) + button_group('configuration_manager_policy', [ + select( + :configuration_manager_policy_choice, + nil, + N_('Policy'), + :items => [ + button( + :configured_system_tag, + 'pficon pficon-edit fa-lg', + N_('Edit Tags for this Configured System'), + N_('Edit Tags'), + :url_parms => "main_div", + :send_checked => true, + :enabled => false, + :onwhen => "1+"), + ] + ), + ]) end diff --git a/app/helpers/application_helper/toolbar/configuration_manager_provider_center.rb b/app/helpers/application_helper/toolbar/ems_configuration_center.rb similarity index 63% rename from app/helpers/application_helper/toolbar/configuration_manager_provider_center.rb rename to app/helpers/application_helper/toolbar/ems_configuration_center.rb index 4b99e921405..22a2222ad30 100644 --- a/app/helpers/application_helper/toolbar/configuration_manager_provider_center.rb +++ b/app/helpers/application_helper/toolbar/ems_configuration_center.rb @@ -1,29 +1,27 @@ -class ApplicationHelper::Toolbar::ConfigurationManagerProviderCenter < ApplicationHelper::Toolbar::Basic - button_group('provider_vmdb', [ +class ApplicationHelper::Toolbar::EmsConfigurationCenter < ApplicationHelper::Toolbar::Basic + button_group('ems_configuration_vmdb', [ select( - :provider_vmdb_choice, + :ems_configuration_vmdb_choice, nil, t = N_('Configuration'), t, :enabled => true, :items => [ button( - :provider_foreman_refresh_provider, + :ems_configuration_refresh_provider, 'fa fa-refresh fa-lg', N_('Refresh relationships for all items related to this Provider'), N_('Refresh Relationships and Power states'), - :url => "refresh", :confirm => N_("Refresh relationships for all items related to this Provider?"), :klass => ApplicationHelper::Button::EmsRefresh), separator, button( - :provider_foreman_edit_provider, + :ems_configuration_edit_provider, 'pficon pficon-edit fa-lg', t = N_('Edit this Provider'), - t, - :url => "edit"), + t), button( - :provider_foreman_delete_provider, + :ems_configuration_delete_provider, 'pficon pficon-delete fa-lg', t = N_('Remove this Provider from Inventory'), t, @@ -33,9 +31,24 @@ class ApplicationHelper::Toolbar::ConfigurationManagerProviderCenter < Applicati :modal_text => N_('Are you sure you want to delete the following Configuration Management Provider?'), :api_url => 'providers', :async_delete => true, - :tree_select => 'root', + :redirect_url => '/ems_configuration/show_list', :component_name => 'RemoveGenericItemModal'}}) ] ), ]) + button_group('ems_configuration_policy', [ + select( + :ems_configuration_policy_choice, + nil, + t = N_('Policy'), + t, + :items => [ + button( + :ems_configuration_tag, + 'pficon pficon-edit fa-lg', + N_('Edit Tags for this Configuration Manager'), + N_('Edit Tags')), + ] + ), + ]) end diff --git a/app/helpers/application_helper/toolbar/configuration_manager_providers_center.rb b/app/helpers/application_helper/toolbar/ems_configurations_center.rb similarity index 74% rename from app/helpers/application_helper/toolbar/configuration_manager_providers_center.rb rename to app/helpers/application_helper/toolbar/ems_configurations_center.rb index ca4143ed971..0ce725d40d7 100644 --- a/app/helpers/application_helper/toolbar/configuration_manager_providers_center.rb +++ b/app/helpers/application_helper/toolbar/ems_configurations_center.rb @@ -1,18 +1,17 @@ -class ApplicationHelper::Toolbar::ConfigurationManagerProvidersCenter < ApplicationHelper::Toolbar::Basic - button_group('provider_vmdb', [ +class ApplicationHelper::Toolbar::EmsConfigurationsCenter < ApplicationHelper::Toolbar::Basic + button_group('ems_configuration_vmdb', [ select( - :provider_vmdb_choice, + :ems_configuration_vmdb_choice, nil, t = N_('Configuration'), t, :enabled => true, :items => [ button( - :provider_foreman_refresh_provider, + :ems_configuration_refresh_provider, 'fa fa-refresh fa-lg', N_('Refresh relationships for all items related to the selected items'), N_('Refresh Relationships and Power states'), - :url => "refresh", :url_parms => "main_div", :send_checked => true, :confirm => N_("Refresh relationships for all items related to the selected items?"), @@ -20,24 +19,22 @@ class ApplicationHelper::Toolbar::ConfigurationManagerProvidersCenter < Applicat :onwhen => "1+"), separator, button( - :provider_foreman_add_provider, + :ems_configuration_add_provider, 'pficon pficon-add-circle-o fa-lg', t = N_('Add a new Provider'), t, - :enabled => true, - :url => "new"), + :enabled => true), button( - :provider_foreman_edit_provider, + :ems_configuration_edit_provider, 'pficon pficon-edit fa-lg', N_('Select a single item to edit'), N_('Edit Selected item'), - :url => "edit", :url_parms => "main_div", :send_checked => true, :enabled => false, :onwhen => "1"), button( - :provider_foreman_delete_provider, + :ems_configuration_delete_provider, 'pficon pficon-delete fa-lg', t = N_('Remove selected items from Inventory'), t, @@ -50,15 +47,15 @@ class ApplicationHelper::Toolbar::ConfigurationManagerProvidersCenter < Applicat :modal_text => N_('Are you sure you want to delete the following Configuration Management Providers?'), :api_url => 'providers', :async_delete => true, - :tree_select => 'root', + :redirect_url => '/ems_configuration/show_list', :component_name => 'RemoveGenericItemModal'}}), separator, ] ), ]) - button_group('configuration_manager_policy', [ + button_group('ems_configuration_policy', [ select( - :configuration_manager_policy_choice, + :ems_configuration_policy_choice, nil, t = N_('Policy'), t, @@ -66,9 +63,9 @@ class ApplicationHelper::Toolbar::ConfigurationManagerProvidersCenter < Applicat :onwhen => "1+", :items => [ button( - :configuration_manager_provider_tag, + :ems_configuration_tag, 'pficon pficon-edit fa-lg', - N_('Edit Tags for this Foreman Provider'), + N_('Edit Tags for this Configuration Manager Provider'), N_('Edit Tags'), :url_parms => "main_div", :send_checked => true, diff --git a/app/helpers/application_helper/toolbar/unassigned_profiles_group_center.rb b/app/helpers/application_helper/toolbar/unassigned_profiles_group_center.rb deleted file mode 100644 index 01c72109650..00000000000 --- a/app/helpers/application_helper/toolbar/unassigned_profiles_group_center.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ApplicationHelper::Toolbar::UnassignedProfilesGroupCenter < ApplicationHelper::Toolbar::Basic - include ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::LifecycleMixin - include ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::PolicyMixin -end diff --git a/app/helpers/application_helper/toolbar/x_configuration_script_center.rb b/app/helpers/application_helper/toolbar/x_configuration_script_center.rb deleted file mode 100644 index bdcf25453a8..00000000000 --- a/app/helpers/application_helper/toolbar/x_configuration_script_center.rb +++ /dev/null @@ -1,35 +0,0 @@ -class ApplicationHelper::Toolbar::XConfigurationScriptCenter < ApplicationHelper::Toolbar::Basic - button_group('configuration_script_vmdb', [ - select( - :configuration_script_vmdb_choice, - nil, - t = N_('Configuration'), - t, - :items => [ - button( - :configscript_service_dialog, - 'pficon pficon-add-circle-o fa-lg', - t = N_('Create Service Dialog from this Template'), - t), - ] - ), - select( - :automation_manager_policy_choice, - nil, - t = N_('Policy'), - t, - :enabled => true, - :items => [ - button( - :configuration_script_tag, - 'pficon pficon-edit fa-lg', - N_('Edit Tags for this Template'), - N_('Edit Tags'), - :url => "tagging", - :url_parms => "main_div", - :send_checked => true, - :enabled => true), - ] - ), - ]) -end diff --git a/app/helpers/application_helper/toolbar/x_configuration_scripts_center.rb b/app/helpers/application_helper/toolbar/x_configuration_scripts_center.rb deleted file mode 100644 index f8e9f479f6a..00000000000 --- a/app/helpers/application_helper/toolbar/x_configuration_scripts_center.rb +++ /dev/null @@ -1,22 +0,0 @@ -class ApplicationHelper::Toolbar::XConfigurationScriptsCenter < ApplicationHelper::Toolbar::Basic - button_group('configuration_script_vmdb', [ - select( - :configuration_script_vmdb_choice, - nil, - t = N_('Configuration'), - t, - :items => [ - button( - :configscript_service_dialog, - 'pficon pficon-add-circle-o fa-lg', - t = N_('Create Service Dialog from this Template'), - t, - :onwhen => '1', - :send_checked => true - ), - ] - ) - ]) - - include ApplicationHelper::Toolbar::ConfigurationScripts::PolicyMixin -end diff --git a/app/helpers/application_helper/toolbar/x_foreman_configured_system_center.rb b/app/helpers/application_helper/toolbar/x_foreman_configured_system_center.rb deleted file mode 100644 index 4bfbbb5dad4..00000000000 --- a/app/helpers/application_helper/toolbar/x_foreman_configured_system_center.rb +++ /dev/null @@ -1,40 +0,0 @@ -class ApplicationHelper::Toolbar::XForemanConfiguredSystemCenter < ApplicationHelper::Toolbar::Basic - button_group('record_summary', [ - select( - :provider_foreman_lifecycle_choice, - nil, - t = N_('Lifecycle'), - t, - :enabled => true, - :items => [ - button( - :provider_foreman_configured_system_provision, - 'pficon pficon-add-circle-o fa-lg', - t = N_('Provision Configured System'), - t, - :url => "provision", - :url_parms => "main_div", - :send_checked => true, - :enabled => true), - ] - ), - select( - :provider_foreman_policy_choice, - nil, - t = N_('Policy'), - t, - :enabled => true, - :items => [ - button( - :configured_system_tag, - 'pficon pficon-edit fa-lg', - N_('Edit Tags for this Configured System'), - N_('Edit Tags'), - :url => "tagging", - :url_parms => "main_div", - :send_checked => true, - :enabled => true), - ] - ), - ]) -end diff --git a/app/helpers/application_helper/toolbar/x_provider_foreman_foreman_configured_system_center.rb b/app/helpers/application_helper/toolbar/x_provider_foreman_foreman_configured_system_center.rb deleted file mode 100644 index 9bde578ef66..00000000000 --- a/app/helpers/application_helper/toolbar/x_provider_foreman_foreman_configured_system_center.rb +++ /dev/null @@ -1,40 +0,0 @@ -class ApplicationHelper::Toolbar::XProviderForemanForemanConfiguredSystemCenter < ApplicationHelper::Toolbar::Basic - button_group('record_summary', [ - select( - :provider_foreman_lifecycle_choice, - nil, - t = N_('Lifecycle'), - t, - :enabled => true, - :items => [ - button( - :provider_foreman_configured_system_provision, - 'pficon pficon-add-circle-o fa-lg', - t = N_('Provision Configured System'), - t, - :url => "provision", - :url_parms => "main_div", - :send_checked => true, - :enabled => true), - ] - ), - select( - :provider_foreman_policy_choice, - nil, - t = N_('Policy'), - t, - :enabled => true, - :items => [ - button( - :configured_system_tag, - 'pficon pficon-edit fa-lg', - N_('Edit Tags for this Configured System'), - N_('Edit Tags'), - :url => "tagging", - :url_parms => "main_div", - :send_checked => true, - :enabled => true), - ] - ), - ]) -end diff --git a/app/helpers/application_helper/toolbar_chooser.rb b/app/helpers/application_helper/toolbar_chooser.rb index cbb291f7163..28da4b56b5b 100644 --- a/app/helpers/application_helper/toolbar_chooser.rb +++ b/app/helpers/application_helper/toolbar_chooser.rb @@ -17,8 +17,6 @@ def x_view_toolbar_filename nil elsif @layout == 'report' @report ? "report_view_tb" : nil - elsif @layout == 'provider_foreman' - @showtype == 'main' ? "x_summary_view_tb" : "x_gtl_view_tb" elsif %w[vm_infra vm_cloud].include?(@layout) @showtype == 'main' ? 'x_summary_view_tb' : nil elsif @layout == 'automation_manager' @@ -90,8 +88,6 @@ def center_toolbar_name_vm_or_template def center_toolbar_filename_explorer if %w[vm_cloud vm_infra vm_or_template].include?(@layout) center_toolbar_name_vm_or_template - elsif @layout == "provider_foreman" && %i[configuration_manager_providers_tree configuration_manager_cs_filter_tree].include?(x_active_tree) - center_toolbar_filename_configuration_manager_providers elsif @layout == "automation_manager" center_toolbar_filename_automation_manager elsif x_active_tree == :ae_tree @@ -403,7 +399,7 @@ def center_toolbar_filename_storage def center_toolbar_filename_classic # Original non vmx view code follows # toolbar buttons on sub-screens - to_display = %w[availability_zones cloud_networks cloud_object_store_containers cloud_subnets + to_display = %w[availability_zones cloud_networks cloud_object_store_containers cloud_subnets configured_systems cloud_tenants cloud_volumes ems_clusters flavors floating_ips host_aggregates hosts network_ports network_routers orchestration_stacks resource_pools security_groups storages middleware_deployments @@ -455,6 +451,7 @@ def center_toolbar_filename_classic cloud_volume_snapshot cloud_volume_type configuration_job + configured_system container container_group container_node @@ -462,6 +459,7 @@ def center_toolbar_filename_classic persistent_volume ems_cloud ems_cluster + ems_configuration ems_container ems_middleware container_project @@ -528,16 +526,6 @@ def x_node_split x_node.split('-') end - def center_toolbar_filename_configuration_manager_providers - if x_active_tree == :configuration_manager_providers_tree - configuration_manager_providers_tree_center_tb(x_node_split) - elsif x_active_tree == :configuration_manager_cs_filter_tree - cs_filter_tree_center_tb(x_node_split) - elsif x_active_tree == :configuration_scripts_tree - configuration_scripts_tree_center_tb(x_node_split) - end - end - def center_toolbar_filename_automation_manager case x_active_tree when :automation_manager_providers_tree @@ -549,22 +537,6 @@ def center_toolbar_filename_automation_manager end end - def configuration_manager_providers_tree_center_tb(nodes) - case nodes.first - when "root" then "configuration_manager_providers_center_tb" - when "fr", "at" then "configuration_manager_provider_center_tb" - when "cp" then configuration_profile_center_tb - when "f" then inventory_group_center_tb - when "xx" then - case nodes.last - when "f" then "configured_systems_center_tb" - when "cp" then "unassigned_profiles_group_center_tb" - else "configuration_manager_providers_center_tb" - end - else unassigned_configuration_profile_node(nodes) - end - end - def cs_filter_tree_center_tb(nodes) case nodes.first when "root", "ms", "xx", "csa", "csf" then "configured_systems_center_tb" @@ -620,10 +592,6 @@ def inventory_group_center_tb end end - def unassigned_configuration_profile_node(nodes) - configuration_profile_center_tb if nodes[2] == "unassigned" - end - NO_GTL_VIEW_BUTTONS = %w[chargeback generic_object generic_object_definition @@ -634,7 +602,6 @@ def unassigned_configuration_profile_node(nodes) miq_policy miq_policy_rsop ops - provider_foreman pxe report].to_set.freeze diff --git a/app/helpers/configuration_profile_helper.rb b/app/helpers/configuration_profile_helper.rb new file mode 100644 index 00000000000..c8111d1757d --- /dev/null +++ b/app/helpers/configuration_profile_helper.rb @@ -0,0 +1,3 @@ +module ConfigurationProfileHelper + include_concern 'TextualSummary' +end diff --git a/app/helpers/configuration_profile_helper/textual_summary.rb b/app/helpers/configuration_profile_helper/textual_summary.rb new file mode 100644 index 00000000000..183855a900b --- /dev/null +++ b/app/helpers/configuration_profile_helper/textual_summary.rb @@ -0,0 +1,109 @@ +module ConfigurationProfileHelper::TextualSummary + def textual_configuration_profile_group_properties + %i[configuration_profile_name + configuration_profile_region + configuration_profile_zone] + end + + def textual_configuration_profile_name + {:label => _("Name"), :value => @record.name} + end + + def textual_configuration_profile_region + {:label => _("Region"), :value => @record.region_description} + end + + def textual_configuration_profile_zone + {:label => _("Zone"), :value => @record.my_zone} + end + + def textual_configuration_profile_group_environment + %i[configuration_profile_environment + configuration_profile_domain + configuration_profile_puppet_realm] + end + + def textual_configuration_profile_environment + {:label => _("Environment"), :value => @record.configuration_environment_name} + end + + def textual_configuration_profile_domain + {:label => _("Domain"), :value => @record.configuration_domain_name} + end + + def textual_configuration_profile_puppet_realm + {:label => _("Puppet Realm"), :value => @record.configuration_realm_name} + end + + def textual_configuration_profile_group_relationships + %i[configuration_manager + configured_systems] + end + + def textual_configuration_manager + configuration_manager = @record.configuration_manager + h = {:label => "Configuration Manager", :icon => "pficon pficon-configuration_manager", :value => (configuration_manager.nil? ? _("None") : configuration_manager.name)} + if configuration_manager && role_allows?(:feature => "ems_configuration_show") + h[:title] = _("Show this Configuration Profile's Configuration Manager") + h[:link] = url_for_only_path(:controller => 'ems_configuration', :action => 'show', :id => configuration_manager) + end + h + end + + def textual_configured_systems + num = @record.number_of(:configured_systems) + h = {:label => _('Configured Systems'), :icon => "pficon pficon-configured_system", :value => num} + if num.positive? && role_allows?(:feature => "configured_system_show_list") + h[:link] = url_for_only_path(:action => 'show', :id => @record, :display => 'configured_systems') + h[:title] = _("Show all Configured Systems") + end + h + end + + def textual_configuration_profile_group_os + %i[configuration_profile_compute_profile + configuration_profile_architecture + configuration_profile_os + configuration_profile_medium + configuration_profile_partition_table] + end + + def textual_configuration_profile_compute_profile + {:label => _("Compute Profile"), :value => @record.configuration_compute_profile_name} + end + + def textual_configuration_profile_architecture + {:label => _("Architecture"), :value => @record.configuration_architecture_name} + end + + def textual_configuration_profile_os + {:label => _("OS"), :value => @record.operating_system_flavor_name} + end + + def textual_configuration_profile_medium + {:label => _("Medium"), :value => @record.customization_script_medium_name} + end + + def textual_configuration_profile_partition_table + {:label => _("Partition Table"), :value => @record.customization_script_ptable_name} + end + + def textual_configuration_profile_group_tenancy + %i[configuration_profile_configuration_locations + configuration_profile_configuration_organizations] + end + + def textual_configuration_profile_configuration_locations + { + :label => _("Configuration Location"), + :value => @record.configuration_locations.collect(&:name).join(", ") + } + end + + def textual_configuration_profile_configuration_organizations + { + :label => _("Configuration Organization"), + :value => @record.configuration_organizations.collect(&:name).join(", ") + } + end +end diff --git a/app/helpers/configured_system_helper.rb b/app/helpers/configured_system_helper.rb new file mode 100644 index 00000000000..dcc9082750b --- /dev/null +++ b/app/helpers/configured_system_helper.rb @@ -0,0 +1,3 @@ +module ConfiguredSystemHelper + include_concern 'TextualSummary' +end diff --git a/app/helpers/configured_system_helper/textual_summary.rb b/app/helpers/configured_system_helper/textual_summary.rb new file mode 100644 index 00000000000..ddbebbe259e --- /dev/null +++ b/app/helpers/configured_system_helper/textual_summary.rb @@ -0,0 +1,128 @@ +module ConfiguredSystemHelper::TextualSummary + include TextualMixins::TextualGroupTags + + def textual_group_properties + TextualGroup.new( + _("Properties"), + %i[hostname ipmi_present ipaddress mac_address zone] + ) + end + + def textual_hostname + { + :label => _("Hostname"), + :icon => "ff ff-configured-system", + :value => @record.hostname, + } + end + + def textual_ipmi_present + {:label => _("IPMI Present"), :value => @record.ipmi_present} + end + + def textual_ipaddress + {:label => _("IP Address"), :value => @record.ipaddress} + end + + def textual_mac_address + {:label => _("Mac address"), :value => @record.mac_address} + end + + def textual_zone + {:label => _("Zone"), :value => @record.configuration_manager.my_zone} + end + + def textual_group_relationships + TextualGroup.new( + _("Relationships"), + %i[configuration_manager configuration_profile] + ) + end + + def textual_configuration_manager + configuration_manager = @record.configuration_manager + h = {:label => "Configuration Manager", :icon => "pficon pficon-configuration_manager", :value => (configuration_manager.nil? ? _("None") : configuration_manager.name)} + if configuration_manager && role_allows?(:feature => "ems_configuration_show") + h[:title] = _("Show this Configured System's Configuration Manager") + h[:link] = url_for_only_path(:controller => 'ems_configuration', :action => 'show', :id => configuration_manager) + end + h + end + + def textual_configuration_profile + configuration_profile = @record.configuration_profile + h = {:label => "Configuration Profile", :icon => "pficon pficon-configuration_profile", :value => (configuration_profile.nil? ? _("None") : configuration_profile.name)} + if configuration_profile && role_allows?(:feature => "configuration_profile_show") + h[:title] = _("Show this Configured System's Configuration Profile") + h[:link] = url_for_only_path(:controller => 'configuration_profile', :action => 'show', :id => configuration_profile) + end + h + end + + def textual_group_environment + TextualGroup.new( + _("Environment"), + %i[configuration_environment_name configuration_domain_name configuration_realm_name] + ) + end + + def textual_configuration_environment_name + {:label => _("Environment"), :value => @record.configuration_profile.try(:configuration_environment_name)} + end + + def textual_configuration_domain_name + {:label => _("Domain"), :value => @record.configuration_profile.try(:configuration_domain_name)} + end + + def textual_configuration_realm_name + {:label => _("Realm"), :value => @record.configuration_profile.try(:configuration_realm_name)} + end + + def textual_group_os + TextualGroup.new( + _("Operating System"), + %i[ + configuration_compute_profile_name configuration_architecture_name operating_system_flavor_name + customization_script_medium_name customization_script_ptable_name + ] + ) + end + + def textual_configuration_compute_profile_name + {:label => _("Compute Profile"), :value => @record.configuration_profile.try(:configuration_compute_profile_name)} + end + + def textual_configuration_architecture_name + {:label => _("Architecture"), :value => @record.configuration_profile.try(:configuration_architecture_name)} + end + + def textual_operating_system_flavor_name + {:label => _("OS Information"), :value => @record.configuration_profile.try(:operating_system_flavor_name)} + end + + def textual_customization_script_medium_name + {:label => _("Medium"), :value => @record.configuration_profile.try(:customization_script_medium_name)} + end + + def textual_customization_script_ptable_name + {:label => _("Partition Table"), :value => @record.configuration_profile.try(:customization_script_ptable_name)} + end + + def textual_group_tenancy + TextualGroup.new(_("Tenancy"), %i[configuration_locations_name configuration_organizations_name]) + end + + def textual_configuration_locations_name + { + :label => _("Configuration Location"), + :value => (@record.configuration_profile.try(:configuration_locations) || []).collect(&:name).join(", ") + } + end + + def textual_configuration_organizations_name + { + :label => _("Configuration Organization"), + :value => (@record.configuration_profile.try(:configuration_organizations) || []).collect(&:name).join(", ") + } + end +end diff --git a/app/helpers/ems_configuration_helper.rb b/app/helpers/ems_configuration_helper.rb new file mode 100644 index 00000000000..e2741bfee71 --- /dev/null +++ b/app/helpers/ems_configuration_helper.rb @@ -0,0 +1,3 @@ +module EmsConfigurationHelper + include_concern 'TextualSummary' +end diff --git a/app/helpers/ems_configuration_helper/textual_summary.rb b/app/helpers/ems_configuration_helper/textual_summary.rb new file mode 100644 index 00000000000..924ec0d1ce4 --- /dev/null +++ b/app/helpers/ems_configuration_helper/textual_summary.rb @@ -0,0 +1,75 @@ +module EmsConfigurationHelper::TextualSummary + include TextualMixins::TextualRefreshStatus + include TextualMixins::TextualZone + + def textual_group_properties + %i[description hostname ipaddress type port guid region] + end + + def textual_description + return nil if @record.try(:description).blank? + + {:label => _("Description"), :value => @record.description} + end + + def textual_region + return nil if @record.provider_region.blank? + + label_val = _('Region') + {:label => label_val, :value => @record.provider_region} + end + + def textual_hostname + @record.hostname + end + + def textual_ipaddress + return nil if @record.ipaddress.blank? + + {:label => _("Discovered IP Address"), :value => @record.ipaddress} + end + + def textual_type + {:label => _('Type'), :value => @record.emstype_description} + end + + def textual_port + @record.supports_port? ? {:label => _("API Port"), :value => @record.port} : nil + end + + def textual_guid + {:label => _("Management Engine GUID"), :value => @record.guid} + end + + def textual_group_relationships + %i[configuration_profiles configured_systems] + end + + def textual_configuration_profiles + num = @record.number_of(:configuration_profiles) + h = {:label => _('Configuration Profiles'), :icon => "pficon pficon-configuration_profile", :value => num} + if num.positive? && role_allows?(:feature => "configuration_profile_show_list") + h[:link] = url_for_only_path(:action => 'show', :id => @record, :display => 'configuration_profiles') + h[:title] = _("Show all Configuration Profiles") + end + h + end + + def textual_configured_systems + num = @record.number_of(:configured_systems) + h = {:label => _('Configured Systems'), :icon => "pficon pficon-configured_system", :value => num} + if num.positive? && role_allows?(:feature => "configured_system_show_list") + h[:link] = url_for_only_path(:action => 'show', :id => @record, :display => 'configured_systems') + h[:title] = _("Show all Configured Systems") + end + h + end + + def textual_group_status + textual_authentications(@record.authentication_for_summary) + %i[refresh_status refresh_date] + end + + def textual_group_tags + %i[tags] + end +end diff --git a/app/helpers/provider_configuration_manager_helper.rb b/app/helpers/provider_configuration_manager_helper.rb deleted file mode 100644 index 0181756e392..00000000000 --- a/app/helpers/provider_configuration_manager_helper.rb +++ /dev/null @@ -1,41 +0,0 @@ -module ProviderConfigurationManagerHelper - include TextualMixins::TextualGroupTags - - def textual_group_properties - %i[hostname - ipmi_present - ipaddress - mac_address - provider_name - zone] - end - - def textual_hostname - {:label => _("Hostname"), - :icon => "ff ff-configured-system", - :value => @record.hostname, } - end - - def textual_ipmi_present - {:label => _("IPMI Present"), :value => @record.ipmi_present} - end - - def textual_ipaddress - {:label => _("IP Address"), :value => @record.ipaddress} - end - - def textual_mac_address - {:label => _("Mac address"), :value => @record.mac_address} - end - - def textual_provider_name - {:label => _("Provider"), - :image => @record.configuration_manager.decorate.fileicon, - :value => @record.configuration_manager.try(:name), - :explorer => true} - end - - def textual_zone - {:label => _("Zone"), :value => @record.configuration_manager.my_zone} - end -end diff --git a/app/helpers/provider_foreman_helper.rb b/app/helpers/provider_foreman_helper.rb deleted file mode 100644 index c5a3c3f7d79..00000000000 --- a/app/helpers/provider_foreman_helper.rb +++ /dev/null @@ -1,296 +0,0 @@ -module ProviderForemanHelper - include TextualMixins::TextualGroupTags - - def textual_group_properties - TextualGroup.new( - _("Properties"), - %i[hostname ipmi_present ipaddress mac_address configuration_profile_desc provider_name zone] - ) - end - - def textual_hostname - { - :label => _("Hostname"), - :icon => "ff ff-configured-system", - :value => @record.hostname, - } - end - - def textual_ipmi_present - {:label => _("IPMI Present"), :value => @record.ipmi_present} - end - - def textual_ipaddress - {:label => _("IP Address"), :value => @record.ipaddress} - end - - def textual_mac_address - {:label => _("Mac address"), :value => @record.mac_address} - end - - def textual_configuration_profile_desc - h = { - :label => _("Configuration Profile Description"), - :value => @record.configuration_profile.try(:description), - :explorer => true - } - h[:icon] = "fa fa-list-ul" if @record.configuration_profile - h - end - - def textual_provider_name - { - :label => _("Provider"), - :image => @record.configuration_manager.decorate.fileicon, - :value => @record.configuration_manager.try(:name), - :explorer => true - } - end - - def textual_zone - {:label => _("Zone"), :value => @record.configuration_manager.my_zone} - end - - def textual_group_environment - TextualGroup.new( - _("Environment"), - %i[configuration_environment_name configuration_domain_name configuration_realm_name] - ) - end - - def textual_configuration_environment_name - {:label => _("Environment"), :value => @record.configuration_profile.try(:configuration_environment_name)} - end - - def textual_configuration_domain_name - {:label => _("Domain"), :value => @record.configuration_profile.try(:configuration_domain_name)} - end - - def textual_configuration_realm_name - {:label => _("Realm"), :value => @record.configuration_profile.try(:configuration_realm_name)} - end - - def textual_group_os - TextualGroup.new( - _("Operating System"), - %i[ - configuration_compute_profile_name configuration_architecture_name operating_system_flavor_name - customization_script_medium_name customization_script_ptable_name - ] - ) - end - - def textual_configuration_compute_profile_name - {:label => _("Compute Profile"), :value => @record.configuration_profile.try(:configuration_compute_profile_name)} - end - - def textual_configuration_architecture_name - {:label => _("Architecture"), :value => @record.configuration_profile.try(:configuration_architecture_name)} - end - - def textual_operating_system_flavor_name - {:label => _("OS Information"), :value => @record.configuration_profile.try(:operating_system_flavor_name)} - end - - def textual_customization_script_medium_name - {:label => _("Medium"), :value => @record.configuration_profile.try(:customization_script_medium_name)} - end - - def textual_customization_script_ptable_name - {:label => _("Partition Table"), :value => @record.configuration_profile.try(:customization_script_ptable_name)} - end - - def textual_group_tenancy - TextualGroup.new(_("Tenancy"), %i[configuration_locations_name configuration_organizations_name]) - end - - def textual_configuration_locations_name - { - :label => _("Configuration Location"), - :value => (@record.configuration_profile.try(:configuration_locations) || []).collect(&:name).join(", ") - } - end - - def textual_configuration_organizations_name - { - :label => _("Configuration Organization"), - :value => (@record.configuration_profile.try(:configuration_organizations) || []).collect(&:name).join(", ") - } - end - - def textual_configuration_profile_group_properties - %i[configuration_profile_name - configuration_profile_region - configuration_profile_zone] - end - - def textual_configuration_profile_name - {:label => _("Name"), :value => @record.name} - end - - def textual_configuration_profile_region - {:label => _("Region"), :value => @record.region_description} - end - - def textual_configuration_profile_zone - {:label => _("Zone"), :value => @record.my_zone} - end - - def textual_configuration_profile_group_environment - %i[configuration_profile_environment - configuration_profile_domain - configuration_profile_puppet_realm] - end - - def textual_configuration_profile_environment - {:label => _("Environment"), :value => @record.configuration_environment_name} - end - - def textual_configuration_profile_domain - {:label => _("Domain"), :value => @record.configuration_domain_name} - end - - def textual_configuration_profile_puppet_realm - {:label => _("Puppet Realm"), :value => @record.configuration_realm_name} - end - - def textual_configuration_profile_group_os - %i[configuration_profile_compute_profile - configuration_profile_architecture - configuration_profile_os - configuration_profile_medium - configuration_profile_partition_table] - end - - def textual_configuration_profile_compute_profile - {:label => _("Compute Profile"), :value => @record.configuration_compute_profile_name} - end - - def textual_configuration_profile_architecture - {:label => _("Architecture"), :value => @record.configuration_architecture_name} - end - - def textual_configuration_profile_os - {:label => _("OS"), :value => @record.operating_system_flavor_name} - end - - def textual_configuration_profile_medium - {:label => _("Medium"), :value => @record.customization_script_medium_name} - end - - def textual_configuration_profile_partition_table - {:label => _("Partition Table"), :value => @record.customization_script_ptable_name} - end - - def textual_configuration_profile_group_tenancy - %i[configuration_profile_configuration_locations - configuration_profile_configuration_organizations] - end - - def textual_configuration_profile_configuration_locations - { - :label => _("Configuration Location"), - :value => @record.configuration_locations.collect(&:name).join(", ") - } - end - - def textual_configuration_profile_configuration_organizations - { - :label => _("Configuration Organization"), - :value => @record.configuration_organizations.collect(&:name).join(", ") - } - end - - def textual_inventory_group_properties - %i[inventory_group_name - inventory_group_region] - end - - def textual_inventory_group_name - {:label => _("Name"), :value => @record.name} - end - - def textual_inventory_group_region - {:label => _("Region"), :value => @record.region_description} - end - - def textual_inventory_group_architecture - {:label => _("Architecture"), :value => @record.configuration_architecture_name} - end - - def textual__inventory_group_oos - {:label => _("OS"), :value => @record.operating_system_flavor_name} - end - - def textual_inventory_group_medium - {:label => _("Medium"), :value => @record.customization_script_medium_name} - end - - def textual_inventory_group_partition_table - {:label => _("Partition Table"), :value => @record.customization_script_ptable_name} - end - - def textual_configuration_script_group_properties - %i[configuration_script_name - configuration_script_region] - end - - def textual_configuration_script_name - {:label => _("Name"), :value => @record.name} - end - - def textual_configuration_script_region - {:label => _("Region"), :value => @record.region_description} - end - - def textual_configuration_script_variables - textual_variables(@record.variables) - end - - def textual_configuration_script_survey - textual_survey_group(@record.survey_spec['spec']) - end - - def textual_configuration_script_group_os - %i[configuration_script_medium - configuration_script_partition_table] - end - - def textual_survey_group(items) - return unless items - h = {:title => _("Surveys"), - :headers => [_('Question Name'), _('Question Description'), _('Variable'), - _('Type'), _('Min'), _('Max'), _('Default'), _('Required'), _('Choices')], - :col_order => %w[question_name question_description variable type min max default required choices]} - h[:value] = items.collect do |item| - { - :title => item['index'], - :question_name => item['question_name'], - :question_description => item['question_description'], - :variable => item['variable'], - :type => item['type'], - :min => item['min'], - :max => item['max'], - :default => item['default'], - :required => item['required'], - :choices => item['choices'] - } - end - h - end - - def textual_variables(vars) - return unless vars - h = {:label => _("Variables"), - :headers => [_('Name'), _('Value')], - :col_order => %w[name value]} - h[:value] = vars.collect do |item| - { - :name => item[0].to_s, - :value => item[1].to_s - } - end - h - end -end -# diff --git a/app/presenters/menu/default_menu.rb b/app/presenters/menu/default_menu.rb index 98567569f51..bb8d0a801d6 100644 --- a/app/presenters/menu/default_menu.rb +++ b/app/presenters/menu/default_menu.rb @@ -13,7 +13,9 @@ def compute_menu_section def configuration_menu_section Menu::Section.new(:conf, N_("Configuration"), 'fa fa-cog', [ - Menu::Item.new('provider_foreman', N_('Management'), 'provider_foreman_explorer', {:feature => 'provider_foreman_explorer', :any => true}, '/provider_foreman/explorer'), + Menu::Item.new('ems_configuration', N_('Providers'), 'ems_configuration', {:feature => 'ems_configuration_show_list'}, '/ems_configuration/show_list'), + Menu::Item.new('configuration_profile', N_('Profiles'), 'configuration_profile', {:feature => 'configuration_profile_show_list'}, '/configuration_profile/show_list'), + Menu::Item.new('configured_system', N_('Configured Systems'), 'configured_system', {:feature => 'configured_system_show_list'}, '/configured_system/show_list'), ]) end diff --git a/app/presenters/tree_builder.rb b/app/presenters/tree_builder.rb index 6cbb019e46a..0094671e229 100644 --- a/app/presenters/tree_builder.rb +++ b/app/presenters/tree_builder.rb @@ -476,10 +476,8 @@ def prefixed_title(prefix, title) "e" => "ExtManagementSystem", "ev" => "MiqEventDefinition", "c" => "EmsCluster", - "csf" => "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem", "csa" => "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem", "f" => "EmsFolder", - "fr" => "ManageIQ::Providers::Foreman::ConfigurationManager", "g" => "MiqGroup", "gd" => "GuestDevice", "god" => "GenericObjectDefinition", diff --git a/app/presenters/tree_builder_configuration_manager.rb b/app/presenters/tree_builder_configuration_manager.rb deleted file mode 100644 index f080b4db4d3..00000000000 --- a/app/presenters/tree_builder_configuration_manager.rb +++ /dev/null @@ -1,58 +0,0 @@ -class TreeBuilderConfigurationManager < TreeBuilder - has_kids_for ManageIQ::Providers::ConfigurationManager, [:x_get_tree_cmf_kids] - has_kids_for ConfigurationProfile, [:x_get_tree_cpf_kids] - - private - - def tree_init_options - {:lazy => true} - end - - def root_options - { - :text => t = _("All Configuration Manager Providers"), - :tooltip => t - } - end - - # Get root nodes count/array for explorer tree - def x_get_tree_roots - count_only_or_objects_filtered(false, ManageIQ::Providers::ConfigurationManager, "name") - end - - def node_by_tree_id(id) - # Creating empty record to show items under unassigned profiles group - super(id) || ConfigurationProfile.new - end - - def x_get_tree_cmf_kids(object, count_only) - assigned_configuration_profile_objs = - count_only_or_objects_filtered(count_only, - ConfigurationProfile.where(:manager_id => object[:id]), - "name") - unassigned_configuration_profile_objs = - fetch_unassigned_configuration_profile_objects(count_only, object[:id]) - - assigned_configuration_profile_objs + unassigned_configuration_profile_objs - end - - # Note: a lot of logic / queries to determine if should display menu item - def fetch_unassigned_configuration_profile_objects(count_only, configuration_manager_id) - unprovisioned_configured_systems = ConfiguredSystem.where(:configuration_profile_id => nil, - :manager_id => configuration_manager_id) - unprovisioned_configured_systems_filtered = Rbac.filtered(unprovisioned_configured_systems) - if unprovisioned_configured_systems_filtered.count > 0 - unassigned_id = "#{configuration_manager_id}-unassigned" - unassigned_configuration_profile = - [ConfigurationProfile.new(:name => "Unassigned Profiles Group|#{unassigned_id}", - :manager_id => configuration_manager_id)] - end - count_only_or_objects(count_only, unassigned_configuration_profile || []) - end - - def x_get_tree_cpf_kids(object, count_only) - configured_systems = ConfiguredSystem.where(:configuration_profile_id => object[:id], - :manager_id => object[:manager_id]) - count_only_or_objects_filtered(count_only, configured_systems, "hostname") - end -end diff --git a/app/presenters/tree_builder_configuration_manager_configured_systems.rb b/app/presenters/tree_builder_configuration_manager_configured_systems.rb deleted file mode 100644 index 57e75f4ea72..00000000000 --- a/app/presenters/tree_builder_configuration_manager_configured_systems.rb +++ /dev/null @@ -1,24 +0,0 @@ -class TreeBuilderConfigurationManagerConfiguredSystems < TreeBuilderConfiguredSystems - def initialize(*args) - @root_class = 'ConfiguredSystem' - super(*args) - end - - private - - def root_options - { - :text => t = _("All Configured Systems"), - :tooltip => t - } - end - - def configured_systems - { - :id => "csf", - :text => t = _("%{name} Configured Systems") % {:name => ui_lookup(:ui_title => 'foreman')}, - :icon => "pficon pficon-folder-close", - :tip => t - } - end -end diff --git a/app/presenters/tree_node/node.rb b/app/presenters/tree_node/node.rb index 87727796ad3..a61fb6dffe4 100644 --- a/app/presenters/tree_node/node.rb +++ b/app/presenters/tree_node/node.rb @@ -31,7 +31,6 @@ def key else base_class = @object.class.base_model.name # i.e. Vm or MiqTemplate base_class = "Datacenter" if base_class == "EmsFolder" && @object.kind_of?(::Datacenter) - base_class = "ManageIQ::Providers::Foreman::ConfigurationManager" if @object.kind_of?(ManageIQ::Providers::Foreman::ConfigurationManager) base_class = "ManageIQ::Providers::AnsibleTower::AutomationManager" if @object.kind_of?(ManageIQ::Providers::AnsibleTower::AutomationManager) prefix = TreeBuilder.get_prefix_for_model(base_class) cid = @object.id diff --git a/app/views/automation_manager/_form.html.haml b/app/views/automation_manager/_form.html.haml index 416736e8de7..bb7271e8b75 100644 --- a/app/views/automation_manager/_form.html.haml +++ b/app/views/automation_manager/_form.html.haml @@ -1,7 +1,2 @@ -= render :partial => 'configuration_manager/shared_form' += render :partial => 'configuration_manager/shared_form', :locals => {:url => "/automation_manager", :model => "automationManagerModel"} -:javascript - ManageIQ.angular.app.value('configurationManagerFormId', '#{@provider_manager.id || "new"}'); - ManageIQ.angular.app.value('url', '/automation_manager'); - ManageIQ.angular.app.value('modelName', 'automationManagerModel'); - miq_bootstrap('#form_div'); diff --git a/app/views/configuration_manager/_shared_form.html.haml b/app/views/configuration_manager/_shared_form.html.haml index 4fb1296dd7b..008202ec744 100644 --- a/app/views/configuration_manager/_shared_form.html.haml +++ b/app/views/configuration_manager/_shared_form.html.haml @@ -91,3 +91,10 @@ 'new-record' => 'vm.newRecord', 'check-authentication' => true} = render :partial => "layouts/angular/generic_form_buttons" + +:javascript + ManageIQ.angular.app.value('configurationManagerFormId', '#{@provider_manager.id || "new"}'); + ManageIQ.angular.app.value('url', '#{url}'); + ManageIQ.angular.app.value('modelName', '#{model}'); + miq_bootstrap('#form_div'); + diff --git a/app/views/configuration_profile/show.html.haml b/app/views/configuration_profile/show.html.haml new file mode 100644 index 00000000000..b46d7edacd9 --- /dev/null +++ b/app/views/configuration_profile/show.html.haml @@ -0,0 +1,13 @@ +- if %w[configured_systems].include?(@display) + = render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"} +- elsif @showtype == "main" + = render :partial => "layouts/flash_msg" + .row + .col-md-12.col-lg-6 + = react('GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_configuration_profile_group_properties), @record)) + = react('GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Relationships'), textual_configuration_profile_group_relationships), @record)) + = react('GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Environment'), textual_configuration_profile_group_environment), @record)) + .col-md-12.col-lg-6 + = react('GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Operating System'), textual_configuration_profile_group_os), @record)) + = react('GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Tenancy'), textual_configuration_profile_group_tenancy), @record)) + diff --git a/app/views/configuration_profile/show_list.html.haml b/app/views/configuration_profile/show_list.html.haml new file mode 100644 index 00000000000..039604839f2 --- /dev/null +++ b/app/views/configuration_profile/show_list.html.haml @@ -0,0 +1,2 @@ +#main_div + = render :partial => 'layouts/gtl' diff --git a/app/views/configured_system/show.html.haml b/app/views/configured_system/show.html.haml new file mode 100644 index 00000000000..7aa7a5d10da --- /dev/null +++ b/app/views/configured_system/show.html.haml @@ -0,0 +1 @@ += render :partial => "layouts/textual_groups_generic" diff --git a/app/views/configured_system/show_list.html.haml b/app/views/configured_system/show_list.html.haml new file mode 100644 index 00000000000..039604839f2 --- /dev/null +++ b/app/views/configured_system/show_list.html.haml @@ -0,0 +1,2 @@ +#main_div + = render :partial => 'layouts/gtl' diff --git a/app/views/ems_configuration/edit.html.haml b/app/views/ems_configuration/edit.html.haml new file mode 100644 index 00000000000..89b07e9e6bb --- /dev/null +++ b/app/views/ems_configuration/edit.html.haml @@ -0,0 +1,2 @@ += render :partial => 'configuration_manager/shared_form', :locals => {:url => "/ems_configuration", :model => "configurationManagerModel"} + diff --git a/app/views/ems_configuration/new.html.haml b/app/views/ems_configuration/new.html.haml new file mode 100644 index 00000000000..89b07e9e6bb --- /dev/null +++ b/app/views/ems_configuration/new.html.haml @@ -0,0 +1,2 @@ += render :partial => 'configuration_manager/shared_form', :locals => {:url => "/ems_configuration", :model => "configurationManagerModel"} + diff --git a/app/views/ems_configuration/show.html.haml b/app/views/ems_configuration/show.html.haml new file mode 100644 index 00000000000..241d616dc49 --- /dev/null +++ b/app/views/ems_configuration/show.html.haml @@ -0,0 +1,11 @@ +- if %w[configuration_profiles configured_systems].include?(@display) + = render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"} +- elsif @showtype == "main" + = render :partial => "layouts/flash_msg" + .row + .col-md-12.col-lg-6 + = react('GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_group_properties), @record)) + = react('GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Relationships'), textual_group_relationships), @record)) + .col-md-12.col-lg-6 + = react('GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Status'), textual_group_status), @record)) + = react('GenericGroupWrapper', expand_generic_group(TextualTags.new(_('Smart Management'), textual_group_tags), @record)) diff --git a/app/views/ems_configuration/show_list.html.haml b/app/views/ems_configuration/show_list.html.haml new file mode 100644 index 00000000000..11ff62f1d58 --- /dev/null +++ b/app/views/ems_configuration/show_list.html.haml @@ -0,0 +1,8 @@ +#main_div + - if EmsConfiguration.any? + = render :partial => 'layouts/gtl' + - else + = render :partial => 'layouts/empty', + :locals => {:add_message => _("Add a new Configuration Manager"), + :documentation => ::Settings.docs.configuration_provider} + diff --git a/app/views/layouts/listnav/_configuration_profile.html.haml b/app/views/layouts/listnav/_configuration_profile.html.haml new file mode 100644 index 00000000000..5ace24d72db --- /dev/null +++ b/app/views/layouts/listnav/_configuration_profile.html.haml @@ -0,0 +1,25 @@ +- if @record.try(:name) + #accordion.panel-group + = miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do + = render :partial => 'shared/quadicon', :locals => {:record => @record} + + = miq_accordion_panel(_("Properties"), false, "stack_prop") do + %ul.nav.nav-pills.nav-stacked + %li + = link_to_with_icon(_('Summary'), + {:action => 'show', :id => @record, :display => 'main'}, + :title => _("Show Summary")) + + = miq_accordion_panel(_("Relationships"), false, "stack_rel") do + %ul.nav.nav-pills.nav-stacked + - if role_allows?(:feature => "ems_configuration_show") && !@record.configuration_manager.nil? + %li + = link_to(_("Configuration Manager: %{name}") % {:name => @record.configuration_manager.name}, + {:controller => "ems_configuration", :action => 'show', :id => @record.configuration_manager.id}, + :title => _("Show parent Configuration Manager for this Configuration Profile")) + - if role_allows?(:feature => "configured_system_show_list") + = li_link(:count => @record.number_of(:configured_systems), + :record_id => @record.id, + :tables => 'configured_systems', + :display => 'configured_systems', + :action => 'show') diff --git a/app/views/layouts/listnav/_configured_system.html.haml b/app/views/layouts/listnav/_configured_system.html.haml new file mode 100644 index 00000000000..3564bb1ba8b --- /dev/null +++ b/app/views/layouts/listnav/_configured_system.html.haml @@ -0,0 +1,24 @@ +- if @record.try(:name) + #accordion.panel-group + = miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do + = render :partial => 'shared/quadicon', :locals => {:record => @record} + + = miq_accordion_panel(_("Properties"), false, "stack_prop") do + %ul.nav.nav-pills.nav-stacked + %li + = link_to_with_icon(_('Summary'), + {:action => 'show', :id => @record, :display => 'main'}, + :title => _("Show Summary")) + + = miq_accordion_panel(_("Relationships"), false, "stack_rel") do + %ul.nav.nav-pills.nav-stacked + - if role_allows?(:feature => "ems_configuration_show") && !@record.configuration_manager.nil? + %li + = link_to(_("Configuration Manager: %{name}") % {:name => @record.configuration_manager.name}, + {:controller => "ems_configuration", :action => 'show', :id => @record.configuration_manager.id}, + :title => _("Show parent Configuration Manager for this Configured System")) + - if role_allows?(:feature => "configuration_profile_show") && !@record.configuration_profile.nil? + %li + = link_to(_("Configuration Profile: %{name}") % {:name => @record.configuration_profile.name}, + {:controller => "configuration_profile", :action => 'show', :id => @record.configuration_profile.id}, + :title => _("Show parent Configuration Profile for this Configured System")) diff --git a/app/views/layouts/listnav/_ems_configuration.html.haml b/app/views/layouts/listnav/_ems_configuration.html.haml new file mode 100644 index 00000000000..b393c097713 --- /dev/null +++ b/app/views/layouts/listnav/_ems_configuration.html.haml @@ -0,0 +1,26 @@ +- if @record.try(:name) + #accordion.panel-group + = miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do + = render :partial => 'shared/quadicon', :locals => {:record => @record} + + = miq_accordion_panel(_("Properties"), false, "stack_prop") do + %ul.nav.nav-pills.nav-stacked + %li + = link_to_with_icon(_('Summary'), + {:action => 'show', :id => @record, :display => 'main'}, + :title => _("Show Summary")) + + = miq_accordion_panel(_("Relationships"), false, "stack_rel") do + %ul.nav.nav-pills.nav-stacked + - if role_allows?(:feature => "configuration_profile_show_list") + = li_link(:count => @record.number_of(:configuration_profiles), + :record_id => @record.id, + :tables => 'configuration_profiles', + :display => 'configuration_profiles', + :action => 'show') + - if role_allows?(:feature => "configured_system_show_list") + = li_link(:count => @record.number_of(:configured_systems), + :record_id => @record.id, + :tables => 'configured_systems', + :display => 'configured_systems', + :action => 'show') diff --git a/app/views/provider_foreman/_configscript_service_dialog.html.haml b/app/views/provider_foreman/_configscript_service_dialog.html.haml deleted file mode 100644 index 26693d8e130..00000000000 --- a/app/views/provider_foreman/_configscript_service_dialog.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -#form_div - #basic_info_div - = render :partial => "layouts/flash_msg" - - url = url_for_only_path(:action => "cs_form_field_changed", :id => @edit[:rec_id]) - .form-horizontal - .form-group - %label.col-md-2.control-label - = _('Service Dialog Name') - .col-md-8 - = text_field_tag("dialog_name", - "", - :autocomplete => 'off', - :diabled => false, - :class => "form-control", - :maxlength => 255, - "data-miq_observe" => {:interval => '.5', - :url => url}.to_json) diff --git a/app/views/provider_foreman/_configuration_profile.html.haml b/app/views/provider_foreman/_configuration_profile.html.haml deleted file mode 100644 index 1d9b5f80f09..00000000000 --- a/app/views/provider_foreman/_configuration_profile.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -#configuration_profile_form_tabs - %ul.nav.nav-tabs - = miq_tab_header('summary', @sb[:active_tab]) do - = _("Summary") - = miq_tab_header('configured_systems', @sb[:active_tab]) do - = _("Configured Systems") - .tab-content - = miq_tab_content('configured_systems', @sb[:active_tab]) do - - if @sb[:active_tab] == "configured_systems" - = render :partial => "layouts/x_gtl" - :javascript - ManageIQ.afterOnload = "if (miqDomElementExists('adv_searchbox_div')) $('#adv_searchbox_div').show();" - = miq_tab_content('summary', @sb[:active_tab]) do - - if @sb[:active_tab] == "summary" - = render :partial => "main_configuration_profile" - -:javascript - miq_tabs_init('#configuration_profile_form_tabs', '/provider_foreman/change_tab'); diff --git a/app/views/provider_foreman/_configuration_script.html.haml b/app/views/provider_foreman/_configuration_script.html.haml deleted file mode 100644 index 1e2e8495ee2..00000000000 --- a/app/views/provider_foreman/_configuration_script.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -= render :partial => "layouts/flash_msg" -.row - .col-md-12.col-lg-8 - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_configuration_script_group_properties), @record) - .col-md-12.col-lg-8 - = react 'TableListViewWrapper', TextualListview.data(textual_configuration_script_variables) - .col-md-12.col-lg-8 - - if @record.survey_spec['spec'] - = react 'TableListViewWrapper', TextualListview.data(textual_configuration_script_survey) diff --git a/app/views/provider_foreman/_form.html.haml b/app/views/provider_foreman/_form.html.haml deleted file mode 100644 index 0841f0eb0fb..00000000000 --- a/app/views/provider_foreman/_form.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -= render :partial => 'configuration_manager/shared_form' - -:javascript - ManageIQ.angular.app.value('configurationManagerFormId', '#{@provider_manager.id || "new"}'); - ManageIQ.angular.app.value('url', '/provider_foreman'); - ManageIQ.angular.app.value('modelName', 'providerForemanModel'); - miq_bootstrap('#form_div'); diff --git a/app/views/provider_foreman/_inventory_group.html.haml b/app/views/provider_foreman/_inventory_group.html.haml deleted file mode 100644 index 83c872f7c44..00000000000 --- a/app/views/provider_foreman/_inventory_group.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -#inventory_group_form_tabs - %ul.nav.nav-tabs - = miq_tab_header('summary', @sb[:active_tab]) do - = _("Summary") - = miq_tab_header('configured_systems', @sb[:active_tab]) do - = _("Configured Systems") - .tab-content - = miq_tab_content('configured_systems', @sb[:active_tab]) do - - if @sb[:active_tab] == "configured_systems" - = render :partial => "layouts/x_gtl" - :javascript - ManageIQ.afterOnload = "if (miqDomElementExists('adv_searchbox_div')) $('#adv_searchbox_div').show();" - = miq_tab_content('summary', @sb[:active_tab]) do - - if @sb[:active_tab] == "summary" - = render :partial => "main_inventory_group" - -:javascript - miq_tabs_init('#inventory_group_form_tabs', '/provider_foreman/change_tab'); diff --git a/app/views/provider_foreman/_main_configuration_profile.html.haml b/app/views/provider_foreman/_main_configuration_profile.html.haml deleted file mode 100644 index cf142cc560d..00000000000 --- a/app/views/provider_foreman/_main_configuration_profile.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -= render :partial => "layouts/flash_msg" -.row - .col-md-12.col-lg-6 - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_configuration_profile_group_properties), @record) - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Environment'), textual_configuration_profile_group_environment), @record) - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Operating System'), textual_configuration_profile_group_os), @record) - .col-md-12.col-lg-6 - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Tenancy'), textual_configuration_profile_group_tenancy), @record) diff --git a/app/views/provider_foreman/_main_inventory_group.html.haml b/app/views/provider_foreman/_main_inventory_group.html.haml deleted file mode 100644 index a30e4dd859b..00000000000 --- a/app/views/provider_foreman/_main_inventory_group.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -= render :partial => "layouts/flash_msg" -.row - .col-md-12.col-lg-6 - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_inventory_group_properties), @record) diff --git a/app/views/provider_foreman/explorer.html.haml b/app/views/provider_foreman/explorer.html.haml deleted file mode 100644 index 429d68ecb50..00000000000 --- a/app/views/provider_foreman/explorer.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -- content_for :search do - = render(:partial => "layouts/x_adv_searchbox", :locals => {:nameonly => controller.provider_active_tree?}) - = render(:partial => 'layouts/quick_search') - -= render(:partial => 'shared/provider_paused', :locals => {:record => @record}) - --# These are the initial divs that will go inside center_cell_div -- if @configuration_profile_record - #main_div - - @pages = nil if @sb[:active_tab] == 'summary' - = render(:partial => 'provider_foreman/configuration_profile') -- elsif @inventory_group_record - #main_div - - @pages = nil if @sb[:active_tab] == 'summary' - = render(:partial => 'provider_foreman/inventory_group') - -- elsif @configured_system_record - #main_div - = render :partial => "layouts/textual_groups_generic" -- elsif @configuration_script_record - #main_div - = render(:partial => 'provider_foreman/configuration_script', :locals => {:controller => "provider_foreman"}) -- else - #main_div - - if ManageIQ::Providers::ConfigurationManager.none? && provider_active_tree? - = render :partial => 'layouts/empty', - :locals => {:add_message => _("Add a new Configuration Management Provider"), - :documentation => ::Settings.docs.configuration_provider} - - else - = render(:partial => 'layouts/x_gtl') - - diff --git a/app/views/provider_foreman/show.html.haml b/app/views/provider_foreman/show.html.haml deleted file mode 100644 index 1cbcf0e501d..00000000000 --- a/app/views/provider_foreman/show.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -= render(:partial => 'shared/provider_paused', :locals => {:record => @record}) - -#main_div - = render(:partial => 'layouts/x_gtl') diff --git a/config/routes.rb b/config/routes.rb index 1f5c0d01a94..bb266341733 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2662,27 +2662,26 @@ dialog_runner_post }, - :provider_foreman => { - :get => %w( + :ems_configuration => { + :get => %w[ + button download_data download_summary_pdf - explorer + edit form_fields + new show show_list tagging_edit - ), - :post => %w( - accordion_select + ], + :post => %w[ authentication_validate button change_tab delete edit - explorer form_field_changed new - provision quick_search refresh reload @@ -2691,16 +2690,57 @@ tagging tagging_edit tag_edit_form_field_changed - tree_autoload - tree_select - cs_form_field_changed - users wait_for_task - x_button - ) + - adv_search_post + - exp_post + - x_post + ] + + adv_search_post + + exp_post + + save_post + }, + + :configuration_profile => { + :get => %w[ + download_data + download_summary_pdf + show + show_list + tagging_edit + ], + :post => %w[ + button + quick_search + reload + show + show_list + tagging_edit + tag_edit_form_field_changed + ] + }, + + :configured_system => { + :get => %w[ + download_data + download_summary_pdf + show + show_list + tagging_edit + ], + :post => %w[ + button + new + provision + quick_search + reload + show + show_list + tagging + tagging_edit + tag_edit_form_field_changed + wait_for_task + ] + + adv_search_post + + dialog_runner_post + + exp_post + + save_post }, :pxe => { diff --git a/product/views/ConfiguredSystem.yaml b/product/views/ConfiguredSystem.yaml index c9cd6d3d7e6..61662f12e89 100644 --- a/product/views/ConfiguredSystem.yaml +++ b/product/views/ConfiguredSystem.yaml @@ -37,6 +37,7 @@ col_order: - build_state - my_zone - configuration_environment_name +- configuration_profile_name # Column titles, in order headers: diff --git a/product/views/ManageIQ_Providers_ConfigurationManager.yaml b/product/views/ManageIQ_Providers_ConfigurationManager.yaml index b48a21449dc..7919654548a 100644 --- a/product/views/ManageIQ_Providers_ConfigurationManager.yaml +++ b/product/views/ManageIQ_Providers_ConfigurationManager.yaml @@ -12,7 +12,7 @@ title: Providers # Menu name -name: ConfigurationManagerForeman +name: ConfigurationManager # Main DB table report is based on db: ManageIQ::Providers::ConfigurationManager diff --git a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager.yaml b/product/views/ManageIQ_Providers_Foreman_ConfigurationManager.yaml deleted file mode 100644 index 2525a1e367f..00000000000 --- a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager.yaml +++ /dev/null @@ -1,103 +0,0 @@ -# -# This is an MIQ Report configuration file -# Single value parameters are specified as: -# single_value_parm: value -# Multiple value parameters are specified as: -# multi_value_parm: -# - value 1 -# - value 2 -# - -# Report title -title: Providers - -# Menu name -name: ConfigurationManagerForeman - -# Main DB table report is based on -db: ManageIQ::Providers::Foreman::ConfigurationManager - -# Columns to fetch from the main table -cols: -- name -- url -- type -- last_refresh_date -- region_description -- authentication_status -- total_configuration_profiles -- total_configured_systems - -# Included tables (joined, has_one, has_many) and columns -include: - zone: - columns: - - name - endpoints: - columns: - - url - -# Included tables and columns for query performance -include_for_find: - -# Order of columns (from all tables) -col_order: -- name -- url -- type -- zone.name -- last_refresh_date -- region_description -- authentication_status -- total_configuration_profiles -- total_configured_systems - -# Column titles, in order -headers: -- Provider Name -- URL -- Type -- Zone -- Last Refresh Date -- Region Description -- Status -- Total Configuration Profiles -- Total Configured Systems - -col_formats: -- -- -- :model_name -- -- -- - -# Condition(s) string for the SQL query -conditions: - -# Order string for the SQL query -order: Ascending - -# Columns to sort the report on, in order -sortby: -- name - -# Group rows (y=yes,n=no,c=count) -group: n - -# Graph type -# Bar -# Column -# ColumnThreed -# ParallelThreedColumn -# Pie -# PieThreed -# StackedBar -# StackedColumn -# StackedThreedColumn - -graph: - -# Dimensions of graph (1 or 2) -# Note: specifying 2 for a single dimension graph may not return expected results -dims: diff --git a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfiguredSystem.yaml b/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfiguredSystem.yaml deleted file mode 100644 index 7c20aefadef..00000000000 --- a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfiguredSystem.yaml +++ /dev/null @@ -1,88 +0,0 @@ -# -# This is an MIQ Report configuration file -# Single value parameters are specified as: -# single_value_parm: value -# Multiple value parameters are specified as: -# multi_value_parm: -# - value 1 -# - value 2 -# - -# Report title -title: ConfiguredSystem - -# Menu name -name: ConfiguredSystems - -# Main DB table report is based on -db: ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem - -# Columns to fetch from the main table -cols: -- hostname -- type -- last_checkin -- build_state -- my_zone -- configuration_environment_name -- configuration_profile_name - -# Included tables (joined, has_one, has_many) and columns -include: - -# Order of columns (from all tables) -col_order: -- hostname -- type -- last_checkin -- build_state -- my_zone -- configuration_environment_name -- configuration_profile_name - -# Column titles, in order -headers: -- Hostname -- Type -- Last Checkin -- Build State -- Zone -- Environment -- Configuration Profile - -col_formats: -- -- :model_name -- -- -- - -# Condition(s) string for the SQL query -conditions: - -# Order string for the SQL query -order: Ascending - -# Columns to sort the report on, in order -sortby: -- hostname - -# Group rows (y=yes,n=no,c=count) -group: n - -# Graph type -# Bar -# Column -# ColumnThreed -# ParallelThreedColumn -# Pie -# PieThreed -# StackedBar -# StackedColumn -# StackedThreedColumn - -graph: - -# Dimensions of graph (1 or 2) -# Note: specifying 2 for a single dimension graph may not return expected results -dims: diff --git a/spec/controllers/application_controller/advanced_search_spec.rb b/spec/controllers/application_controller/advanced_search_spec.rb index 85599d2ac76..0b75c9b6c43 100644 --- a/spec/controllers/application_controller/advanced_search_spec.rb +++ b/spec/controllers/application_controller/advanced_search_spec.rb @@ -1,18 +1,20 @@ -describe ProviderForemanController, "::AdvancedSearch" do - before do - stub_user(:features => :all) - controller.instance_variable_set(:@sb, {}) - end +describe EmsConfigurationController, "::AdvancedSearch" do + let(:expr) { ApplicationController::Filter::Expression.new("=" => exp, :token => 1) } + let(:exp) { {:field => "Some_field", :value => "123"} } - describe "#adv_search_redraw_left_div" do - before { controller.instance_variable_set(:@sb, :active_tree => :configuration_manager_cs_filter_tree) } + describe '#adv_search_button_saveid' do + before do + stub_user(:features => :all) + controller.instance_variable_set(:@edit, :new => {:expression => {"=" => exp}}, :new_search_name => 'filter', :expression => expr) + controller.instance_variable_set(:@expkey, :expression) + end - it "calls build_accordions_and_trees method in Config Mgmt Configured Systems when saving a filter" do - allow(controller).to receive(:adv_search_redraw_listnav_and_main) + subject { controller.instance_variable_get(:@edit)[:expression] } - expect(controller).to receive(:build_accordions_and_trees).and_call_original.once - expect(TreeBuilderConfigurationManagerConfiguredSystems).to receive(:new).and_call_original - controller.send(:adv_search_redraw_left_div) + it 'sets only @edit[@expkey][:exp_last_loaded]' do + controller.send(:adv_search_button_saveid) + expect(subject[:selected]).to be_nil + expect(subject[:exp_last_loaded]).to include(:name => "user_#{session[:userid]}_filter", :description => 'filter', :typ => 'user') end end end diff --git a/spec/controllers/application_controller/explorer_spec.rb b/spec/controllers/application_controller/explorer_spec.rb index a6f123e9020..f3d9149d78a 100644 --- a/spec/controllers/application_controller/explorer_spec.rb +++ b/spec/controllers/application_controller/explorer_spec.rb @@ -79,21 +79,3 @@ end end end - -describe ProviderForemanController do - describe '#replace_search_box' do - let(:presenter) { ExplorerPresenter.new(:active_tree => :configuration_manager_providers_tree) } - - it 'replaces advsearchModal' do - expect(presenter).to receive(:replace).with(:adv_searchbox_div, '') - expect(presenter).not_to receive(:replace).with(:advsearchModal, '') - controller.send(:replace_search_box, presenter, :nameonly => true) - end - - it 'does not replace advsearchModal' do - expect(presenter).to receive(:replace).with(:adv_searchbox_div, '') - expect(presenter).to receive(:replace).with(:advsearchModal, '') - controller.send(:replace_search_box, presenter) - end - end -end diff --git a/spec/controllers/mixins/manager_controller_mixin_spec.rb b/spec/controllers/mixins/manager_controller_mixin_spec.rb index 73bd78b016f..5ae1fa1bfad 100644 --- a/spec/controllers/mixins/manager_controller_mixin_spec.rb +++ b/spec/controllers/mixins/manager_controller_mixin_spec.rb @@ -1,6 +1,6 @@ describe Mixins::ManagerControllerMixin do describe '#replace_right_cell' do - let(:controller) { ProviderForemanController.new } + let(:controller) { AutomationManagerController.new } before do allow(controller).to receive(:leaf_record) diff --git a/spec/controllers/ops_controller/settings/rbac_roles_spec.rb b/spec/controllers/ops_controller/settings/rbac_roles_spec.rb index d7be0ef50ee..0f5770dfe7b 100644 --- a/spec/controllers/ops_controller/settings/rbac_roles_spec.rb +++ b/spec/controllers/ops_controller/settings/rbac_roles_spec.rb @@ -2,7 +2,7 @@ before do EvmSpecHelper.seed_specific_product_features( %w(vm vm_compare vm_delete instance instance_delete image image_delete miq_template - miq_template_delete provider_foreman_explorer provider_foreman_view) + miq_template_delete ems_configuration_show_list) ) end @@ -41,10 +41,10 @@ end end context '"_tab_conf" feature node' do - it 'yields features including "provider_foreman_view"' do + it 'yields features including "ems_configuration_show_list"' do expect do |b| - controller.send(:recurse_sections_and_features, '_tab_conf', &b) - end.to yield_successive_args(["provider_foreman_explorer", include("provider_foreman_view")]) + controller.send(:recurse_sections_and_features, 'ems_configuration', &b) + end.to yield_successive_args(["ems_configuration", include("ems_configuration_show_list")]) end end context '"vm" feature node' do diff --git a/spec/controllers/provider_foreman_controller_spec.rb b/spec/controllers/provider_foreman_controller_spec.rb index a9ae38c5a5d..e69de29bb2d 100644 --- a/spec/controllers/provider_foreman_controller_spec.rb +++ b/spec/controllers/provider_foreman_controller_spec.rb @@ -1,645 +0,0 @@ -describe ProviderForemanController do - render_views - - let(:tags) { ["/managed/quota_max_memory/2048"] } - - before do - allow(controller).to receive(:data_for_breadcrumbs).and_return({}) - @zone = EvmSpecHelper.local_miq_server.zone - Tag.find_or_create_by(:name => tags.first) - - @provider = ManageIQ::Providers::Foreman::Provider.create(:name => "testForeman", :url => "10.8.96.102", :zone => @zone) - @config_mgr = ManageIQ::Providers::Foreman::ConfigurationManager.find_by(:provider_id => @provider.id) - @config_profile = ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile.create(:name => "testprofile", - :description => "testprofile", - :manager_id => @config_mgr.id) - @config_profile2 = ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile.create(:name => "testprofile2", - :description => "testprofile2", - :manager_id => @config_mgr.id) - @configured_system = ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "test_configured_system", - :configuration_profile_id => @config_profile.id, - :manager_id => @config_mgr.id) - @configured_system2a = ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "test2a_configured_system", - :configuration_profile_id => @config_profile2.id, - :manager_id => @config_mgr.id) - @configured_system2b = ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "test2b_configured_system", - :configuration_profile_id => @config_profile2.id, - :manager_id => @config_mgr.id) - @configured_system_unprovisioned = - ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "configured_system_unprovisioned", - :configuration_profile_id => nil, - :manager_id => @config_mgr.id) - - @provider2 = ManageIQ::Providers::Foreman::Provider.create(:name => "test2Foreman", :url => "10.8.96.103", :zone => @zone) - @config_mgr2 = ManageIQ::Providers::Foreman::ConfigurationManager.find_by(:provider_id => @provider2.id) - @configured_system_unprovisioned2 = - ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "configured_system_unprovisioned2", - :configuration_profile_id => nil, - :manager_id => @config_mgr2.id) - controller.instance_variable_set(:@sb, :active_tree => :configuration_manager_providers_tree) - - [@configured_system, @configured_system2a, @configured_system2b, @configured_system_unprovisioned2].each do |cs| - cs.tag_with(tags, :namespace => '') - end - end - - it "renders index" do - stub_user(:features => :all) - get :index - expect(response.status).to eq(302) - expect(response).to redirect_to(:action => 'explorer') - end - - it "renders explorer" do - login_as user_with_feature(%w(providers_accord configured_systems_filter_accord)) - - get :explorer - accords = controller.instance_variable_get(:@accords) - expect(accords.size).to eq(2) - breadcrumbs = controller.instance_variable_get(:@breadcrumbs) - expect(breadcrumbs[0]).to include(:url => '/provider_foreman/show_list') - expect(response.status).to eq(200) - expect(response.body).to_not be_empty - end - - it "renders explorer sorted by url" do - login_as user_with_feature(%w(providers_accord configured_systems_filter_accord)) - FactoryBot.create(:provider_foreman, :name => "foremantest1", :url => "z_url") - FactoryBot.create(:provider_foreman, :name => "foremantest2", :url => "a_url") - - get :explorer, :params => {:sortby => '2'} - expect(response.status).to eq(200) - expect(response.body).to include("modelName: 'ManageIQ::Providers::ConfigurationManager'") - expect(response.body).to include("activeTree: 'configuration_manager_providers_tree'") - expect(response.body).to include("gtlType: 'list'") - expect(response.body).to include("isExplorer: 'true' === 'true' ? true : false") - expect(response.body).to include("showUrl: '/provider_foreman/x_show/'") - end - - context "renders explorer based on RBAC" do - it "renders explorer based on RBAC access to feature 'configured_system_tag'" do - login_as user_with_feature %w(configured_system_tag) - - get :explorer - accords = controller.instance_variable_get(:@accords) - expect(accords.size).to eq(1) - expect(accords[0][:name]).to eq("configuration_manager_cs_filter") - expect(response.status).to eq(200) - expect(response.body).to_not be_empty - end - - it "renders explorer based on RBAC access to feature 'provider_foreman_add_provider'" do - login_as user_with_feature %w(provider_foreman_add_provider) - - get :explorer - accords = controller.instance_variable_get(:@accords) - expect(accords.size).to eq(1) - expect(accords[0][:name]).to eq("configuration_manager_providers") - expect(response.status).to eq(200) - expect(response.body).to_not be_empty - end - end - - context "asserts correct privileges" do - before { login_as user_with_feature %w[configured_system_provision] } - - it "should not raise an error for feature that user has access to" do - expect { controller.send(:assert_privileges, "configured_system_provision") }.not_to raise_error - end - - it "should raise an error for feature that user has access to" do - expect { controller.send(:assert_privileges, "provider_foreman_add_provider") } - .to raise_error(MiqException::RbacPrivilegeException) - end - end - - it "renders show_list" do - stub_user(:features => :all) - get :show_list - expect(response.status).to eq(302) - expect(response.body).to_not be_empty - end - - it "renders a new page" do - post :new, :format => :js - expect(response.status).to eq(200) - end - - context "Verify the provisionable flag for CSs" do - it "Provision action should not be allowed only for a Configured System marked as not provisionable" do - allow(controller).to receive(:x_node).and_return("root") - allow(controller).to receive(:x_tree).and_return(:type => :filter) - controller.params = {:id => "configuration_manager_cs_filter"} - allow(controller).to receive(:replace_right_cell) - allow(controller).to receive(:render) - controller.params = {:id => @configured_system2a.id} - controller.send(:provision) - expect(controller.send(:flash_errors?)).to_not be_truthy - end - end - - it "#save_provider_foreman will not save with a duplicate name" do - ManageIQ::Providers::Foreman::Provider.create(:name => "test2Foreman", :url => "server1", :zone => @zone) - provider2 = ManageIQ::Providers::Foreman::Provider.new(:name => "test2Foreman", :url => "server2", :zone => @zone) - controller.instance_variable_set(:@provider, provider2) - allow(controller).to receive(:render_flash) - controller.save_provider - expect(assigns(:flash_array).last[:message]).to include("Name has already been taken") - end - - describe "#edit" do - before { stub_user(:features => :all) } - - it "renders the edit page when the configuration manager id is supplied" do - post :edit, :params => { :id => @config_mgr.id } - expect(response.status).to eq(200) - right_cell_text = controller.instance_variable_get(:@right_cell_text) - expect(right_cell_text).to eq("Edit Provider") - end - - it "should display the zone field" do - new_zone = FactoryBot.create(:zone) - controller.instance_variable_set(:@provider, @provider) - post :edit, :params => { :id => @config_mgr.id } - expect(response.status).to eq(200) - expect(response.body).to include("option value=\\\"#{new_zone.name}\\\"") - end - - it "should save the zone field" do - new_zone = FactoryBot.create(:zone) - controller.instance_variable_set(:@provider, @provider) - allow(controller).to receive(:leaf_record).and_return(false) - post :edit, :params => { :button => 'save', - :id => @config_mgr.id, - :zone => new_zone.name, - :url => @provider.url, - :verify_ssl => @provider.verify_ssl } - expect(response.status).to eq(200) - expect(@provider.zone).to eq(new_zone) - end - - it "should save the verify_ssl flag" do - controller.instance_variable_set(:@provider, @provider) - allow(controller).to receive(:leaf_record).and_return(false) - [true, false].each do |verify_ssl| - post :edit, :params => { :button => 'save', - :id => @config_mgr.id, - :url => @provider.url, - :verify_ssl => verify_ssl.to_s } - expect(response.status).to eq(200) - expect(@provider.verify_ssl).to eq(verify_ssl ? 1 : 0) - end - end - - it "renders the edit page when the configuration manager id is selected from a list view" do - post :edit, :params => { :miq_grid_checks => @config_mgr.id } - expect(response.status).to eq(200) - end - - it "renders the edit page when the configuration manager id is selected from a grid/tile" do - post :edit, :params => { "check_#{@config_mgr.id}" => "1" } - expect(response.status).to eq(200) - end - end - - describe "#refresh" do - before do - stub_user(:features => :all) - allow(controller).to receive(:x_node).and_return("root") - allow(controller).to receive(:rebuild_toolbars).and_return("true") - end - - it "renders the refresh flash message for Foreman" do - post :refresh, :params => {:miq_grid_checks => @config_mgr.id} - expect(response.status).to eq(200) - expect(assigns(:flash_array).first[:message]).to include("Refresh Provider initiated for 1 provider") - end - - it "refreshes the provider when the configuration manager id is supplied" do - allow(controller).to receive(:replace_right_cell) - post :refresh, :params => { :id => @config_mgr.id } - expect(assigns(:flash_array).first[:message]).to include("Refresh Provider initiated for 1 provider") - end - - it "it refreshes a provider when the configuration manager id is selected from a grid/tile" do - allow(controller).to receive(:replace_right_cell) - post :refresh, :params => { "check_#{@config_mgr.id}" => "1", - "check_#{@config_mgr2.id}" => "1" } - expect(assigns(:flash_array).first[:message]).to include("Refresh Provider initiated for 2 providers") - end - end - - context "renders right cell text" do - before do - right_cell_text = nil - login_as user_with_feature(%w(providers_accord configured_systems_filter_accord)) - controller.instance_variable_set(:@right_cell_text, right_cell_text) - allow(controller).to receive(:get_view_calculate_gtl_type) - allow(controller).to receive(:get_view_pages) - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:load_or_clear_adv_search) - allow(controller).to receive(:replace_search_box) - allow(controller).to receive(:update_partials) - allow(controller).to receive(:render) - - allow(controller).to receive(:items_per_page).and_return(20) - allow(controller).to receive(:gtl_type).and_return("list") - allow(controller).to receive(:current_page).and_return(1) - controller.send(:build_accordions_and_trees) - end - - it "renders right cell text for root node" do - key = ems_key_for_provider(@provider) - controller.send(:get_node_info, "root") - right_cell_text = controller.instance_variable_get(:@right_cell_text) - expect(right_cell_text).to eq("All Configuration Management Providers") - end - - it "renders right cell text for ConfigurationManagerForeman node" do - controller.instance_variable_set(:@in_report_data, true) - ems_id = ems_key_for_provider(@provider) - controller.params = {:id => ems_id} - controller.send(:tree_select) - right_cell_text = controller.instance_variable_get(:@right_cell_text) - expect(right_cell_text).to eq("Configuration Profiles under Foreman Provider \"testForeman Configuration Manager\"") - end - end - - it "builds foreman child tree" do - tree_builder = TreeBuilderConfigurationManager.new("root", controller.instance_variable_get(:@sb)) - objects = tree_builder.send(:x_get_tree_roots) - expected_objects = [@config_mgr, @config_mgr2] - expect(objects).to match_array(expected_objects) - end - - context "renders tree_select" do - before do - get :explorer - right_cell_text = nil - login_as user_with_feature(%w(providers_accord configured_systems_filter_accord)) - controller.instance_variable_set(:@right_cell_text, right_cell_text) - allow(controller).to receive(:get_view_calculate_gtl_type) - allow(controller).to receive(:get_view_pages) - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:load_or_clear_adv_search) - allow(controller).to receive(:replace_search_box) - allow(controller).to receive(:update_partials) - allow(controller).to receive(:render) - - allow(controller).to receive(:items_per_page).and_return(20) - allow(controller).to receive(:gtl_type).and_return("list") - allow(controller).to receive(:current_page).and_return(1) - controller.send(:build_accordions_and_trees) - end - - it "calls get_view with the associated dbname for the Configuration Management Providers accordion" do - stub_user(:features => :all) - allow(controller).to receive(:x_active_tree).and_return(:configuration_manager_providers_tree) - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_providers) - allow(controller).to receive(:build_listnav_search_list) - controller.params = {:id => "configuration_manager_providers_accord"} - expect(controller).to receive(:get_view).with("ManageIQ::Providers::ConfigurationManager", - :gtl_dbname => :cm_providers, :dbname => :cm_providers).and_call_original - controller.send(:accordion_select) - end - - it "calls get_view with the associated dbname for the Configuration Profiles list" do - stub_user(:features => :all) - allow(controller).to receive(:x_active_tree).and_return(:configuration_manager_providers_tree) - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_providers) - ems_id = ems_id_for_provider(@provider) - controller.instance_variable_set(:@in_report_data, true) - controller.params = {:id => ems_key_for_provider(@provider)} - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:apply_node_search_text) - expect(controller).to receive(:get_view).with("ConfigurationProfile", :match_via_descendants => "ConfiguredSystem", - :named_scope => [[:with_manager, ems_id]], - :dbname => :cm_configuration_profiles, - :gtl_dbname => :cm_configuration_profiles).and_call_original - controller.send(:tree_select) - end - - it "calls get_view with the associated dbname for the Configured Systems accordion" do - stub_user(:features => :all) - allow(controller).to receive(:x_active_tree).and_return(:configuration_manager_cs_filter_tree) - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_cs_filter) - allow(controller).to receive(:build_listnav_search_list) - controller.params = {:id => "configuration_manager_cs_filter_accord"} - expect(controller).to receive(:get_view).with("ConfiguredSystem", :gtl_dbname => :cm_configured_systems, :dbname => :cm_configured_systems).and_call_original - allow(controller).to receive(:build_listnav_search_list) - controller.send(:accordion_select) - end - end - - it "singularizes breadcrumb name" do - expect(controller.send(:breadcrumb_name, nil)).to eq("#{ui_lookup(:ui_title => "foreman")} Provider") - end - - it "renders tagging editor for a configured system" do - session[:tag_items] = [@configured_system.id] - session[:assigned_filters] = [] - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_cs_filter) - parent = FactoryBot.create(:classification) - FactoryBot.create(:classification_tag, :parent => parent) - FactoryBot.create(:classification_tag, :parent => parent) - post :tagging, :params => { :id => @configured_system.id, :format => :js } - expect(response.status).to eq(200) - end - - it "renders tagging editor for a configured system in the manager accordion" do - session[:assigned_filters] = [] - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_providers) - allow(controller).to receive(:x_node).and_return(config_profile_key(@config_profile)) - parent = FactoryBot.create(:classification) - FactoryBot.create(:classification_tag, :parent => parent) - FactoryBot.create(:classification_tag, :parent => parent) - post :tagging, :params => { :miq_grid_checks => [@configured_system.id], :id => @config_profile.id, :format => :js } - expect(response.status).to eq(200) - end - - it "renders tree_select as js" do - TreeBuilderConfigurationManager.new(:configuration_manager_providers_tree, controller.instance_variable_get(:@sb)) - - allow(controller).to receive(:process_show_list) - allow(controller).to receive(:add_unassigned_configuration_profile_record) - allow(controller).to receive(:replace_explorer_trees) - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:rebuild_toolbars) - allow(controller).to receive(:replace_search_box) - allow(controller).to receive(:update_partials) - - stub_user(:features => :all) - - key = ems_key_for_provider(@provider) - post :tree_select, :params => { :id => key, :format => :js } - expect(response.status).to eq(200) - end - - context "tree_select on provider foreman node" do - before do - login_as user_with_feature %w(provider_foreman_refresh_provider provider_foreman_edit_provider provider_foreman_delete_provider) - - allow(controller).to receive(:check_privileges) - allow(controller).to receive(:process_show_list) - allow(controller).to receive(:add_unassigned_configuration_profile_record) - allow(controller).to receive(:replace_explorer_trees) - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:replace_search_box) - allow(controller).to receive(:x_active_tree).and_return(:configuration_manager_providers_tree) - end - - it "does not hide Configuration button in the toolbar" do - TreeBuilderConfigurationManager.new(:configuration_manager_providers_tree, controller.instance_variable_get(:@sb)) - key = ems_key_for_provider(@provider) - post :tree_select, :params => { :id => key } - expect(response.status).to eq(200) - expect(response.body).not_to include('