-
Notifications
You must be signed in to change notification settings - Fork 898
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
[V2V] Set context data for the task associated with conversion host creation #18541
Changes from all commits
54746a1
6cb8de7
313ae94
af27955
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 |
---|---|---|
|
@@ -26,7 +26,21 @@ def queue_configuration(op, instance_id, resource, params, auth_user = nil) | |
:args => [params, auth_user] | ||
} | ||
|
||
MiqTask.generic_action_with_callback(task_opts, queue_opts) | ||
task_id = MiqTask.generic_action_with_callback(task_opts, queue_opts) | ||
|
||
# Set the context_data after the fact because the above call only accepts | ||
# certain options while ignoring the rest. We also don't want to store | ||
# any ssh key information. Useful for a retry option in the UI, and | ||
# informational purposes in general. | ||
# | ||
MiqTask.find(task_id).tap do |task| | ||
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. @djberg96 so you want to use the old method so this can be backported then followup with a refactoring PR to just pass in the context_data? 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. That's the plan, yes. |
||
params = params&.except(:task_id, :miq_task_id) | ||
hash = {:request_params => params&.reject { |key, _value| key.to_s.end_with?('private_key') }} | ||
task.context_data = hash | ||
task.save | ||
end | ||
|
||
task_id | ||
end | ||
|
||
def enable_queue(params, auth_user = nil) | ||
|
@@ -43,13 +57,14 @@ def enable(params, auth_user = nil) | |
params = params.symbolize_keys | ||
_log.info("Enabling a conversion_host with parameters: #{params}") | ||
|
||
params.delete(:task_id) # In case this is being called through *_queue which will stick in a :task_id | ||
params.delete(:miq_task_id) # The miq_queue.activate_miq_task will stick in a :miq_task_id | ||
params.delete(:task_id) # In case this is being called through *_queue which will stick in a :task_id | ||
miq_task_id = params.delete(:miq_task_id) # The miq_queue.activate_miq_task will stick in a :miq_task_id | ||
|
||
vmware_vddk_package_url = params.delete(:vmware_vddk_package_url) | ||
params[:vddk_transport_supported] = !vmware_vddk_package_url.nil? | ||
params[:vddk_transport_supported] = vmware_vddk_package_url.present? | ||
|
||
vmware_ssh_private_key = params.delete(:vmware_ssh_private_key) | ||
params[:ssh_transport_supported] = !vmware_ssh_private_key.nil? | ||
params[:ssh_transport_supported] = vmware_ssh_private_key.present? | ||
|
||
ssh_key = params.delete(:conversion_host_ssh_private_key) | ||
|
||
|
@@ -65,6 +80,13 @@ def enable(params, auth_user = nil) | |
|
||
conversion_host.enable_conversion_host_role(vmware_vddk_package_url, vmware_ssh_private_key) | ||
conversion_host.save! | ||
|
||
if miq_task_id | ||
MiqTask.find(miq_task_id).tap do |task| | ||
task.context_data.to_h[:conversion_host_id] = conversion_host.id | ||
task.save | ||
end | ||
end | ||
end | ||
rescue StandardError => error | ||
raise | ||
|
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.
@djberg96 how about adding
:context_data
to the options hash and pass it to theMiqTask.create!
hereThere 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.
I thought about making modifications there - I think that method could use some refactoring in general - but was worried about introducing some sort of unexpected regression. I'd like to do that in a separate PR if you don't mind. If/when that happens, we can return to this and refactor it.
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.
I'd rather fix it first even if it is in a separate PR, a quick search of the callers should be enough to see if anyone is doing anything strange like passing in invalid keys.
I'd expect to be able to control any of the task attributes in the first argument, so something like:
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.
I actually had this already started, so I've created a WIP here: #18578
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.
Awesome!