From 0ce0e6a5b896bfdae85058635d8da563040cb283 Mon Sep 17 00:00:00 2001 From: Boris Odnopozov Date: Tue, 26 Jun 2018 14:16:38 +0300 Subject: [PATCH] Add sysprep support for ovirt Add sysprep specification support for vm provisioning from template for the oVirt provider. Depends on: https://github.com/ManageIQ/manageiq/pull/17636 Implements: https://bugzilla.redhat.com/show_bug.cgi?id=1553833 --- .../customize_fields_visibility_service.rb | 12 +- app/views/miq_request/_prov_field.html.haml | 5 +- app/views/shared/views/_prov_dialog.html.haml | 110 ++++++++++++------ 3 files changed, 89 insertions(+), 38 deletions(-) diff --git a/app/services/customize_fields_visibility_service.rb b/app/services/customize_fields_visibility_service.rb index 539f7e26261f..afbb70db2fd4 100644 --- a/app/services/customize_fields_visibility_service.rb +++ b/app/services/customize_fields_visibility_service.rb @@ -6,10 +6,21 @@ def determine_visibility(platform, supports_customization_template, customize_fi if supports_customization_template field_names_to_edit += [ :addr_mode, + :sysprep_timezone, :customization_template_id, :customization_template_script, :dns_servers, :dns_suffixes, + :sysprep_domain_name, + :sysprpe_domain_admin, + :sysprep_domain_password, + :sysprep_computer_name, + :sysprep_locale_ui, + :sysprep_locale_input, + :sysprep_locale_system, + :sysprep_locale_user, + :sysprep_machine_object_ou, + :sysprep_product_key, :gateway, :hostname, :ip_addr, @@ -24,7 +35,6 @@ def determine_visibility(platform, supports_customization_template, customize_fi :sysprep_upload_file, :sysprep_upload_text, :linux_host_name, - :sysprep_computer_name, :ip_addr, :subnet_mask, :gateway, diff --git a/app/views/miq_request/_prov_field.html.haml b/app/views/miq_request/_prov_field.html.haml index 86d45ed93bc5..04e2367a82fb 100644 --- a/app/views/miq_request/_prov_field.html.haml +++ b/app/views/miq_request/_prov_field.html.haml @@ -87,7 +87,10 @@ :sysprep_full_name, :sysprep_organization, :sysprep_product_id, :sysprep_computer_name, :sysprep_per_server_max_connections, :vm_description, - :vm_name, :wins_servers].include?(field) + :vm_name, :wins_servers, :sysprep_domain, :sysprep_timezone, + :sysprep_admin_password, :sysprep_product_key, :sysprep_locale_ui, + :sysprep_locale_input, :sysprep_locale_system, :sysprep_locale_user, + :sysprep_machine_object_ou].include?(field) .col-md-8 - if @edit && field_hash[:display] == :edit && !@edit[:stamp_typ] -# Allow editing of the text field diff --git a/app/views/shared/views/_prov_dialog.html.haml b/app/views/shared/views/_prov_dialog.html.haml index e97e3d7e64ad..163c1fbc29c1 100644 --- a/app/views/shared/views/_prov_dialog.html.haml +++ b/app/views/shared/views/_prov_dialog.html.haml @@ -191,42 +191,80 @@ :keys => keys}) - if (@edit && @edit[:new] && @edit[:new][:sysprep_enabled] && @edit[:new][:sysprep_enabled][0] == "fields") || (@options && @options[:sysprep_enabled] && @options[:sysprep_enabled][0] == "fields") - if wf.kind_of?(ManageIQ::Providers::Redhat::InfraManager::ProvisionWorkflow) - - keys = [:root_username, :root_password] - = render(:partial => "/miq_request/prov_dialog_fieldset", - :locals => {:workflow => wf, - :dialog => dialog, - :label => _("Credentials"), - :prefix => "/miq_request/", - :keys => keys}) - - keys = [:addr_mode, :hostname, :ip_addr, :subnet_mask, :gateway] - = render(:partial => "/miq_request/prov_dialog_fieldset", - :locals => {:workflow => wf, - :dialog => dialog, - :label => _("IP Address Information"), - :prefix => "/miq_request/", - :keys => keys}) - - keys = [:dns_servers, :dns_suffixes] - = render(:partial => "/miq_request/prov_dialog_fieldset", - :locals => {:workflow => wf, - :dialog => dialog, - :label => _("DNS"), - :prefix => "/miq_request/", - :keys => keys}) - - keys = [:customization_template_id] - = render(:partial => "/miq_request/prov_dialog_fieldset", - :locals => {:workflow => wf, - :dialog => dialog, - :label => _("Customize Template"), - :prefix => "/miq_request/", - :keys => keys}) - - show_customization_template_script = (@edit && @edit[:new] && @edit[:new][:customization_template_script]) || (@options && @options[:customization_template_script]) - - keys = [show_customization_template_script ? :customization_template_script : nil].compact - = render(:partial => "/miq_request/prov_dialog_fieldset", - :locals => {:workflow => wf, - :dialog => dialog, - :label => _("Selected Template Contents"), - :prefix => "/miq_request/", - :keys => keys}) + - if @edit[:new][:sysprep_enabled][1] == "Sysprep Specification" + - keys = [:sysprep_computer_name, :sysprep_organization, :sysprep_admin_password, :sysprep_product_key] + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Computer Details"), + :prefix => "/miq_request/", + :keys => keys}) + - keys = [:sysprep_domain, :sysprep_domain_admin, :sysprep_domain_password, :sysprep_machine_object_ou] + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Domain Information"), + :prefix => "/miq_request/", + :keys => keys}) + - keys = [:sysprep_timezone, :sysprep_locale_ui, :sysprep_locale_system, :sysprep_locale_input, :sysprep_locale_user] + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Localization"), + :prefix => "/miq_request/", + :keys => keys}) + - keys = [:customization_template_id] + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Customize Template"), + :prefix => "/miq_request/", + :keys => keys}) + - show_customization_template_script = (@edit && @edit[:new] && @edit[:new][:customization_template_script]) || (@options && @options[:customization_template_script]) + - keys = [show_customization_template_script ? :customization_template_script : nil].compact + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Selected Template Contents"), + :prefix => "/miq_request/", + :keys => keys}) + - else + - keys = [:root_username, :root_password] + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Credentials"), + :prefix => "/miq_request/", + :keys => keys}) + - keys = [:addr_mode, :hostname, :ip_addr, :subnet_mask, :gateway] + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("IP Address Information"), + :prefix => "/miq_request/", + :keys => keys}) + - keys = [:dns_servers, :dns_suffixes] + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("DNS"), + :prefix => "/miq_request/", + :keys => keys}) + - keys = [:customization_template_id] + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Customize Template"), + :prefix => "/miq_request/", + :keys => keys}) + - show_customization_template_script = (@edit && @edit[:new] && @edit[:new][:customization_template_script]) || (@options && @options[:customization_template_script]) + - keys = [show_customization_template_script ? :customization_template_script : nil].compact + = render(:partial => "/miq_request/prov_dialog_fieldset", + :locals => {:workflow => wf, + :dialog => dialog, + :label => _("Selected Template Contents"), + :prefix => "/miq_request/", + :keys => keys}) - else - keys = [:sysprep_custom_spec, :sysprep_spec_override] = render(:partial => "/miq_request/prov_dialog_fieldset",