Skip to content

Commit

Permalink
fix folder path method name
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemorency committed Nov 19, 2024
1 parent db4b738 commit bfdcf6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions plugins/module_utils/_vmware_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ansible.module_utils._text import to_text
from ansible.module_utils.six import integer_types, string_types, iteritems
import ansible.module_utils.common._collections_compat as collections_compat
from ansible_collections.vmware.vmware.plugins.module_utils._vmware_folder_paths import get_folder_path_of_vm
from ansible_collections.vmware.vmware.plugins.module_utils._vmware_folder_paths import get_folder_path_of_vsphere_object


class VmFacts():
Expand Down Expand Up @@ -167,7 +167,7 @@ def hw_general_facts(self):

def hw_folder_facts(self):
try:
hw_folder = get_folder_path_of_vm(self.vm)
hw_folder = get_folder_path_of_vsphere_object(self.vm)
except Exception:
hw_folder = None

Expand Down Expand Up @@ -313,7 +313,7 @@ def host_facts(self):
for host in self.cluster.host:
hosts.append({
'name': host.name,
'folder': get_folder_path_of_vm(host),
'folder': get_folder_path_of_vsphere_object(host),
})
return {"hosts": hosts}

Expand Down
11 changes: 5 additions & 6 deletions plugins/module_utils/_vmware_folder_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,16 @@ def format_folder_path_as_datastore_fq_path(folder_path, datacenter_name):
return __prepend_datacenter_and_folder_type(folder_path, datacenter_name, folder_type='datastore')


def get_folder_path_of_vm(vm):
def get_folder_path_of_vsphere_object(vsphere_obj):
"""
Find the path of virtual machine.
Find the path of an object in vsphere.
Args:
content: VMware content object
vm_name: virtual machine managed object
vsphere_obj: VMware content object
Returns: Folder of virtual machine if exists, else None
Returns: Folder of object if exists, else None
"""
_folder = vm.parent
_folder = vsphere_obj.parent
folder_path = [_folder.name]
while getattr(_folder, 'parent', None) is not None:
_folder = _folder.parent
Expand Down

0 comments on commit bfdcf6a

Please sign in to comment.