Skip to content

Commit 2fefe94

Browse files
authored
Merge pull request #9711 from Fryguy/drop_log_collection2
Drop Log Collection validation
2 parents 8be0ccf + 4b80dd3 commit 2fefe94

File tree

7 files changed

+1
-157
lines changed

7 files changed

+1
-157
lines changed

app/controllers/application_controller.rb

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -425,55 +425,6 @@ def report_only
425425
render 'shared/show_report', :layout => 'report_only'
426426
end
427427

428-
# moved this method here so it can be accessed from pxe_server controller as well
429-
# this is a terrible name, it doesn't validate log_depots
430-
# TODO: I think we can move this back to the pxe_server_controller and eliminate all non-pxe code paths
431-
def log_depot_validate
432-
@schedule = nil # setting to nil, since we are using same view for both db_back and log_depot edit
433-
# if zone is selected in tree replace tab#3
434-
pfx = if x_active_tree == :diagnostics_tree
435-
if @sb[:active_tab] == "diagnostics_database"
436-
# coming from diagnostics/database tab
437-
"dbbackup"
438-
end
439-
elsif session[:edit]&.key?(:pxe_id)
440-
# add/edit pxe server
441-
"pxe"
442-
else
443-
# add/edit dbbackup schedule
444-
"schedule"
445-
end
446-
447-
id = params[:id] || "new"
448-
if pfx == "pxe"
449-
return unless load_edit("#{pfx}_edit__#{id}")
450-
451-
settings = {:username => @edit[:new][:log_userid], :password => @edit[:new][:log_password]}
452-
settings[:uri] = @edit[:new][:uri_prefix] + "://" + @edit[:new][:uri]
453-
else
454-
settings = {:username => params[:log_userid], :password => params[:log_password]}
455-
settings[:uri] = "#{params[:uri_prefix]}://#{params[:uri]}"
456-
settings[:uri_prefix] = params[:uri_prefix]
457-
end
458-
459-
begin
460-
if pfx == "pxe"
461-
msg = _('PXE Credentials successfully validated')
462-
PxeServer.verify_depot_settings(settings)
463-
else
464-
msg = _('Depot Settings successfully validated')
465-
MiqSchedule.new.verify_file_depot(settings)
466-
end
467-
rescue StandardError => bang
468-
add_flash(_("Error during 'Validate': %{error_message}") % {:error_message => bang.message}, :error)
469-
else
470-
add_flash(msg)
471-
end
472-
473-
@changed = (@edit[:new] != @edit[:current]) if pfx == "pxe"
474-
javascript_flash
475-
end
476-
477428
# to reload currently displayed summary screen in explorer
478429
def reload
479430
@_params[:id] = x_node

app/controllers/ops_controller/settings/schedules.rb

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,6 @@ def schedule_edit
119119
# This is only because ops_controller tries to set form locals, otherwise we should not use the @edit variable
120120
@edit = {:sched_id => @schedule.id}
121121

122-
depot = @schedule.file_depot
123-
full_uri, _query = depot.try(:uri)&.split('?')
124-
@uri_prefix, @uri = full_uri.to_s.split('://')
125-
@log_userid = depot.try(:authentication_userid)
126-
@log_password = depot.try(:authentication_password)
127-
@log_aws_region = depot.try(:aws_region)
128-
@openstack_region = depot.try(:openstack_region)
129-
@keystone_api_version = depot.try(:keystone_api_version)
130-
@v3_domain_ident = depot.try(:v3_domain_ident)
131-
@swift_api_port = full_uri.blank? ? nil : URI(full_uri).port
132-
@security_protocol = depot.try(:security_protocol)
133-
134122
# This is a hack to trick the controller into thinking we loaded an edit variable
135123
session[:edit] = {:key => "schedule_edit__#{@schedule.id || 'new'}"}
136124

@@ -267,29 +255,6 @@ def schedule_disable
267255
schedule_toggle(false)
268256
end
269257

270-
# TODO: I think we can drop this now that log collection is dropped, however, PXE needs FileDepot validation, and
271-
# I'm not sure if this method is also used by PXE validation. Note that application_controller has a log_depot_validate
272-
# as well, which might be the one used for PXE. By extension, build_uri_settings can probably also be dropped.
273-
def log_depot_validate
274-
assert_privileges("schedule_admin")
275-
276-
if params[:log_password]
277-
file_depot = FileDepot.new
278-
else
279-
id = params[:id] || params[:backup_schedule_type]
280-
file_depot = MiqSchedule.find(id).file_depot
281-
end
282-
uri_settings = build_uri_settings(file_depot)
283-
begin
284-
MiqSchedule.new.verify_file_depot(uri_settings)
285-
rescue => bang
286-
add_flash(_("Error during 'Validate': %{message}") % {:message => bang.message}, :error)
287-
else
288-
add_flash(_('Depot Settings successfuly validated'))
289-
end
290-
javascript_flash
291-
end
292-
293258
private
294259

295260
def schedule_check_compliance?(schedule)
@@ -726,18 +691,6 @@ def build_schedule_options_for_select
726691
]
727692
end
728693

729-
def retrieve_aws_regions
730-
ManageIQ::Providers::Amazon::Regions.regions.flat_map { |region| [region[1].values_at(:description, :name)] }
731-
end
732-
733-
def retrieve_openstack_api_versions
734-
[['Keystone v2', 'v2'], ['Keystone v3', 'v3']]
735-
end
736-
737-
def retrieve_security_protocols
738-
[[_('SSL without validation'), 'ssl'], [_('SSL'), 'ssl-with-validation'], [_('Non-SSL'), 'non-ssl']]
739-
end
740-
741694
def schedule_set_basic_record_vars(schedule)
742695
schedule.name = params[:name]
743696
schedule.description = params[:description]
@@ -762,27 +715,4 @@ def schedule_set_interval_record_vars(schedule)
762715
schedule.run_at[:interval][:unit] = params[:timer_typ].downcase
763716
schedule.run_at[:interval][:value] = params[:timer_value]
764717
end
765-
766-
def build_uri_settings(file_depot)
767-
uri_settings = {}
768-
type = FileDepot.supported_protocols[params[:uri_prefix]]
769-
raise _("Invalid or unsupported file depot type.") if type.nil?
770-
771-
protocols = FileDepot.supported_depots.map { |k, _v| [k, k.constantize] }.to_h
772-
if protocols[type].try(:requires_credentials?)
773-
log_password = params[:log_password] || file_depot.try(:authentication_password)
774-
uri_settings = {:username => params[:log_userid], :password => log_password}
775-
end
776-
uri_settings[:uri] = "#{params[:uri_prefix]}://#{params[:uri]}"
777-
uri_settings[:uri_prefix] = params[:uri_prefix]
778-
uri_settings[:log_protocol] = params[:log_protocol]
779-
uri_settings[:aws_region] = params[:log_aws_region]
780-
uri_settings[:openstack_region] = params[:openstack_region]
781-
uri_settings[:keystone_api_version] = params[:keystone_api_version]
782-
uri_settings[:v3_domain_ident] = params[:v3_domain_ident]
783-
uri_settings[:security_protocol] = params[:security_protocol]
784-
uri_settings[:swift_api_port] = params[:swift_api_port]
785-
uri_settings[:type] = type
786-
uri_settings
787-
end
788718
end

app/controllers/pxe_controller/pxe_servers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def pxe_server_async_cred_validation
183183
render :json => {:status => 'error', :message => _("Error during 'Validate': %{error_message}") % {:error_message => bang.message}}
184184
end
185185

186-
render :json => {:status => 'success', :message => _('PXE Credentials successfuly validated')}
186+
render :json => {:status => 'success', :message => _('PXE Credentials successfully validated')}
187187
end
188188

189189
private #######################

config/routes.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,6 @@
26662666
explorer
26672667
iso_datastore_list
26682668
iso_image_edit
2669-
log_depot_validate
26702669
pxe_image_edit
26712670
pxe_image_type_edit
26722671
pxe_image_type_list

spec/config/routes.pending.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,6 @@ PlacementGroupController:
10401040
- sections_field_changed
10411041
PxeController:
10421042
- accordion_select
1043-
- log_depot_validate
10441043
- pxe_server_async_cred_validation
10451044
- reload
10461045
- report_data

spec/controllers/ops_controller/settings/schedules_spec.rb

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -82,35 +82,6 @@
8282
end
8383
end
8484

85-
context "#build_uri_settings" do
86-
let(:mocked_filedepot) { double(FileDepotSmb) }
87-
it "uses params[:log_password] for validation if one exists" do
88-
controller.params = {:log_userid => "userid",
89-
:log_password => "password2",
90-
:uri_prefix => "smb",
91-
:uri => "samba_uri",
92-
:log_protocol => "Samba"}
93-
settings = {:username => "userid",
94-
:password => "password2",
95-
:uri => "smb://samba_uri",
96-
:uri_prefix => "smb"}
97-
expect(controller.send(:build_uri_settings, mocked_filedepot)).to include(settings)
98-
end
99-
100-
it "uses the stored password for validation if params[:log_password] does not exist" do
101-
controller.params = {:log_userid => "userid",
102-
:uri_prefix => "smb",
103-
:uri => "samba_uri",
104-
:log_protocol => "Samba"}
105-
expect(mocked_filedepot).to receive(:try).with(:authentication_password).and_return('password')
106-
settings = {:username => "userid",
107-
:password => "password",
108-
:uri => "smb://samba_uri",
109-
:uri_prefix => "smb"}
110-
expect(controller.send(:build_uri_settings, mocked_filedepot)).to include(settings)
111-
end
112-
end
113-
11485
context "#schedule_set_record_vars" do
11586
let(:user) { stub_user(:features => :all) }
11687
let(:schedule) { FactoryBot.create(:miq_automate_schedule) }

spec/routing/pxe_routing_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
end
2828
end
2929

30-
describe "#log_depot_validate" do
31-
it "routes with POST" do
32-
expect(post("/pxe/log_depot_validate")).to route_to("pxe#log_depot_validate")
33-
end
34-
end
35-
3630
describe "#pxe_image_edit" do
3731
it "routes with POST" do
3832
expect(post("/pxe/pxe_image_edit")).to route_to("pxe#pxe_image_edit")

0 commit comments

Comments
 (0)