Skip to content

Commit

Permalink
Revert "Merge pull request #568 from fdupont-redhat/v2v_state_machine…
Browse files Browse the repository at this point in the history
  • Loading branch information
simaishi committed Dec 3, 2019
1 parent 1c76cd2 commit 913b4fe
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module ManageIQ
module Automate
module Transformation
module Infrastructure
module VM
module Common
class PowerOff
def initialize(handle = $evm)
@handle = handle
@task = ManageIQ::Automate::Transformation::Common::Utils.task(@handle)
@source_vm = ManageIQ::Automate::Transformation::Common::Utils.source_vm(@handle)
end

def main
return if @source_vm.power_state == 'off'
if @handle.state_var_exist?(:vm_shutdown_in_progress)
@source_vm.stop if @handle.root['ae_state_retries'].to_i > 10
else
@source_vm.shutdown_guest
@handle.set_state_var(:vm_shutdown_in_progress, true)
end
@handle.root['ae_result'] = 'retry'
rescue => e
@handle.set_state_var(:ae_state_progress, 'message' => e.message)
raise
end
end
end
end
end
end
end
end

ManageIQ::Automate::Transformation::Infrastructure::VM::Common::PowerOff.new.main
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
object_type: method
version: 1.0
object:
attributes:
name: PowerOff
display_name:
description:
scope: instance
language: ruby
location: inline
embedded_methods:
- "/Transformation/Common/Utils"
options: {}
inputs: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: PreTransform
inherits:
description:
fields:
- State5:
value: "/Transformation/Infrastructure/VM/Common/PowerOff"
on_entry: /System/CommonMethods/MiqAe.WeightedUpdateStatus(weight => 40, description
=> "Power off", task_message => "Pre-migration")
on_exit: /System/CommonMethods/MiqAe.WeightedUpdateStatus(weight => 40, description
=> "Power off", task_message => "Pre-migration")
on_error: /System/CommonMethods/MiqAe.WeightedUpdateStatus(weight => 40, description
=> "Power off", task_message => "Pre-migration")
max_retries: '20'
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ object:
on_error: /System/CommonMethods/MiqAe.WeightedUpdateStatus(weight => 1, description
=> "Waiting for Handover", task_message => "Pre-migration")
max_retries: '86400'
- State8:
value: "/Transformation/StateMachines/VMTransformation/PreTransform?state_ancestry=${#state_ancestry}/${#ae_state}"
on_entry: /System/CommonMethods/MiqAe.WeightedUpdateStatus(weight => 2, description
=> "Pre Transform VM")
on_exit: /System/CommonMethods/MiqAe.WeightedUpdateStatus(weight => 2, description
=> "Pre Transform VM")
on_error: /System/CommonMethods/MiqAe.WeightedUpdateStatus(weight => 2, description
=> "Pre Transform VM")
- State11:
value: "/Transformation/StateMachines/VMTransformation/Transform?state_ancestry=${#state_ancestry}/${#ae_state}"
on_entry: /System/CommonMethods/MiqAe.WeightedUpdateStatus(weight => 85, description
Expand Down

0 comments on commit 913b4fe

Please sign in to comment.