Skip to content

Commit

Permalink
Fixes #30929 - Deprecate ovirt v3 API
Browse files Browse the repository at this point in the history
  • Loading branch information
shiramax committed Oct 13, 2020
1 parent a9ed12b commit a174f46
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/views/compute_resources/form/_ovirt.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<%= text_f f, :url, :size => "col-md-8", :help_block => _("e.g. https://ovirt.example.com/ovirt-engine/api"), :help_inline => documentation_button('5.2.7oVirt/RHEVNotes') %>
<%= checkbox_f f, :use_v4, :checked => f.object.use_v4?,
:label => _('Use APIv4'),
:help_inline => _("Use the new engine API.") %>
:help_inline => _("API v4 is the default version. Uncheck it if you want to use v3, which is deprecated and will be removed in the next release.") %>
<% unless f.object.use_v4? %>
<%= alert :header => '', :class => 'alert-warning', :close => false,
:text => _("Please note, API v3 is deprecated and will be removed completely in the next Foreman release."), :size=> "col-md-8" %>
<% end %>
<%= text_f f, :user, :help_block => _("e.g. admin@internal") %>
<%= password_f f, :password, :keep_value => true, :unset => unset_password? %>
<% datacenters = (f.object.uuid.nil? && controller.action_name != 'test_connection') ? [] : f.object.datacenters rescue []%>
Expand Down
27 changes: 27 additions & 0 deletions config/initializers/deprecations.rb
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
ActiveSupport::Deprecation.behavior = :silence if Rails.env.production?

Foreman::Application.configure do |app|
config.after_initialize do
next if Foreman.in_rake?
next unless Rails.env.production?
next unless ComputeResource.all.unscoped.where(type: 'Foreman::Model::Ovirt').any? { |cr| cr.use_v4 == false }
blueprint = NotificationBlueprint.find_by_name('feature_deprecation')
next unless blueprint
message = UINotifications::StringParser.new(blueprint.message, {feature: 'Ovirt V3 API', version: '2.4'}).to_s
next if blueprint.notifications.where(message: message).any?
Notification.create!(
audience: Notification::AUDIENCE_ADMIN,
message: message,
notification_blueprint: blueprint,
initiator: User.anonymous_admin,
actions: {
links: [
{
href: 'https://community.theforeman.org/t/suggestion-to-drop-ovirt-api-v3-from-foreman/19915',
title: _('Further Information'),
external: true,
},
],
}
)
end
end

0 comments on commit a174f46

Please sign in to comment.