From 913b4fe437777abe6f117c960b9f3f922a3b4b2e Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Tue, 3 Dec 2019 11:13:01 -0500 Subject: [PATCH] Revert "Merge pull request #568 from fdupont-redhat/v2v_state_machine_shutdown" This reverts commit 1f4748a522a81d77ceb4d9800e85c81e3efb3b5e. https://bugzilla.redhat.com/show_bug.cgi?id=1767545 --- .../VM/Common.class/__methods__/poweroff.rb | 35 +++++++++++++++++++ .../VM/Common.class/__methods__/poweroff.yaml | 15 ++++++++ .../VMTransformation.class/pretransform.yaml | 19 ++++++++++ .../transformation.yaml | 8 +++++ 4 files changed, 77 insertions(+) create mode 100644 content/automate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/poweroff.rb create mode 100644 content/automate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/poweroff.yaml create mode 100644 content/automate/ManageIQ/Transformation/StateMachines/VMTransformation.class/pretransform.yaml diff --git a/content/automate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/poweroff.rb b/content/automate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/poweroff.rb new file mode 100644 index 000000000..d5157b580 --- /dev/null +++ b/content/automate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/poweroff.rb @@ -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 diff --git a/content/automate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/poweroff.yaml b/content/automate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/poweroff.yaml new file mode 100644 index 000000000..19d592eeb --- /dev/null +++ b/content/automate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/poweroff.yaml @@ -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: [] diff --git a/content/automate/ManageIQ/Transformation/StateMachines/VMTransformation.class/pretransform.yaml b/content/automate/ManageIQ/Transformation/StateMachines/VMTransformation.class/pretransform.yaml new file mode 100644 index 000000000..0e123b2b6 --- /dev/null +++ b/content/automate/ManageIQ/Transformation/StateMachines/VMTransformation.class/pretransform.yaml @@ -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' diff --git a/content/automate/ManageIQ/Transformation/StateMachines/VMTransformation.class/transformation.yaml b/content/automate/ManageIQ/Transformation/StateMachines/VMTransformation.class/transformation.yaml index f605f0482..923e9df5a 100644 --- a/content/automate/ManageIQ/Transformation/StateMachines/VMTransformation.class/transformation.yaml +++ b/content/automate/ManageIQ/Transformation/StateMachines/VMTransformation.class/transformation.yaml @@ -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