-
Notifications
You must be signed in to change notification settings - Fork 367
Drop Diagnostics > Collect Logs #9704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -803,7 +803,6 @@ def set_method_form_vars | |
| else | ||
| _("Editing Automate Method \"%{name}\"") % {:name => @ae_method.name} | ||
| end | ||
| session[:log_depot_default_verify_status] = false | ||
| session[:edit] = @edit | ||
| session[:changed] = @changed = false | ||
| end | ||
|
|
@@ -1024,14 +1023,11 @@ def form_method_field_changed | |
| end | ||
| @edit[:new][:fields][f[1].to_i]['default_value'] = nil | ||
| end | ||
| if @edit[:default_verify_status] != session[:log_depot_default_verify_status] | ||
| session[:log_depot_default_verify_status] = @edit[:default_verify_status] | ||
| page << if @edit[:default_verify_status] | ||
| "miqValidateButtons('show', 'default_');" | ||
| else | ||
| "miqValidateButtons('hide', 'default_');" | ||
| end | ||
| end | ||
| page << if @edit[:default_verify_status] | ||
| "miqValidateButtons('show', 'default_');" | ||
| else | ||
| "miqValidateButtons('hide', 'default_');" | ||
| end | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I honestly don't understand this code nor why there was anything log_depot related in the miq_ae_class_controller in the first place - feels like a copypaste error. I did verify that on the AeClass method page, that the Validate button correctly enables/disables itself, and it seems to be working as expected. |
||
| page << javascript_for_miq_button_visibility_changed(@changed) | ||
| page << "miqSparkle(false)" | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,80 +74,6 @@ def pm_refresh_workers | |
| end | ||
| alias refresh_workers pm_refresh_workers | ||
|
|
||
| def log_depot_edit | ||
| assert_privileges("#{@sb[:selected_typ] == "miq_server" ? "" : "zone_"}log_depot_edit") | ||
| @record = @sb[:selected_typ].classify.constantize.find(@sb[:selected_server_id]) | ||
| # @schedule = nil # setting to nil, since we are using same view for both db_back and log_depot edit | ||
| case params[:button] | ||
| when "cancel" | ||
| @in_a_form = false | ||
| @edit = session[:edit] = nil | ||
| add_flash(_("Edit Log Depot settings was cancelled by the user")) | ||
| diagnostics_set_form_vars | ||
| replace_right_cell(:nodetype => x_node) | ||
| when "save" | ||
| if @flash_array | ||
| javascript_flash(:spinner_off => true) | ||
| return | ||
| end | ||
|
|
||
| begin | ||
| if params[:log_protocol].blank? | ||
| @record.log_file_depot.try(:destroy) | ||
| else | ||
| new_uri = "#{params[:uri_prefix]}://#{params[:uri]}" | ||
| raise _("Unsupported log depot protocol: %{protocol}") % {:protocol => params[:log_protocol]} unless FileDepot.supported_depots.key?(params[:log_protocol]) | ||
|
|
||
| build_supported_depots_for_select | ||
| log_protocol = params[:log_protocol] | ||
| protocols = FileDepot.supported_depots.map { |k, _v| [k, k.constantize] }.to_h | ||
| raise _('Invalid or unsupported file depot type.') unless protocols.key?(log_protocol) | ||
|
|
||
| depot = @record.log_file_depot.instance_of?(protocols[log_protocol]) ? @record.log_file_depot : @record.build_log_file_depot(:type => log_protocol) | ||
| depot.update(:uri => new_uri, :name => params[:depot_name]) | ||
| creds = set_credentials | ||
| depot.update_authentication(creds) if protocols[log_protocol].try(:requires_credentials?) | ||
| @record.save! | ||
| end | ||
| rescue => bang | ||
| add_flash(_("Error during 'Save': %{message}") % {:message => bang.message}, :error) | ||
| @changed = true | ||
| render :update do |page| | ||
| page << javascript_prologue | ||
| page.replace_html("diagnostics_collect_logs", :partial => "ops/log_collection") | ||
| end | ||
| else | ||
| add_flash(_("Log Depot Settings were saved")) | ||
| @edit = nil | ||
| diagnostics_set_form_vars | ||
| replace_right_cell(:nodetype => x_node) | ||
| end | ||
| when "validate" | ||
| creds = set_credentials | ||
| settings = { | ||
| :username => creds[:default][:userid], | ||
| :password => creds[:default][:password], | ||
| :uri => "#{params[:uri_prefix]}://#{params[:uri]}" | ||
| } | ||
|
|
||
| begin | ||
| log_protocol = params[:log_protocol] | ||
| protocols = FileDepot.supported_depots.map { |k, _v| [k, k.constantize] }.to_h | ||
| raise _("Unsupported log depot protocol: %{protocol}") % {:protocol => log_protocol} unless protocols.key?(log_protocol) | ||
|
|
||
| protocols[log_protocol].validate_settings(settings) | ||
| rescue => bang | ||
| add_flash(_("Error during 'Validate': %{message}") % {:message => bang.message}, :error) | ||
| else | ||
| add_flash(_("Log Depot Settings were validated")) | ||
| end | ||
| javascript_flash(:spinner_off => true) | ||
| when nil # Reset or first time in | ||
| @in_a_form = true | ||
| replace_right_cell(:nodetype => "log_depot_edit") | ||
| end | ||
| end | ||
|
|
||
| # Send the log in text format | ||
| def fetch_log | ||
| assert_privileges("fetch_log") | ||
|
|
@@ -257,36 +183,6 @@ def cu_repair | |
| end | ||
| end | ||
|
|
||
| def log_collection_form_fields | ||
| assert_privileges("#{@sb[:selected_typ] == "miq_server" ? "" : "zone_"}log_depot_edit") | ||
| @record = @sb[:selected_typ].classify.constantize.find(@sb[:selected_server_id]) | ||
| log_depot = @record.log_file_depot | ||
| log_depot_json = log_depot ? build_log_depot_json(log_depot) : build_empty_log_depot_json | ||
| render :json => log_depot_json | ||
| end | ||
|
|
||
| def build_log_depot_json(log_depot) | ||
| prefix, uri = log_depot[:uri].to_s.split('://') | ||
| klass = @record.log_file_depot.try(:class) | ||
|
|
||
| log_depot_json = {:depot_name => log_depot[:name], | ||
| :uri => uri, | ||
| :uri_prefix => prefix, | ||
| :log_userid => log_depot.authentication_userid, | ||
| :log_protocol => klass.to_s} | ||
| log_depot_json | ||
| end | ||
|
|
||
| def build_empty_log_depot_json | ||
| log_depot_json = {:depot_name => '', | ||
| :uri => '', | ||
| :uri_prefix => '', | ||
| :log_userid => '', | ||
| :log_password => '', | ||
| :log_protocol => ''} | ||
| log_depot_json | ||
| end | ||
|
|
||
| def diagnostics_server_list | ||
| assert_privileges("ops_diagnostics_server_view") | ||
|
|
||
|
|
@@ -376,31 +272,6 @@ def cu_repair_get_form_vars | |
| end | ||
| end | ||
|
|
||
| # Collect the current logs from the selected zone or server | ||
| def logs_collect(options = {}) | ||
| options[:support_case] = params[:support_case] if params[:support_case] | ||
| obj, id = x_node.split("-") | ||
| assert_privileges("#{obj == "z" ? "zone_" : ""}collect_logs") | ||
| klass = obj == "svr" ? MiqServer : Zone | ||
| instance = @selected_server = klass.find(id.to_i) | ||
| if !instance.active? | ||
| add_flash(_("Cannot start log collection, requires a started server"), :error) | ||
| elsif instance.log_collection_active_recently? | ||
| add_flash(_("Cannot start log collection, a log collection is already in progress within this scope"), :error) | ||
| else | ||
| begin | ||
| options[:context] = klass.name | ||
| instance.synchronize_logs(session[:userid], options) | ||
| rescue => bang | ||
| add_flash(_("Log collection error returned: %{error_message}") % {:error_message => bang.message}, :error) | ||
| else | ||
| add_flash(_("Log collection for %{product} %{object_type} %{name} has been initiated") % {:product => Vmdb::Appliance.PRODUCT_NAME, :object_type => klass.name, :name => instance.display_name}) | ||
| end | ||
| end | ||
| get_node_info(x_node) | ||
| replace_right_cell(:nodetype => x_node) | ||
| end | ||
|
|
||
| # Reload the selected node and redraw the screen via ajax | ||
| def refresh_server_summary | ||
| assert_privileges("refresh_server_summary") | ||
|
|
@@ -677,7 +548,7 @@ def diagnostics_set_form_vars | |
| @sb[:selected_typ] = "miq_server" | ||
| end | ||
| else | ||
| @sb[:active_tab] = "diagnostics_collect_logs" # setting it to show collect logs tab as first tab for the servers that are not started | ||
| @sb[:active_tab] = "diagnostics_summary" # setting it to summary tab as first tab for the servers that are not started | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure how to test this as I can't figure out how the code hits this else condition. |
||
| @record = @selected_server = MiqServer.find(x_node.split("-").last.to_i) | ||
| @sb[:selected_server_id] = @selected_server.id | ||
| @sb[:selected_typ] = "miq_server" | ||
|
|
@@ -726,20 +597,4 @@ def diagnostics_get_info | |
| diagnostics_set_form_vars | ||
| end | ||
| end | ||
|
|
||
| def build_supported_depots_for_select | ||
| not_supported_depots = %w[FileDepotS3 FileDepotSwift] | ||
| supported_depots = FileDepot.supported_depots.reject { |model, _desc| not_supported_depots.include?(model) } | ||
| @uri_prefixes = supported_depots.keys.map { |model| [model, model.constantize.uri_prefix] }.to_h | ||
| @supported_depots_for_select = {'' => _('<No Depot>')}.merge(supported_depots) | ||
| end | ||
|
|
||
| def set_credentials | ||
| creds = {} | ||
| if params[:log_userid] | ||
| log_password = params[:log_password] || @record.log_file_depot.authentication_password | ||
| creds[:default] = {:userid => params[:log_userid], :password => log_password} | ||
| end | ||
| creds | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -267,6 +267,9 @@ def schedule_disable | |
| schedule_toggle(false) | ||
| end | ||
|
|
||
| # TODO: I think we can drop this now that log collection is dropped, however, PXE needs FileDepot validation, and | ||
| # I'm not sure if this method is also used by PXE validation. Note that application_controller has a log_depot_validate | ||
| # as well, which might be the one used for PXE. By extension, build_uri_settings can probably also be dropped. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving this TODO in here for now, and I will handle this in a follow up. I don't want to mess with the PXE path and overcomplicate this PR. |
||
| def log_depot_validate | ||
| assert_privileges("schedule_admin") | ||
|
|
||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not changing this at the moment as I don't want to mess with PXE.