-
Notifications
You must be signed in to change notification settings - Fork 900
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
Generic Object wrapper method for API calls #16077
Generic Object wrapper method for API calls #16077
Conversation
@jntullo I am wondering whether method GenericObject is a special class. We want to define as few methods as possible while leave all the method names available to customers. |
@bzwei unfortunately it doesn't work, since we need to queue the method. When trying your suggestion by setting the ae_user_identity prior to calling the method (via the queue), |
@mkanoor great, thank you! |
You might want to create 2 PR's 1 in manageiq for the generic object and 1 for the manageiq-api @user ||= User.current_user
@group ||= User.current_user.current_group
@tenant ||= User.current_user.current_tenant All these variables would be set the Queue worker that is going to dispatch the work. When you call it from the API side you have to set the user_id, group_id, tenant_id via the queue_options in MiqTask.create_generic_action_with_callback. :user_id => User.current_user.id,
:group_id =>User.current_user.current_group.id,
:tenant_id => User.current_user.current_tenant.id |
@jntullo https://github.com/ManageIQ/manageiq-api/blob/eb172af56203e8f1747d98a17217d1d91ce715a9/app/controllers/api/base_controller/action.rb#L27 |
@jntullo This would allow us to slowly add this functionality as and when we need user context. If we introduce it directly inside of queue_object_action all the methods would be running within a specific user context and the results might not be what you are expecting. |
Checked commits jntullo/manageiq@5d1a3e8~...23b428c with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 spec/models/generic_object_spec.rb
|
closing in favor of #16120 |
This PR creates a wrapper around the generic object method that is to be called via the API. For the methods to be called successfully,
ae_user_identity
must be set first. This new method,call_queued_method
, will be queued by the API to set theae_user_identity
and then call the requested action with specified parameters in order to properly execute the associated automate method.It may help to see a visual, so here it is in action being called from the API (working with what will soon be an API PR + ManageIQ/manageiq-automation_engine#74, + the always handy
simulate_queue_worker
).Without parameters:

With parameters:

Naming is hard, so I am open to suggestions.
cc: @lfu @mkanoor @abellotti
@miq-bot add_label enhancement, automate
@miq-bot assign @gmcculloug