-
Notifications
You must be signed in to change notification settings - Fork 121
Add Generic Service Reconfigure entry point #763
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
Add Generic Service Reconfigure entry point #763
Conversation
|
@putmanoj I assume this is mostly copied from another entrypoint, but which one (or is this all brand new)? I just wanted to see them side-by-side so I can understand what I'm looking at. |
Hi @Fryguy Acutally, probably methods can be removed, we could use default methods, if ...
|
81cafe4 to
f25cf2e
Compare
…_action, etc Use common method all all methods, needed to make Reconfigure work,
f25cf2e to
caba3b8
Compare
| def reconfiguration_options | ||
| task = @handle.root["service_reconfigure_task"] | ||
| {:dialog => task.options[:dialog] || {}} | ||
| end | ||
|
|
||
| def update_options | ||
| if service_action == 'Reconfigure' | ||
| reconfiguration_options | ||
| else | ||
| {} |
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.
Note to self: something about this doesn't seem right in the generic lifecycle preprocess, needs investigation (is there a reconfigure override we can stick this in?)
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.
Yes, agree, needs investigation, though for now, did not find anything better than this.
| def self.update_task(message, status = nil, handle = $evm) | ||
| task_name = if handle.root["request"] == "service_reconfigure" | ||
| 'service_reconfigure_task' | ||
| else | ||
| 'service_template_provision_task' | ||
| end | ||
| handle.root[task_name].try do |task| | ||
| task.miq_request.user_message = message | ||
| task.message = status unless status.nil? | ||
| end | ||
| end | ||
|
|
||
| def self.service(handle = $evm) | ||
| if handle.root["request"] == "service_reconfigure" | ||
| task = handle.root["service_reconfigure_task"] | ||
| service = task.source unless task.nil? | ||
| else | ||
| service = handle.root["service"] | ||
| end |
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.
Having this kind of "is it provision or is it reconfigure" logic in a generic utils object also doesn't feel right
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.
Created the utils object (probably could have named it 'common' object), was to hide this "is it provision or is it reconfigure" logic, from the step methods.
At present,
-
servicemethod - need not have the "is it provision or is it reconfigure" logic, as the 'service' object gets added with https://github.com/ManageIQ/manageiq/pull/23405/files#diff-7bcaccf0a5393207d24e32b17c0758232ab7f73c9ae41412c4b25e16b06f5eeaR39 change -
service_actionmethod - needs the "is it provision or is it reconfigure" logic, as did not yet find the way to add the 'service_action' attribute. -
update_taskmethod - needs the "is it provision or is it reconfigure" logic, as simply the task names are named differently, for Provision vs Reconfigure vs Retirement.
Also, would say there is bug in existing update_task method for Retirement, see https://github.com/putmanoj/manageiq-content/blob/master/content/automate/ManageIQ/Service/Generic/StateMachines/GenericLifecycle.class/__methods__/execute.rb#L34
def update_task(message)
@handle.root['service_template_provision_task'].try { |task| task.miq_request.user_message = message }
end
though for Retirement the task_name is 'service_retire_task'
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'm not too familiar with Automate, but I still feel like a lot of this if reconfigure else if retirement else could be replaced by attributes on the class that we could use instead
| if handle.root["request"] == "service_reconfigure" | ||
| task = handle.root["service_reconfigure_task"] |
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.
If we set the service here could we drop this conditional? Seems weird that we have service for prov and retire but not reconfigure
| when "service_retire" | ||
| "service_retire_task" | ||
| else | ||
| "service_template_provision_task" |
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.
What is handle.root["request"] here? Is it service_template_provision? If so could we generically do #{handle.root["request"]}_task}?
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.
You'll notice I'm trying to kill this whole util_object if we can get away with 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.
Check images attached in #763 (comment)
- Provision
- request => "clone_to_service"
- service_action => "Provision"
- Reconfigure
- request => "service_reconfigure"
- service_action => (NOT AVAILABLE) - this is the main reason, need to add the util_object, unless we can fix this in core
- Retirement
- request => "service_retire"
- service_action => "Retirement"
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.
Apart from the task name, where patterns are different, between the actions
| end | ||
| handle.root[task_name].try do |task| | ||
| task.miq_request.user_message = message | ||
| task.message = status unless status.nil? |
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.
Really minor but we tend to prefer the "positive" if status over the "negative" unless status.nil?
|
Checked commits putmanoj/manageiq-content@746e93a~...ca8c626 with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.62.0, and yamllint |
| def self.service(handle = $evm) | ||
| service = handle.root["service"] || service_task(handle)&.source | ||
| service.tap do |s| | ||
| ManageIQ::Automate::System::CommonMethods::Utils::LogObject.log_and_raise("Service not found", handle) if s.nil? | ||
| end | ||
| end |
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.
@putmanoj with ManageIQ/manageiq#23405 merged do we still need this ?



This PR has changes to Service Reconfigure action, will following changes made.
/Service/Generic/StateMachines/GenericLifecycle/reconfigureentry pointPreProcessmethod, to pass dialog params (changes from user), for reconfiguration process/Service/Generic/StateMachines/Utils/util_objectclass, with common methods forservice,service_action&update_task, to use in all the steps methods.Resolves https://jsw.ibm.com/browse/CP4AIOPS-5515