diff --git a/app/assets/javascripts/host_edit_extensions.js b/app/assets/javascripts/foreman_wds/host_edit_extensions.js similarity index 80% rename from app/assets/javascripts/host_edit_extensions.js rename to app/assets/javascripts/foreman_wds/host_edit_extensions.js index 79ad6225ce164dcc80e79fabb8d1862ce87d1c00..7dfaae42dccc23e1b7886ea79bed530f55a4d09a 100644 --- a/app/assets/javascripts/host_edit_extensions.js +++ b/app/assets/javascripts/foreman_wds/host_edit_extensions.js @@ -31,20 +31,30 @@ os_selected = function(element){ } }; +var old_onHostEditLoad = onHostEditLoad; +onHostEditLoad = function() { + old_onHostEditLoad(); + + $('#wds_provisioning').detach().insertBefore('#media_select'); +}; + function wds_provision_method_selected() { - build_provision_method_selected(); + $('div[id*=_provisioning]').hide(); + $('#network_provisioning').show(); $('#wds_provisioning').show(); - if ($('#wds_image_select select').val() === '') + if ($('#wds_image_select select').val() === '') { $('#wds_image_select select').attr('disabled', true); + } } $(document).on('change', '#host_provision_method_wds', wds_provision_method_selected); $(function() { + if($('#host_provision_method_wds').is(':checked')) { + wds_provision_method_selected(); + } + var caps = $('#capabilities').val() || $('#bare_metal_capabilities').val(); update_capabilities(caps); - $('#provisioning_method input[checked]').click(); - - $('#wds_provisioning').detach().insertBefore('#media_select'); }); diff --git a/app/models/concerns/foreman_wds/host_extensions.rb b/app/models/concerns/foreman_wds/host_extensions.rb index 6249c5c256e61c03e451f495d431d057cf6cd82c..f80b490861b5e424eb883d3f93f7f806c0975548 100644 --- a/app/models/concerns/foreman_wds/host_extensions.rb +++ b/app/models/concerns/foreman_wds/host_extensions.rb @@ -40,23 +40,25 @@ module ForemanWds end def capabilities + return [:wds] if wds_build? return super + [:wds] if compute_resource && (os.nil? || os.family == 'Windows') super end def bare_metal_capabilities + return [:wds] if wds_build? return super + [:wds] if os.nil? || os.family == 'Windows' super end def can_be_built? - super || (wds? && !build?) + super || (managed? && SETTINGS[:unattended] && wds? && !build?) end def wds_build? - provision_method == 'wds' + self[:provision_method] == 'wds' end def pxe_build? @@ -117,5 +119,5 @@ module ForemanWds end class ::Host::Managed::Jail < Safemode::Jail - allow :unattend_arch, :unattend_pass, :wds_facet, :wds_server, :wds_install_image_file, :wds_install_image_group, :wds_install_image_name + allow :unattend_arch, :unattend_pass, :wds_build?, :wds_facet, :wds_server, :wds_install_image_file, :wds_install_image_group, :wds_install_image_name end diff --git a/app/views/hosts/provision_method/wds/_form.html.erb b/app/views/hosts/provision_method/wds/_form.html.erb index 3a8bf597ba059bab20f049612c0c452471c4d54f..df2a74a21e490732af130b4612058ccc8d97c1ee 100644 --- a/app/views/hosts/provision_method/wds/_form.html.erb +++ b/app/views/hosts/provision_method/wds/_form.html.erb @@ -1,4 +1,4 @@ -<%= javascript 'host_edit_extensions' %> +<%= javascript 'foreman_wds/host_edit_extensions' %> <% wds_facet = @host.wds_facet || @host.build_wds_facet -%> <div id="wds_provisioning" <%= display? !@host.wds_build? %>>