-
Notifications
You must be signed in to change notification settings - Fork 900
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
Allow VMware provision without needing to specify a host #11437
Allow VMware provision without needing to specify a host #11437
Conversation
887cdf6
to
1e044b5
Compare
end | ||
|
||
def dest_folder | ||
folder_id = get_option(:placement_folder_name) | ||
return EmsFolder.find_by(:id => folder_id) if folder_id | ||
|
||
host_dc = dest_host.parent_datacenter || dest_host.ems_cluster.parent_datacenter | ||
dc = dest_cluster ? dest_cluster.parent_datacenter : dest_host.parent_datacenter |
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.
A host always has at least a ComputeResource
but for some reason we only inventory ClusterComputeResource
This line could be simplified to just dc = dest_cluster.parent_datacenter
if we change that, might revisit later.
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 simplification
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
008c857
to
2845e48
Compare
@bdunne Please review |
datastore = selected_placement_obj(:placement_ds_name, Storage) | ||
|
||
raise MiqException::MiqProvisionError, "Destination placement_ds_name not provided" if datastore.nil? | ||
raise MiqException::MiqProvisionError, "Destination placement_host_name and placement_cluster_name not provided" if host.nil? && cluster.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.
One test relies on this method raising an exception if these are missing, not sure if its better to do the checks here or in prepare_for_clone_task
though
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.
The selected_placement_obj
method used by both the manual_placement
and automatic_placement
methods use to raise an error if the object was not defined. Now the manual_placement
method is checking here and the automatic_placement
will not catch the error until prepare_for_clone_task
.
Can we consolidate these checks in the placement
method above? I would move the new raise
logic in prepare_for_clone_task
and do that in the placement
method as well. It makes more sense to do all our placement checking in that one place.
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.
Moved all new checks to placement
@@ -54,18 +57,17 @@ def dest_resource_pool | |||
resource_pool = ResourcePool.find_by(:id => respool_id) unless respool_id.nil? | |||
return resource_pool unless resource_pool.nil? | |||
|
|||
cluster = dest_host.owning_cluster | |||
cluster ? cluster.default_resource_pool : dest_host.default_resource_pool | |||
dest_cluster ? dest_cluster.default_resource_pool : dest_host.default_resource_pool |
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.
Could be simplified to:
dest_cluster.try(:default_resource_pool) || dest_host.default_resource_pool
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 dest_folder | ||
folder_id = get_option(:placement_folder_name) | ||
return EmsFolder.find_by(:id => folder_id) if folder_id | ||
|
||
host_dc = dest_host.parent_datacenter || dest_host.ems_cluster.parent_datacenter | ||
dc = dest_cluster ? dest_cluster.parent_datacenter : dest_host.parent_datacenter |
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 simplification
host_ids = if clone_options[:host] | ||
clone_options[:host].id | ||
else | ||
clone_options[:cluster].hosts.collect(&: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.
Is .hosts
an ActiveRecord Collection? If so, pluck(:id)
would be slightly more efficient.
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
datastore ||= selected_placement_obj(:placement_ds_name, Storage) | ||
return host, datastore | ||
cluster = selected_placement_obj(:placement_cluster_name, EmsCluster) || (host.ems_cluster if host) |
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 host.try(:ems_cluster)
over (host.ems_cluster if host)
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
@@ -435,7 +435,7 @@ | |||
:auto_select_single: false | |||
:description: Name | |||
:required_method: :validate_placement | |||
:required: true | |||
:required: false |
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 this is no longer required, the :required_method:
will not run. I would suggest changing it to a validation_method
and verify that validate_placement
returns the expected result with and without a host selected.
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.
@gmcculloug mentioned not wanting this in here at all yet so it might be moot
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 suggest creating a separate PR for the dialog/workflow validation changes. I suggested this change to @agrare for local testing but did not expect it to be part of the PR.
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.
Yeah my misunderstanding didn't realize it was for local dev, removed.
562db92
to
a10e83c
Compare
@gmcculloug can you review? @miq-bot remove-label wip |
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.
@agrare Do not change the return values for allowed_vlans
in this PR since that will cause issues for automate users. We can look into doing that in a separate PR where we can focus on backwards compatibility. The details would get lost in this PR and we would also not want to back port that change to the Darga branch.
# Find a host in the cluster that has this storage mounted to get the right ems_ref for this | ||
# datastore in the datacenter | ||
datastore = HostStorage.find_by(:storage_id => clone_options[:datastore].id, :host_id => host_ids) | ||
vim_clone_options[:datastore] = datastore.ems_ref if datastore |
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.
Now that this logic is more than a single line it would be clearer to have it in a separate method.
vim_clone_options[:datastore] = datastore_ems_ref(clone_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.
Done
datastore = selected_placement_obj(:placement_ds_name, Storage) | ||
|
||
raise MiqException::MiqProvisionError, "Destination placement_ds_name not provided" if datastore.nil? | ||
raise MiqException::MiqProvisionError, "Destination placement_host_name and placement_cluster_name not provided" if host.nil? && cluster.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.
The selected_placement_obj
method used by both the manual_placement
and automatic_placement
methods use to raise an error if the object was not defined. Now the manual_placement
method is checking here and the automatic_placement
will not catch the error until prepare_for_clone_task
.
Can we consolidate these checks in the placement
method above? I would move the new raise
logic in prepare_for_clone_task
and do that in the placement
method as well. It makes more sense to do all our placement checking in that one place.
@@ -435,7 +435,7 @@ | |||
:auto_select_single: false | |||
:description: Name | |||
:required_method: :validate_placement | |||
:required: true | |||
:required: false |
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 suggest creating a separate PR for the dialog/workflow validation changes. I suggested this change to @agrare for local testing but did not expect it to be part of the PR.
a9b0be1
to
c557796
Compare
@gmcculloug made requested changes and re-tested |
c557796
to
dca8127
Compare
Checked commits agrare/manageiq@cc6906c~...dca8127 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 app/models/manageiq/providers/vmware/infra_manager/provision/cloning.rb
app/models/manageiq/providers/vmware/infra_manager/provision/placement.rb
spec/models/manageiq/providers/vmware/infra_manager/provision/placement_spec.rb
|
@gmcculloug correct, I'll take them out of the TODO list |
👍 LGTM |
Thanks guys! |
@agrare This needs to go back to the euwe branch, right? |
@bdunne yes, there's a 5.6.z clone also (https://bugzilla.redhat.com/show_bug.cgi?id=1378116) |
Allow VMware provision without needing to specify a host (cherry picked from commit de4f24f)
Euwe Backport details: $ git log
commit 92faa3252b44f9b8227537d037349c6ae68fa9b7
Author: Brandon Dunne <brandondunne@hotmail.com>
Date: Tue Sep 27 14:53:16 2016 -0400
Merge pull request #11437 from agrare/vmware_infra_provision_no_host
Allow VMware provision without needing to specify a host
(cherry picked from commit de4f24f31c66681066a0b85931653d872818c4ab) |
This should be backported AFTER #11135 |
Allow VMware provision without needing to specify a host (cherry picked from commit de4f24f) https://bugzilla.redhat.com/show_bug.cgi?id=1378116
Darga Backport details: $ git log
commit a6a212a019cb8191c022dbe97d6496aa20fd482e
Author: Brandon Dunne <brandondunne@hotmail.com>
Date: Tue Sep 27 14:53:16 2016 -0400
Merge pull request #11437 from agrare/vmware_infra_provision_no_host
Allow VMware provision without needing to specify a host
(cherry picked from commit de4f24f31c66681066a0b85931653d872818c4ab)
https://bugzilla.redhat.com/show_bug.cgi?id=1378116 |
This will allow a user to provision a VM to a VMware DRS-enabled cluster without having to specify a specific host. This aligns MIQ provision workflow with the VMware cloning workflow when you have a DRS cluster.
https://bugzilla.redhat.com/show_bug.cgi?id=1377975