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

Support moving a VM to another folder during VM Migrate. #17519

Merged
merged 1 commit into from
Jun 22, 2018

Conversation

lfu
Copy link
Member

@lfu lfu commented Jun 4, 2018

RHEV v4+ supports VM Migrate. Only supported migration options for RHEV would be shown in the workflow. Folder is one of the unsupported migration options.
SCVMM does not support Migrate.

Includes ManageIQ/manageiq-providers-vmware#285.
Includes ManageIQ/manageiq-schema#219.
Includes ManageIQ/manageiq-ui-classic#4045.

https://bugzilla.redhat.com/show_bug.cgi?id=1090957

@miq-bot assign @gmcculloug
@miq-bot add_label gaprindashvili/no, enhancement

cc @agrare @bronaghs

@miq-bot miq-bot added the wip label Jun 4, 2018
@lfu lfu changed the title [WIP] Support moving a VM to another folder during VM Migrate. Support moving a VM to another folder during VM Migrate. Jun 7, 2018
@miq-bot miq-bot removed the wip label Jun 7, 2018
with_provider_object do |vim_folder|
_log.info("#{log_header} Invoking moveIntoFolder ...")
vim_folder.send(:moveIntoFolder, vm_mor)
_log.info("#{log_header} Invoking moveIntoFolder complete")
Copy link
Member

Choose a reason for hiding this comment

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

Can you use the more common Invoking moveIntoFolder... / Invoking moveIntoFolder...Complete ? That makes it easier to grep for one or both.

@lfu lfu force-pushed the vm_move_folder_1090957 branch 2 times, most recently from 5bf7e55 to 100569b Compare June 7, 2018 18:45
Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

Tested EmsFolder#move_into_folder and it looks good to me, I'll leave the migrate task review to @gmcculloug

@agrare
Copy link
Member

agrare commented Jun 7, 2018

@lfu #17525 was merged so that should fix your refresh issues when moving the host and folder.

@@ -150,6 +150,18 @@ def register_host(host)
end
end

def move_into_folder(vm)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this implemented at the base ems_folder level instead of in the vmware provider?

Copy link
Member

Choose a reason for hiding this comment

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

I would be ok if this was implemented at the base as "raise NotImplementedError" and in vmware as doing the concrete work.

Copy link
Member

Choose a reason for hiding this comment

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

There isn't a folder class in the VMware provider currently

Copy link
Member

Choose a reason for hiding this comment

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

I'm good with adding one though

vm.relocate(host, respool, datastore, nil, disk_transform)
end

folder.move_into_folder(vm) if folder.present?
Copy link
Member

Choose a reason for hiding this comment

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

If you move this into the provider and don't have it at the base, this can be folder.try(:move_into_folder, vm)

@lfu
Copy link
Member Author

lfu commented Jun 11, 2018

Travis failed for constant ManageIQ::Providers::Vmware::InfraManager::EmsFolder that is in ManageIQ/manageiq-providers-vmware#285.

@lfu lfu force-pushed the vm_move_folder_1090957 branch 3 times, most recently from 20ad78c to f22fcc7 Compare June 14, 2018 16:03
@@ -66,18 +71,20 @@ def do_request
begin
if vc_method == :migrate
vm.migrate(host, respool)
else
elsif vc_method == :relocate
Copy link
Member

Choose a reason for hiding this comment

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

Might want to switch to a case statement, but that's minor.

vm.relocate(host, respool, datastore, nil, disk_transform)
end

folder.try(:move_into_folder, vm) if folder.present?
Copy link
Member

Choose a reason for hiding this comment

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

no need to check for presence if you are doing .try

@@ -57,7 +62,7 @@ def do_request
:relocate
elsif respool && host.nil?
:relocate
else
elsif host
:migrate
end
Copy link
Member

Choose a reason for hiding this comment

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

Since you've removed the catchall else, is there a new catchall?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no catchall case here. Only do certain thing when the condition meets.

@@ -19,27 +19,27 @@
# VMware specific folders
#

factory :vmware_folder, :parent => :ems_folder do
factory :vmware_folder, :parent => :ems_folder, :class => "ManageIQ::Providers::Vmware::InfraManager::Folder" do
Copy link
Member

Choose a reason for hiding this comment

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

if the other vmware_folder objects inherit from this one, then you can set the class once.

@@ -69,7 +69,7 @@
hidden true
end

factory :vmware_datacenter, :parent => :vmware_folder, :class => "Datacenter" do
factory :vmware_datacenter, :class => "Datacenter" do
Copy link
Member

Choose a reason for hiding this comment

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

I don't like the removal of this. A vmware_datacenter is a vmware_folder, and this is supposed to be used for inheriting the other attributes. Why was this necessary to remove?

subject.vm = vm
host = FactoryGirl.create(:host, :name => "test")
options = {:placement_host_name => [host.id, host.name] }
subject.update_attributes(:options => options)
Copy link
Member

Choose a reason for hiding this comment

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

Prefer to inline the options...

subject.update_attributes(:options =>{:placement_host_name => [host.id, host.name]})

@Fryguy
Copy link
Member

Fryguy commented Jun 19, 2018

I talked with @agrare about this because the introduction of a leaf-class for folders is being done only for VMware, but not for ovirt nor scvmm, and that concerns me. While we could go the path of also changing ovirt and scvmm to introduce leaf classes, and make it consistent, then update this PR to use that, I think that introduces way too much change for what's necessary.

It looks like the reason for introducing the leaf class is to have a place to put the move_into_folder method. However, I think the implementation is upside-down. While vmware itself implements a folder migrate as a method on the folder object itself, we don't have to follow the same API structuring in our AR modeling. Instead, we could have the move_into_folder method live on the Vm model, accepting an EmsFolder object as a parameter. If we do it this way we don't need to introduce any leaf classes for the folder hierarchy. By not introducing leaf classes, we don't need any data migrations nor changes to the other providers.

@agrare
Copy link
Member

agrare commented Jun 19, 2018

@Fryguy agreed, we have the VmOrTemplate::Operations::Relocation module which has methods to move the vm to other hosts and/or storages (relocate and migrate) so we could add this method there.

@miq-bot
Copy link
Member

miq-bot commented Jun 19, 2018

Checked commit lfu@6ec2e3f with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 0 offenses detected
Everything looks fine. ⭐

@agrare
Copy link
Member

agrare commented Jun 20, 2018

@gmcculloug I merged the VMware PR this depends on, I wonder if we should add some supports_feature_mixin entry for this so that move into folder isn't shown for all providers?

@lfu
Copy link
Member Author

lfu commented Jun 21, 2018

Currently SCVMM does not support VM migrate.
For RHEV 4.0+, folder is one of the fields that are excluded from VM Migrate.
So we are good with the folder visibility in the migrate workflow.

@gmcculloug
Copy link
Member

Thanks @lfu.

@agrare Seems like a good idea overall, but does not appear that we need to hold up this PR to add it. Could be added as a later refactoring.

@gmcculloug gmcculloug merged commit adb2759 into ManageIQ:master Jun 22, 2018
@gmcculloug gmcculloug added this to the Sprint 89 Ending Jul 2, 2018 milestone Jun 22, 2018
@lfu lfu deleted the vm_move_folder_1090957 branch September 29, 2018 14:30
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.

5 participants