-
Notifications
You must be signed in to change notification settings - Fork 897
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 Migrate support to RHEV provider #11366
Add Migrate support to RHEV provider #11366
Conversation
def vm_migrate(vm, options = {}) | ||
host_id = URI(options[:host]).path.split('/').last | ||
|
||
mig_options = { |
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.
What is mig? Is that migration? If so, prefer spelling it out for readability/clarity.
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.
yes, migration. Changed.
:id => host_id | ||
} | ||
} | ||
connection = connect(:version => 4) |
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.
Prefer with_provider_connection helper which auto-closes.
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.
done
end | ||
|
||
def field_unsupported(key) | ||
@manager.respond_to? :unsupported_migration_options and |
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.
Prefer &&
over and
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.
done
@gmcculloug Please review. I'm not sure about the changes for unsupported fields. I feel like they should be at the base class, but you might know better. |
447c1e4
to
7914d29
Compare
} | ||
} | ||
|
||
with_provider_connection(:version => 4) do |connection| |
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.
@borod108 do you know how to behave in case of old api level?
7914d29
to
503c80e
Compare
@borod108 have you ever seen this travis failure? I have no idea if that has anything to do with my patch, it fails on |
@jelkosz nope, did you try to run tests on local? |
bcae041
to
80b556c
Compare
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
80b556c
to
97c459c
Compare
@miq-bot add_label euwe/yes |
@@ -22,6 +22,8 @@ def get_source_and_targets(refresh = false) | |||
return @target_resource = {} if ems.length != 1 | |||
|
|||
result = {:ems => ci_to_hash_struct(ems.first)} | |||
@manager = ems.first |
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 think you can remove this here and inline that below in field_unsupported
Because like this its adding a side effect to this method
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 don't see any good way of doing it since the ems
is a result of
ems = @values[:src_ids].to_miq_a.collect { |v_id| v = Vm.find_by_id(v_id); v.ext_management_system }.uniq.compact
which I don't really want to repeat in field_unsupported
.
But this method anyway have side effects so not sure this is an issue.
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.
how about moving ems
into its own method with memoization then?
But lets wait for @mkanoor to chime in
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.
@bdunne
Can you please help review this it relates to RHEVM
super unless field_unsupported(key) | ||
end | ||
|
||
def field_unsupported(key) |
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.
@mkanoor can you have a look at this or somebody from your team that has experience with this?
I'm not sure if this is how we handle partially supported fields
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.
This needs tests
@@ -100,6 +100,20 @@ def prepare_disk(disk_spec, ems_storage_uid) | |||
} | |||
end | |||
|
|||
def vm_migrate(vm, options = {}) |
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.
Shouldn't this live under the VM operations instead of the manager?
@@ -118,4 +132,8 @@ def remove_disks(disks, vm) | |||
disks.each { |disk_id| service.attachment_service(disk_id).remove } | |||
end | |||
end | |||
|
|||
def unsupported_migration_options |
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.
same
@@ -38,6 +40,15 @@ def get_source_and_targets(refresh = false) | |||
@target_resource = result | |||
end | |||
|
|||
def add_target(dialog_key, key, klass, result) | |||
super unless field_unsupported(key) |
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.
It would be great if logic was positive case rather than the current double negative "unless unsupported"
028ab6d
to
b8283f7
Compare
@@ -119,4 +119,23 @@ def remove_disks(disks, vm) | |||
disks.each { |disk_id| service.attachment_service(disk_id).remove } | |||
end | |||
end | |||
|
|||
def vm_migrate(vm, options = {}) |
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 was expecting migrate
to be a VM operation. Any reason that this is on the infra manager instead?
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 was trying to make it similar to the vmware provider where it is also placed in the infra manager. Also, it needs to be called from the vm_migrate_workflow
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.
yes, this how our api currently works. VmOrTemaplate#migrate
calls VmOrTemaplate#raw_migrate
which calls Ems#vm_migrate
- so this should work
@bdunne I'm fine with the non-automate part. If you think the workflow part is good, I think this can be merged. |
@jelkosz There are a couple of remaining rubocop comments. Otherwise looks good 👍 |
b8283f7
to
3866681
Compare
@jelkosz thanks for addressing the rubocop stuff @gmcculloug can you merge this please? @bdunne and me are 👍 |
3866681
to
bc4c103
Compare
Checked commits jelkosz/manageiq@1581e45~...bc4c103 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 |
@gmcculloug @bdunne Only rebased and added a check to allow this code only for api version 4. The travis failure is not related, all commits are failing on this same issue. |
@miq-bot add_label blocker |
@jelkosz Is there a BZ related to this change? |
Add Migrate support to RHEV provider (cherry picked from commit 99adc9d) https://bugzilla.redhat.com/show_bug.cgi?id=1392005
Euwe Backport details: $ git log -1
commit ab440c5fe20e3e35ceb5e2443b0ae1250b032ee5
Author: Greg McCullough <gmccullo@redhat.com>
Date: Thu Nov 3 14:43:17 2016 -0400
Merge pull request #11366 from jelkosz/add-migrate-to-rhev-provider
Add Migrate support to RHEV provider
(cherry picked from commit 99adc9df0da7a25bfd220a153680cef6fc9e767c)
https://bugzilla.redhat.com/show_bug.cgi?id=1392005 |
A simple implementation which adds the support to migrating of virtual machines in the ovirt/rhev.
https://bugzilla.redhat.com/show_bug.cgi?id=1373079