Project

General

Profile

« Previous | Next » 

Revision eb0834f5

Added by Sebastian Gräßl over 7 years ago

Fixes #6502 - List ignored classes and environments on import

When importing environments and classes from puppet, ignored
environments and classes defined in ignored_environments.yml
aren't aparent.

This will add them to the list to import as ignored and
should address issues like #6502.

View differences:

app/controllers/concerns/foreman/controller/environments.rb
opts[:env] = params[:env] unless params[:env].blank?
@importer = PuppetClassImporter.new(opts)
@changed = @importer.changes
rescue => e
if e.message =~ /puppet feature/i
error _("No smart proxy was found to import environments from, ensure that at least one smart proxy is registered with the 'puppet' feature.")
......
end
end
if @importer.ignored_boolean_environment_names?
warning(_("Ignored environment names resulting in booleans found. Please quote strings like true/false and yes/no in config/ignored_environments.yml."))
end
if @changed["new"].size > 0 || @changed["obsolete"].size > 0 || @changed["updated"].size > 0
render "common/_puppetclasses_or_envs_changed"
else
notice _("No changes to your environments detected")
notice_message = _("No changes to your environments detected")
if @changed['ignored'].present?
list_ignored(notice_message, @changed['ignored'])
end
notice(notice_message)
redirect_to :controller => controller_path
end
end
......
ensure
redirect_to :controller => controller_path
end
private
def list_ignored(notice, ignored)
environments = ignored.select { |_, values| values.first == '_ignored_' }
if environments.any?
ignore_notice = _("Ignored environments: %s") % environments.keys.to_sentence
else
ignore_notice = _("Ignored classes in the environments: %s") % ignored.keys.to_sentence
end
notice << "\n" + ignore_notice
end
end

Also available in: Unified diff