Skip to content

Commit

Permalink
fixes issue with cliustername if strip_host_domain_name is set #75
Browse files Browse the repository at this point in the history
refs: #75
  • Loading branch information
bb-Ricardo committed Sep 2, 2021
1 parent 37be99c commit 3392d53
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions module/sources/vmware/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,8 @@ def add_host(self, obj):
log.error(e)

# handle standalone hosts
if cluster_name == name:
if cluster_name == name or (self.strip_host_domain_name is True and cluster_name.split(".")[0] == name):
cluster_name = cluster_name.split(".")[0]
log.debug2(f"Host name and cluster name are equal '{cluster_name}'. "
f"Assuming this host is a 'standalone' host.")

Expand Down Expand Up @@ -1957,9 +1958,14 @@ def add_virtual_machine(self, obj):
self.processed_vm_uuid.append(vm_uuid)

parent_name = get_string_or_none(grab(obj, "runtime.host.name"))
cluster_name = get_string_or_none(grab(obj, "runtime.host.parent.name"))

# honor strip_host_domain_name
if cluster_name is not None and self.strip_host_domain_name is True and \
parent_name.split(".")[0] == cluster_name.split(".")[0]:
cluster_name = cluster_name.split(".")[0]

# check VM cluster
cluster_name = get_string_or_none(grab(obj, "runtime.host.parent.name"))
if cluster_name is None:
log.error(f"Requesting cluster for Virtual Machine '{name}' failed. Skipping.")
return
Expand Down

0 comments on commit 3392d53

Please sign in to comment.