Skip to content

Commit 78a2072

Browse files
authored
Merge pull request #9683 from agrare/miq_provision_configuration_script_service_catalog
Updates for ConfigurationScript Service Provisioning
2 parents 5e881fe + cf83bd3 commit 78a2072

File tree

6 files changed

+134
-3
lines changed

6 files changed

+134
-3
lines changed

app/controllers/application_controller/miq_request_methods.rb

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def prov_field_changed
3232
@record =
3333
if @edit[:new][:src_configured_system_ids].present?
3434
PhysicalServer.where(:id => @edit[:new][:src_configured_system_ids].first).first
35+
elsif @edit[:new][:src_configuration_script_id].present?
36+
ConfigurationScript.where(:id => Array(@edit[:new][:src_configuration_script_id]).first)
3537
else
3638
MiqTemplate.where(:id => Array(@edit[:new][:src_vm_id]).first)
3739
end
@@ -310,6 +312,14 @@ def sort_configured_system_grid
310312
sort_grid('configured_system', @edit[:wf].get_field(:src_configured_system_ids, :service)[:values])
311313
end
312314

315+
# get the sort column that was clicked on, else use the current one
316+
def sort_configuration_script_grid
317+
assert_privileges("miq_request_edit")
318+
return unless load_edit("prov_edit__#{params[:id]}", "show_list")
319+
320+
sort_grid('configuration_script', @edit[:wf].get_field(:src_configuration_script_id, :service)[:values])
321+
end
322+
313323
# get the sort column that was clicked on, else use the current one
314324
def sort_pxe_img_grid
315325
assert_privileges("miq_request_edit")
@@ -380,6 +390,15 @@ def build_configured_system_grid(configured_systems, sort_order = nil, sort_by =
380390
@configured_systems = _build_whatever_grid('configured_system', configured_systems, headers, sort_order, sort_by)
381391
end
382392

393+
def build_configuration_script_grid(configuration_scripts, sort_order = nil, sort_by = nil)
394+
sort_by ||= "name"
395+
sort_order ||= "ASC"
396+
397+
headers = {"name" => _("Name"), "description" => _("Description"), "manager_name" => _("Provider Name")}
398+
399+
@configuration_scripts = _build_whatever_grid("configuration_script", configuration_scripts, headers, sort_order, sort_by)
400+
end
401+
383402
def build_pxe_img_grid(pxe_imgs, sort_order = nil, sort_by = nil)
384403
sort_by ||= "name"
385404
sort_order ||= "ASC"
@@ -516,6 +535,13 @@ def build_grid
516535
case @edit[:wf]
517536
when MiqProvisionConfiguredSystemWorkflow
518537
build_dialog_page_miq_provision_configured_system_workflow
538+
when MiqProvisionConfigurationScriptWorkflow
539+
case @edit[:new][:current_tab_key]
540+
when :purpose
541+
build_tags_for_provisioning(@edit[:wf], @edit.fetch_path(:new, tag_symbol_for_workflow), true)
542+
when :service
543+
build_configuration_script_grid(@edit[:wf].get_field(:src_configuration_script_id, :service)[:values], @edit[:configuration_script_sortdir], @edit[:configuration_script_sortcol])
544+
end
519545
when MiqProvisionVirtWorkflow
520546
if @edit[:new][:current_tab_key] == :service
521547
if @edit[:new][:st_prov_type]
@@ -580,6 +606,7 @@ def dialog_partial_for_workflow
580606
when ManageIQ::Providers::Foreman::ConfigurationManager::ProvisionWorkflow then "prov_configured_system_foreman_dialog"
581607
when VmMigrateWorkflow then "prov_vm_migrate_dialog"
582608
when PhysicalServerProvisionWorkflow then "prov_physical_server_dialog"
609+
when MiqProvisionConfigurationScriptWorkflow then "prov_configuration_script_dialog"
583610
end
584611
end
585612

@@ -805,6 +832,10 @@ def prov_get_form_vars
805832
elsif v.id.to_i == val.to_i
806833
@edit[:new][f.to_sym] = [val, v.name] # Save [value, description]
807834
end
835+
elsif evm_object_class == :ConfigurationScriptBase
836+
if v.id.to_i == val.id.to_i
837+
@edit[:new][f.to_sym] = [val, v.name] # Save [value, name]
838+
end
808839
elsif v[1].to_i == val.to_i
809840
@edit[:new][f.to_sym] = [val, v[0]] # Save [value, description]
810841
end
@@ -933,7 +964,8 @@ def prov_set_form_vars(req = nil)
933964
end
934965

935966
if @edit[:wf].kind_of?(ManageIQ::Providers::Foreman::ConfigurationManager::ProvisionWorkflow) ||
936-
@edit[:wf].kind_of?(PhysicalServerProvisionWorkflow)
967+
@edit[:wf].kind_of?(PhysicalServerProvisionWorkflow) ||
968+
@edit[:wf].kind_of?(MiqProvisionConfigurationScriptWorkflow)
937969
# BD TODO
938970
else
939971
@edit[:ds_sortdir] ||= "DESC"

app/helpers/request_info_helper.rb

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module RequestInfoHelper
33

44
PROV_FIELD_TYPES = [:vm, :host, :ds, :template, :vc, :pxe_img, :iso_img, :window_image].freeze
55

6-
PROV_FIELDS = [:src_vm_id, :placement_host_name, :placement_ds_name, :attached_ds, :sysprep_custom_spec, :customization_template_id, :pxe_image_id, :iso_image_id, :windows_image_id].freeze
6+
PROV_FIELDS = [:src_vm_id, :placement_host_name, :placement_ds_name, :attached_ds, :sysprep_custom_spec, :customization_template_id, :pxe_image_id, :iso_image_id, :windows_image_id, :src_configuration_script_id].freeze
77

88
def provision_tab_configuration(workflow)
99
prov_tab_labels = workflow.provisioning_tab_list.pluck(:name)
@@ -54,6 +54,8 @@ def prov_grid_data(field, field_id, spec_required)
5454
{:type => :iso_img, :iso_img => @iso_imgs}
5555
when :windows_image_id
5656
{:type => :window_image, :window_images => @windows_images}
57+
when :src_configuration_script_id
58+
{:type => :configuration_script, :configuration_scripts => @configuration_scripts}
5759
else
5860
{}
5961
end
@@ -93,6 +95,20 @@ def prov_vm_data(data)
9395
{:headers => headers, :rows => rows, :selected => :src_vm_id, :none_index => data[:none_index]}
9496
end
9597

98+
def prov_configuration_script_data(data)
99+
edit = data[:edit]
100+
headers = prov_grid_configuration_script_header(edit, data[:configuration_scripts], data[:type])
101+
rows = []
102+
if data[:configuration_scripts]
103+
rows += data[:configuration_scripts].map do |configuration_script|
104+
prov_row_item(configuration_script.id.to_s, prov_configuration_script_grid_cells(configuration_script))
105+
end
106+
else
107+
rows.push({:id => data[:script].id.to_s, :clickable => true, :cells => prov_configuration_script_grid_cells(data[:script])})
108+
end
109+
{:headers => headers, :rows => rows, :selected => :src_configuration_script_id, :none_index => data[:none_index]}
110+
end
111+
96112
def prov_host_data(data)
97113
edit = data[:edit]
98114
options = edit || data[:options_data]
@@ -200,6 +216,20 @@ def prov_grid_vm_header(edit, clones, vms, type)
200216
headers
201217
end
202218

219+
def prov_grid_configuration_script_header(edit, configuration_scripts, type)
220+
header_keys = prov_header_keys(type.to_s)
221+
headers = []
222+
edit[header_keys[:columns]].each_with_index do |h, index|
223+
item = prov_grid_header_item(edit[header_keys[:headers]][h])
224+
if configuration_scripts
225+
item[:sort_choice] = h
226+
item[:sort_data] = prov_sort_data(edit, index, header_keys)
227+
end
228+
headers.push(item)
229+
end
230+
headers
231+
end
232+
203233
def prov_grid_host_header(edit, options, type)
204234
header_keys = prov_header_keys(type.to_s)
205235
headers = []
@@ -272,6 +302,14 @@ def prov_vm_grid_cells(data, edit)
272302
cells
273303
end
274304

305+
def prov_configuration_script_grid_cells(data)
306+
[
307+
prov_cell_data(data.name),
308+
prov_cell_data(data.description),
309+
prov_cell_data(data.manager_name)
310+
]
311+
end
312+
275313
def prov_host_grid_cells(data, options)
276314
options[:host_columns].map do |col|
277315
prov_cell_data(data.send(col))
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
-# wf The workflow object currently in use
2+
-# dialog The name (symbol) of the selected dialog
3+
4+
- current_tab = @edit && @edit[:new] ? @edit[:new][:current_tab_key] : @options[:current_tab_key]
5+
%br
6+
7+
- if dialog == current_tab
8+
- case current_tab
9+
- when :requester
10+
- 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]
11+
= render(:partial => "prov_dialog_fieldset",
12+
:locals => {:workflow => wf,
13+
:dialog => dialog,
14+
:label => _("Request Information"),
15+
:keys => keys})
16+
- keys = [:owner_manager, :owner_manager_mail, :owner_manager_mail]
17+
= render(:partial => "prov_dialog_fieldset",
18+
:locals => {:workflow => wf,
19+
:dialog => dialog,
20+
:label => _("Manager"),
21+
:keys => keys})
22+
- when :purpose
23+
- keys = [:tag_ids]
24+
= render(:partial => "prov_dialog_fieldset",
25+
:locals => {:workflow => wf,
26+
:dialog => dialog,
27+
:label => _("Select Tags to apply"),
28+
:keys => keys})
29+
- when :service
30+
- keys = [:src_configuration_script_id]
31+
= render(:partial => "prov_dialog_fieldset",
32+
:locals => {:workflow => wf,
33+
:dialog => dialog,
34+
:label => _("Configuration Scripts"),
35+
:keys => keys})
36+
- when :customize
37+
- keys = [:root_password]
38+
= render(:partial => "prov_dialog_fieldset",
39+
:locals => {:workflow => wf,
40+
:dialog => dialog,
41+
:label => _("Credentials"),
42+
:prefix => "miq_request/",
43+
:keys => keys})
44+
- keys = [:hostname, :ip_addr]
45+
= render(:partial => "prov_dialog_fieldset",
46+
:locals => {:workflow => wf,
47+
:dialog => dialog,
48+
:label => _("IP Address Information"),
49+
:prefix => "miq_request/",
50+
:keys => keys})
51+
- when :schedule
52+
- 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")
53+
- keys = [:schedule_type, has_schedule_time ? :schedule_time : nil, :stateless].compact
54+
= render(:partial => "prov_dialog_fieldset",
55+
:locals => {:workflow => wf,
56+
:dialog => dialog,
57+
:label => _("Schedule Info"),
58+
:keys => keys})

app/views/miq_request/_prov_field.html.haml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
- elsif [:placement_folder_name].include?(field)
201201
-# wider Pull Down field that fits into 1280 wide screens
202202
.col-md-8
203+
- field_hash[:display] = :edit
203204
- if @edit && field_hash[:display] == :edit && !@edit[:stamp_typ]
204205
-# Allow editing of this pulldown field
205206
- if field_hash[:values].blank?
@@ -301,7 +302,7 @@
301302
:placement_cluster_name, :placement_dc_name, :placement_ds_name,
302303
:placement_ems_name, :placement_host_name, :placement_rp_name,
303304
:pxe_image_id, :windows_image_id, :src_configured_system_ids,
304-
:src_host_ids, :src_vm_id, :sysprep_custom_spec,
305+
:src_host_ids, :src_vm_id, :src_configuration_script_id, :sysprep_custom_spec,
305306
:customization_template_id].include?(field)
306307
-# Pull Down fields that need to be sorted on description
307308
.col-md-8

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,6 +2226,7 @@
22262226
retrieve_email
22272227
show_list
22282228
sort_configured_system_grid
2229+
sort_configuration_script_grid
22292230
sort_ds_grid
22302231
sort_host_grid
22312232
sort_iso_img_grid

spec/config/routes.pending.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ MiqRequestController:
835835
- retrieve_email
836836
- show
837837
- show_list
838+
- sort_configuration_script_grid
838839
- sort_configured_system_grid
839840
- sort_ds_grid
840841
- sort_host_grid

0 commit comments

Comments
 (0)