Skip to content
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 VM Transformation state machine #252

Merged

Conversation

ghost
Copy link

@ghost ghost commented Feb 22, 2018

This state machine describes the states to transform a virtual machine. It uses nested state machines to easily change the behavior based on source and destination EMS, as well as transformation method.

The update_status.rb method also add tracking information, such as start and update times, and percentage of progress. The percentage is either provided by the method itself, or defaults to the number of retries on the max retries of the state.

It also take into account the nesting by creating an artificial ancestry. The ancestry requires the state machine designer to add the following argument to the URI: ?state_ancestry=${#state_ancestry}/${#ae_state}".

@gmcculloug
Copy link
Member

cc @bzwei

@miq-bot miq-bot added the wip label Feb 22, 2018
# phase (entry, exit, error). This updates the details with live
# data from the method, and also sets sane defaults.
case @handle.root['ae_status_state']
when 'on_entry'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This main method should be broken down into smaller methods. A good place to start is converting these when blocks for the case statement into separate methods.

# state machines. Where running a nested state machines, there can be
# more than one active states: one per level of nesting. The real
# active state is the one with the deepest ancestry.
def current_state(states)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fdupont-redhat
Couldn't you get the current state from root['ae_state']?
We are setting it here https://github.com/ManageIQ/manageiq-automation_engine/blob/master/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_state_machine.rb#L63

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of nested state machines, root [ae_state] contains the name of the current state in the current state machine. And nothing prevents from having two states with the same name when using nested state machines. So, here I take the state ancestry depth as a criteria to distinguish the real running state.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fdupont-redhat
So do you need the fully qualified instance name that is being used at that moment? We have that information we can set it as an extra attribute in the root object.

@@ -0,0 +1,119 @@
module Transformation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

progress['percent'] = reconcile_children_percent('', progress['states'])
end
# We record the progress as a task option.
task.set_option(:progress, progress)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have new method task.update_transformation_progress(progress)

end
# Then, we set the update time to now, which is also finish time
# when the state is finished.
state_hash['updated_on'] = Time.now.utc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task itself has updated_on column. Should not need this one.

@michalskrivanek
Copy link

I guess you're renaming "rhev" to either ovirt or rhv:)
And the steps which are currently designed to work with export domain would be simplified with the upload api - no sysprep, that disk preparation steps...those should be all not required

@miq-bot
Copy link
Member

miq-bot commented Mar 20, 2018

Checked commits fabiendupont/manageiq-content@6ac472d~...0ab65ba with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
6 files checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Yaml - missing config files

@gmcculloug gmcculloug removed the wip label Mar 20, 2018
@gmcculloug gmcculloug changed the title [WIP] Add VM Transformation state machine Add VM Transformation state machine Mar 20, 2018
@gmcculloug
Copy link
Member

@mkanoor Can you give this one last review?

@gmcculloug gmcculloug merged commit d45d46f into ManageIQ:master Mar 21, 2018
@gmcculloug gmcculloug added this to the Sprint 82 Ending Mar 26, 2018 milestone Mar 21, 2018
ghost pushed a commit to fabiendupont/v2v-automate that referenced this pull request Mar 22, 2018
…Q/manageiq-content/pull/248.

Removed code for sysprep state, as we won't use them.
Moved the code to a sub directory to ease import.
simaishi pushed a commit that referenced this pull request May 29, 2018
…nsformation

Add VM Transformation state machine
(cherry picked from commit d45d46f)
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit fd65978a1876d656e176729b2d2d67ee3057261e
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Wed Mar 21 17:26:20 2018 -0400

    Merge pull request #252 from fdupont-redhat/v2v_state_machines_vm_transformation
    
    Add VM Transformation state machine
    (cherry picked from commit d45d46f2f2801eeba43d16dae2a7c9c8482fa717)

@ghost ghost deleted the v2v_state_machines_vm_transformation branch July 11, 2018 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants