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

Reduce object lookups for finding folders #268

Merged
merged 4 commits into from
Jul 9, 2018

Conversation

mattkirby
Copy link
Contributor

These commits reduce the number of objects looked up when finding VM folders. Additionally, object lookup methods that scan for a folder with a matching name are removed in favor of searchIndex with FindByInventoryPath. Without this change the time it takes to find VM folders is much longer and more resource intensive.

This commit reduces object lookups used for get_vm. Without this change get_vm looks up the VM folder, which is already used and known to find the vm with find_vm.
This commit replaces find_folder to use information already known about folders to determine their location and quickly fail when it does not exist without traversing the hierarchy. Without this change find_folder is very inneficient and can take a long time to return depending on how deep in the folder tree the folder exists.
This commit renames find_folder to find_vm_folder to clarify its intent to retrieve folders from the VM hierarchy. Without this change find_folder implies it may find folders that are not within the VM hierarchy.
@mattkirby
Copy link
Contributor Author

This will resolve #204 .

@@ -365,15 +353,22 @@ def get_target_datacenter_from_config(pool_name)
nil
end

def generate_vm_hash(vm_object, template_name, pool_name)
hash = { 'name' => nil, 'hostname' => nil, 'template' => nil, 'poolname' => nil, 'boottime' => nil, 'powerstate' => nil }
def generate_vm_hash(vm_object, pool_name)
Copy link

Choose a reason for hiding this comment

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

This seems like a good opportunity to add documentation to this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some brief documentation to this method. Let me know if you think it doesn't cover what you were hoping to see, it's pretty brief.

Copy link

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@smcelmurry smcelmurry left a comment

Choose a reason for hiding this comment

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

Good on @Dakta's approval of documentation

Copy link

@Dakta Dakta left a comment

Choose a reason for hiding this comment

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

Looks good

@@ -365,15 +353,22 @@ def get_target_datacenter_from_config(pool_name)
nil
end

def generate_vm_hash(vm_object, template_name, pool_name)
hash = { 'name' => nil, 'hostname' => nil, 'template' => nil, 'poolname' => nil, 'boottime' => nil, 'powerstate' => nil }
def generate_vm_hash(vm_object, pool_name)
Copy link

Choose a reason for hiding this comment

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

👍

@mchllweeks mchllweeks merged commit a72012b into puppetlabs:master Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants