Skip to content

Commit

Permalink
Fixes #3971 - warning shown when PXE template is edited and has hosts…
Browse files Browse the repository at this point in the history
… in build mode
  • Loading branch information
Ondrej Prazak authored and Dominic Cleal committed Jul 9, 2015
1 parent d4a4928 commit a377f77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/helpers/provisioning_templates_helper.rb
Expand Up @@ -67,6 +67,15 @@ def permitted_actions(template)
end
end

def pxe_with_building_hosts?(template)
kinds = ["PXELinux", "PXEGrub"]
os_ids = template.operatingsystem_ids
template.respond_to?(:template_kind) &&
template.template_kind.present? &&
kinds.include?(template.template_kind.name) &&
Host.where(:build => true, :operatingsystem_id => os_ids).any?
end

private

def locations_only?
Expand Down
5 changes: 5 additions & 0 deletions app/views/templates/_form.html.erb
Expand Up @@ -35,6 +35,11 @@
"http://www.theforeman.org/manuals/#{SETTINGS[:version].short}/index.html#4.4.3ProvisioningTemplates", :rel => 'external')).html_safe) %>
<% end -%>
<% if pxe_with_building_hosts?(@template) -%>
<%= alert :class => 'alert-warning', :header => '',
:text => icon_text("warning-sign", (_("Warning: The template is associated to at least one host in build mode. To apply the change, disable and enable build mode on hosts to update the live templates."))) %>
<% end -%>

<div class='form-group'>
<label class="control-label" for="template"><%= _("Template editor") %></label>
<div class="navbar navbar-form">
Expand Down

0 comments on commit a377f77

Please sign in to comment.