-
Notifications
You must be signed in to change notification settings - Fork 70
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
Use the new VM's ems_ref instead of an annotation #408
Merged
gmcculloug
merged 4 commits into
ManageIQ:master
from
agrare:bz_1724751_use_vm_ems_ref_to_find_in_vmdb
Jul 23, 2019
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,19 @@ module ManageIQ::Providers::Vmware::InfraManager::Provision::Cloning | |
def do_clone_task_check(clone_task_mor) | ||
source.with_provider_connection do |vim| | ||
begin | ||
state, val = vim.pollTask(clone_task_mor, "VMClone") | ||
case state | ||
task_props = ["info.state", "info.error", "info.result", "info.progress", "info.completeTime"] | ||
task = vim.getMoProp(clone_task_mor, task_props) | ||
|
||
case task&.info&.state | ||
when TaskInfoState::Success | ||
phase_context[:new_vm_ems_ref] = task&.info&.result | ||
phase_context[:clone_vm_task_completion_time] = task&.info&.completeTime | ||
return true | ||
when TaskInfoState::Running | ||
return false, val.nil? ? "beginning" : "#{val}% complete" | ||
progress = task&.info&.progress | ||
return false, progress.nil? ? "beginning" : "#{progress}% complete" | ||
else | ||
return false, state | ||
return false, task&.info&.state | ||
end | ||
end | ||
end | ||
|
@@ -18,11 +23,11 @@ def do_clone_task_check(clone_task_mor) | |
end | ||
|
||
def find_destination_in_vmdb | ||
# The new VM will have the guid we placed in the annotations field | ||
validation_guid = phase_context[:new_vm_validation_guid] | ||
VmOrTemplate.where(:name => dest_name).detect do |v| | ||
v.hardware.annotation && v.hardware.annotation.include?(validation_guid) | ||
end | ||
# Check that the EMS inventory is as up to date as the CloneVM_Task completeTime | ||
# to prevent issues with post-provision depending on data that isn't in VMDB yet | ||
return if source.ext_management_system.last_inventory_date < phase_context[:clone_vm_task_completion_time] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
source.ext_management_system.vms.find_by(:ems_ref => phase_context[:new_vm_ems_ref]) | ||
end | ||
|
||
def prepare_for_clone_task | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Overall this looks good. Since we are referencing
task&.info
in 5 places we should set that to a variable to avoid the lookup each time:task_info = task&.info
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.
👍 will 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.
@gmcculloug done