-
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
Support moving a VM to another folder during VM Migrate. #17519
Conversation
568b40e
to
b76fd96
Compare
app/models/ems_folder.rb
Outdated
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") |
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.
Can you use the more common Invoking moveIntoFolder...
/ Invoking moveIntoFolder...Complete
? That makes it easier to grep for one or both.
5bf7e55
to
100569b
Compare
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.
Tested EmsFolder#move_into_folder
and it looks good to me, I'll leave the migrate task review to @gmcculloug
app/models/ems_folder.rb
Outdated
@@ -150,6 +150,18 @@ def register_host(host) | |||
end | |||
end | |||
|
|||
def move_into_folder(vm) |
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.
Why is this implemented at the base ems_folder level instead of in the vmware provider?
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 would be ok if this was implemented at the base as "raise NotImplementedError" and in vmware as doing the concrete work.
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.
There isn't a folder class in the VMware provider currently
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'm good with adding one though
app/models/vm_migrate_task.rb
Outdated
vm.relocate(host, respool, datastore, nil, disk_transform) | ||
end | ||
|
||
folder.move_into_folder(vm) if folder.present? |
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.
If you move this into the provider and don't have it at the base, this can be folder.try(:move_into_folder, vm)
100569b
to
e9f0e98
Compare
Travis failed for constant |
20ad78c
to
f22fcc7
Compare
app/models/vm_migrate_task.rb
Outdated
@@ -66,18 +71,20 @@ def do_request | |||
begin | |||
if vc_method == :migrate | |||
vm.migrate(host, respool) | |||
else | |||
elsif vc_method == :relocate |
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.
Might want to switch to a case statement, but that's minor.
app/models/vm_migrate_task.rb
Outdated
vm.relocate(host, respool, datastore, nil, disk_transform) | ||
end | ||
|
||
folder.try(:move_into_folder, vm) if folder.present? |
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.
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 |
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.
Since you've removed the catchall else
, is there a new catchall?
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.
There is no catchall case here. Only do certain thing when the condition meets.
spec/factories/ems_folder.rb
Outdated
@@ -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 |
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.
if the other vmware_folder objects inherit from this one, then you can set the class once.
spec/factories/ems_folder.rb
Outdated
@@ -69,7 +69,7 @@ | |||
hidden true | |||
end | |||
|
|||
factory :vmware_datacenter, :parent => :vmware_folder, :class => "Datacenter" do | |||
factory :vmware_datacenter, :class => "Datacenter" do |
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 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?
spec/models/vm_migrate_task_spec.rb
Outdated
subject.vm = vm | ||
host = FactoryGirl.create(:host, :name => "test") | ||
options = {:placement_host_name => [host.id, host.name] } | ||
subject.update_attributes(:options => 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.
Prefer to inline the options...
subject.update_attributes(:options =>{:placement_host_name => [host.id, host.name]})
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 |
@Fryguy agreed, we have the |
f22fcc7
to
6ec2e3f
Compare
Checked commit lfu@6ec2e3f with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@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? |
Currently SCVMM does not support VM migrate. |
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