-
Notifications
You must be signed in to change notification settings - Fork 118
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 default cleanup state machine for VM transformation #378
Add default cleanup state machine for VM transformation #378
Conversation
1ecbebb
to
bbfc783
Compare
raise 'No task found. Exiting' if task.nil? | ||
@handle.log(:info, "Task: #{task.inspect}") if @debug | ||
|
||
destination_ems = @handle.vmdb(:ext_management_system).find_by(:id => task.get_option(:destination_ems_id)) |
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.
@fdupont-redhat
Can you check if the destination_ems is present before setting the state var.
destination_vm = @handle.vmdb(:vm).find_by(:id => task.get_option(:destination_vm_id)) | ||
destination_vm.start | ||
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']) |
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.
@fdupont-redhat Check for task being 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.
I check if task is nil, as well as VM.
# Retrieve transformation host | ||
transformation_host = @handle.vmdb(:host).find_by(:id => task.get_option(:transformation_host_id)) | ||
|
||
# Skip if virtv2v has not started yet or is already finished |
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.
@fdupont-redhat
Can all of these skips be in a separate function called validate or valid and you call the remote command only if its valid.
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.
@fdupont-redhat Two minor cleanup items.
def main | ||
task = @handle.vmdb(:service_template_transformation_plan_task).find_by(:id => @handle.root['service_template_transformation_plan_task_id']) | ||
raise 'No task found. Exiting' if task.nil? | ||
@handle.log(:info, "Task: #{task.inspect}") if @debug |
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.
@debug
is referenced here but never defined.
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.
Fixed with default value to false
.
module Common | ||
class VMCheckTransformed | ||
def initialize(handle = $evm) | ||
@debug = true |
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.
and @debug
is referenced here but never used.
Checked commits fabiendupont/manageiq-content@bbfc783~...01b9fa9 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 content/automate/ManageIQ/Transformation/Common.class/methods/assesstransformationcleanup.rb
content/automate/ManageIQ/Transformation/TransformationHosts/Common.class/methods/killvirtv2v.rb
|
…tate_machine Add default cleanup state machine for VM transformation (cherry picked from commit fe3fe98) https://bugzilla.redhat.com/show_bug.cgi?id=1608758
Gaprindashvili backport details:
|
This PR provides the default state machine for VM transformation cleanup. The state machine is triggered from an automate request, as designed in #357. The request creation passes a variable in
$evm.root
:service_template_transformation_plan_task_id
.The process is as follow:
virt-v2v-wrapper
handles cleaning up the destination provider when the virt-v2v command fails, so nothing to do on ManageIQ side.Associated RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1599997