Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

[WIP] Add payload download action to the UI worker. #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/controllers/migration_analytics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,30 @@ def layout_full_center
end
end

def payload
check_feature_enabled
task_id = params['task_id']
raise "Must specify a task id via \"task_id\"" if task_id.blank?

begin
task = MiqTask.find(task_id)
path = task&.context_data&.payload_path
if path && File.exist?(path)
send_file(path, :type => 'application/binary', :filename => 'analytics_payload.bin')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to parse out the filename as it is on disk and retain it instead of using analytics_payload.bin?

else
raise "Payload not found."
end
rescue ActiveRecord::RecordNotFound => e
action_result(false, e.to_s)
end
end

menu_section :migration

private
def check_feature_enabled
unless Settings.prototype.migration_analytics.enabled
raise ActionController::RoutingError, 'Feature Not Enabled'
end
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Rails.application.routes.draw do
if Settings.prototype.migration_analytics.enabled
get "/migration_analytics", to: "migration_analytics#index"
get "/migration_analytics/payload", to: "migration_analytics#payload"
end
end