-
Notifications
You must be signed in to change notification settings - Fork 120
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
Fix default cleanup state machine #382
Merged
gmcculloug
merged 1 commit into
ManageIQ:master
from
fabiendupont:v2v_fix_cleanup_state_machine_poweron
Aug 1, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
.../automate/ManageIQ/Transformation/Common.class/__methods__/assesstransformationcleanup.rb
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...utomate/ManageIQ/Transformation/Common.class/__methods__/assesstransformationcleanup.yaml
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
...mate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/checkpoweredon.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module ManageIQ | ||
module Automate | ||
module Transformation | ||
module Infrastructure | ||
module VM | ||
module Common | ||
class CheckPoweredOn | ||
def initialize(handle = $evm) | ||
@handle = handle | ||
end | ||
|
||
def main | ||
if @handle.root['service_template_transformation_plan_task'].blank? | ||
task = @handle.vmdb(:service_template_transformation_plan_task).find_by(:id => @handle.root['service_template_transformation_plan_task_id']) | ||
vm = task.source if task.present? | ||
else | ||
task = @handle.root['service_template_transformation_plan_task'] | ||
vm = @handle.vmdb(:vm).find_by(:id => task.get_option(:destination_vm_id)) if task.present? | ||
end | ||
return if vm.blank? | ||
@handle.log(:info, "Target VM: #{vm.name} [#{vm.vendor}]") | ||
return if task.get_option(:source_vm_power_state) != 'on' | ||
if vm.power_state != 'on' | ||
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. For readability add spaces between lines when the context changes: I would think something like this: def main
task, vm = task_and_vm
return if vm.blank?
@handle.log(:info, "Target VM: #{vm.name} [#{vm.vendor}]")
return if task.get_option(:source_vm_power_state) != 'on'
if vm.power_state != 'on'
@handle.root["ae_result"] = "retry"
@handle.root["ae_retry_interval"] = "15.seconds"
end
rescue => e
@handle.set_state_var(:ae_state_progress, 'message' => e.message)
raise
end |
||
@handle.root["ae_result"] = "retry" | ||
@handle.root["ae_retry_interval"] = "15.seconds" | ||
end | ||
rescue => e | ||
@handle.set_state_var(:ae_state_progress, 'message' => e.message) | ||
raise | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
if $PROGRAM_NAME == __FILE__ | ||
ManageIQ::Automate::Transformation::Infrastructure::VM::Common::CheckPoweredOn.new.main | ||
end |
File renamed without changes.
36 changes: 0 additions & 36 deletions
36
...omate/ManageIQ/Transformation/Infrastructure/VM/rhevm.class/__methods__/checkpoweredon.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should break this down into methods which would make the logic easier to read.
Move this first if-else block into a method that returns both
task
andvm
:Then the first part of main becomes:
If you think this is too much change it could be in a followup refactoring, but we need to move away for having large single method scripts in general.
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.
The code is identical in
checkpoweredon.rb
andpoweron.rb
. I'd propose movingtask_and_vm
to a embedded utility method. It's a bigger change that may require another PR. I'd go for a followup refactoring.