diff --git a/app/controllers/application_controller/miq_request_methods.rb b/app/controllers/application_controller/miq_request_methods.rb index c17b87641a7..8b9ee03014f 100644 --- a/app/controllers/application_controller/miq_request_methods.rb +++ b/app/controllers/application_controller/miq_request_methods.rb @@ -292,14 +292,20 @@ def _build_whatever_grid(what, list, headers, sort_order, sort_by, integer_field def build_configured_system_grid(configured_systems, sort_order = nil, sort_by = nil) sort_by ||= "hostname" sort_order ||= "ASC" - - headers = { - "hostname" => _("Hostname"), - "configuration_location_name" => _("Configuration Location"), - "configuration_organization_name" => _("Configuration Organization"), - "operating_system_flavor_name" => _("Operating System"), - "provider_name" => _("Provider"), - } + headers = {} + if @edit[:wf].kind_of?(PhysicalServerProvisionWorkflow) + headers = { + "name" => _("Server Name") + } + else + headers = { + "hostname" => _("Hostname"), + "configuration_location_name" => _("Configuration Location"), + "configuration_organization_name" => _("Configuration Organization"), + "operating_system_flavor_name" => _("Operating System"), + "provider_name" => _("Provider"), + } + end @configured_systems = _build_whatever_grid('configured_system', configured_systems, headers, sort_order, sort_by) end @@ -513,6 +519,7 @@ def dialog_partial_for_workflow when ManageIQ::Providers::Foreman::ConfigurationManager::ProvisionWorkflow then "prov_configured_system_foreman_dialog" when MiqHostProvisionWorkflow then "prov_host_dialog" when VmMigrateWorkflow then "prov_vm_migrate_dialog" + when PhysicalServerProvisionWorkflow then "prov_physical_server_dialog" end end @@ -845,7 +852,8 @@ def prov_set_form_vars(req = nil) @edit[:new] = @edit[:new].merge pre_prov_values.select { |k| !@edit[:new].keys.include?(k) } end - if @edit[:wf].kind_of?(ManageIQ::Providers::Foreman::ConfigurationManager::ProvisionWorkflow) + if @edit[:wf].kind_of?(ManageIQ::Providers::Foreman::ConfigurationManager::ProvisionWorkflow) || + @edit[:wf].kind_of?(PhysicalServerProvisionWorkflow) # BD TODO else @edit[:ds_sortdir] ||= "DESC" @@ -944,6 +952,10 @@ def workflow_instance_from_vars(req) @edit[:prov_type] = "ConfiguredSystem" @edit[:new][:src_configured_system_ids] = params[:prov_id].kind_of?(Array) ? params[:prov_id] : [params[:prov_id]] wf_type = ManageIQ::Providers::Foreman::ConfigurationManager::ProvisionWorkflow + elsif @edit[:org_controller] == "physical_server" + @edit[:prov_type] = "PhysicalServer" + @edit[:new][:src_configured_system_ids] = params[:prov_id].kind_of?(Array) ? params[:prov_id] : [params[:prov_id]] + wf_type = PhysicalServerProvisionWorkflow else @edit[:prov_type] = "Host" if @edit[:new].empty? diff --git a/app/controllers/physical_server_controller.rb b/app/controllers/physical_server_controller.rb index d666a8f588c..7728862e141 100644 --- a/app/controllers/physical_server_controller.rb +++ b/app/controllers/physical_server_controller.rb @@ -39,7 +39,7 @@ def textual_group_list %i(properties networks relationships power_management assets firmware_details network_adapters smart_management), ] end - helper_method :textual_group_list + helper_method(:textual_group_list) def button assign_policies(PhysicalServer) if params[:pressed] == "physical_server_protect" @@ -53,4 +53,15 @@ def button javascript_redirect(:action => 'show', :id => @record.id, :display => 'timeline') end end + + def provision + provisioning_ids = find_checked_ids_with_rbac(PhysicalServer) + provisioning_ids.push(find_id_with_rbac(PhysicalServer, params[:id])) if provisioning_ids.empty? + + javascript_redirect(:controller => "miq_request", + :action => "prov_edit", + :prov_id => provisioning_ids, + :org_controller => "physical_server", + :escape => false) + end end diff --git a/app/helpers/application_helper/toolbar/physical_server_center.rb b/app/helpers/application_helper/toolbar/physical_server_center.rb index e7ea26052e8..1bd5b90dfae 100644 --- a/app/helpers/application_helper/toolbar/physical_server_center.rb +++ b/app/helpers/application_helper/toolbar/physical_server_center.rb @@ -193,6 +193,26 @@ class ApplicationHelper::Toolbar::PhysicalServerCenter < ApplicationHelper::Tool ), ] ), + select( + :physical_server_lifecycle_choice, + 'fa fa-recycle fa-lg', + t = N_('Lifecycle'), + t, + :enabled => true, + :items => [ + button( + :physical_server_provision, + 'pficon pficon-add-circle-o fa-lg', + t = N_('Provision Physical Server'), + t, + :url => "provision", + :url_parms => "main_div", + :enabled => true, + :onwhen => "0+", + :klass => ApplicationHelper::Button::ConfiguredSystemProvision + ) + ] + ) ] ) diff --git a/app/helpers/application_helper/toolbar/physical_servers_center.rb b/app/helpers/application_helper/toolbar/physical_servers_center.rb index efcc8b53f70..f8b4004ee45 100644 --- a/app/helpers/application_helper/toolbar/physical_servers_center.rb +++ b/app/helpers/application_helper/toolbar/physical_servers_center.rb @@ -217,6 +217,26 @@ class ApplicationHelper::Toolbar::PhysicalServersCenter < ApplicationHelper::Too ), ] ), + select( + :physical_server_lifecycle_choice, + 'fa fa-recycle fa-lg', + t = N_('Lifecycle'), + t, + :enabled => true, + :items => [ + button( + :physical_server_provision, + 'pficon pficon-add-circle-o fa-lg', + t = N_('Provision Physical Server'), + t, + :url => "provision", + :url_parms => "main_div", + :enabled => true, + :onwhen => "0+", + :klass => ApplicationHelper::Button::ConfiguredSystemProvision + ) + ] + ) ] ) end diff --git a/app/views/miq_request/_prov_physical_server_dialog.html.haml b/app/views/miq_request/_prov_physical_server_dialog.html.haml new file mode 100644 index 00000000000..5c360ab4895 --- /dev/null +++ b/app/views/miq_request/_prov_physical_server_dialog.html.haml @@ -0,0 +1,58 @@ +-# wf The workflow object currently in use +-# dialog The name (symbol) of the selected dialog + +- current_tab = @edit && @edit[:new] ? @edit[:new][:current_tab_key] : @options[:current_tab_key] +%br + +- if dialog == current_tab + - case current_tab + - when :requester + - keys = [:owner_email, :owner_first_name, :owner_last_name, :owner_address, :owner_city, :owner_state, :owner_zip, :owner_country, :owner_title, :owner_company, :owner_department, :owner_office, :owner_phone, :owner_phone_mobile, :request_notes] + = render(:partial => "prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Request Information"), + :keys => keys}) + - keys = [:owner_manager, :owner_manager_mail, :owner_manager_mail] + = render(:partial => "prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Manager"), + :keys => keys}) + - when :purpose + - keys = [:tag_ids] + = render(:partial => "prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Select Tags to apply"), + :keys => keys}) + - when :service + - keys = [:src_configured_system_ids, :src_configuration_profile_id] + = render(:partial => "prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Physical Servers"), + :keys => keys}) + - when :customize + - keys = [:root_password] + = render(:partial => "prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Credentials"), + :prefix => "miq_request/", + :keys => keys}) + - keys = [:hostname, :ip_addr] + = render(:partial => "prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("IP Address Information"), + :prefix => "miq_request/", + :keys => keys}) + - when :schedule + - has_schedule_time = (@edit && @edit[:new] && @edit[:new][:schedule_type] && @edit[:new][:schedule_type][0] == "schedule") || (@options && @options[:schedule_type] && @options[:schedule_type][0] == "schedule") + - keys = [:schedule_type, has_schedule_time ? :schedule_time : nil, :stateless].compact + = render(:partial => "prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Schedule Info"), + :keys => keys}) diff --git a/config/routes.rb b/config/routes.rb index 7db9552d37e..ef59c4d3452 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1335,6 +1335,7 @@ quick_search tl_chooser wait_for_task + provision ) + adv_search_post + exp_post +