Skip to content

Commit

Permalink
Merge pull request #6782 from h-kataria/configuration_manager_non_exp…
Browse files Browse the repository at this point in the history
…lorer_version

Configuration manager non explorer version
  • Loading branch information
Fryguy authored May 8, 2020
2 parents a3f14bd + 3f8593e commit fdc0b7a
Show file tree
Hide file tree
Showing 85 changed files with 1,314 additions and 2,671 deletions.
8 changes: 0 additions & 8 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions app/controllers/application_controller/advanced_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller/ci_processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
9 changes: 4 additions & 5 deletions app/controllers/application_controller/explorer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/automation_manager_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
52 changes: 52 additions & 0 deletions app/controllers/configuration_profile_controller.rb
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions app/controllers/configured_system_controller.rb
Original file line number Diff line number Diff line change
@@ -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
113 changes: 113 additions & 0 deletions app/controllers/ems_configuration_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit fdc0b7a

Please sign in to comment.