Skip to content

Commit

Permalink
fixes vCenter tag assignment for host and VM
Browse files Browse the repository at this point in the history
refs: #98
refs: #65
  • Loading branch information
bb-Ricardo committed Oct 18, 2021
1 parent 03ddfff commit 391c3c4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions module/sources/vmware/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,9 @@ def add_host(self, obj):
log.debug2(f"Found a match ({object_regex.pattern}) for {name}, using tag '{tag_name}'")
host_tags.append(tag_name)

# get vCenter tags
host_tags.extend(self.get_object_tags(obj))

# prepare host data model
host_data = {
"name": name,
Expand All @@ -1341,10 +1344,6 @@ def add_host(self, obj):
if len(host_tags) > 0:
host_data["tags"] = host_tags

host_tags = self.get_object_tags(obj)
if len(host_tags) > 0:
host_data["tags"] = host_tags

# iterate over hosts virtual switches, needed to enrich data on physical interfaces
self.network_data["vswitch"][name] = dict()
for vswitch in grab(obj, "config.network.vswitch", fallback=list()):
Expand Down Expand Up @@ -1803,6 +1802,9 @@ def add_virtual_machine(self, obj):
log.debug2(f"Found a match ({object_regex.pattern}) for {name}, using tag '{tag_name}'")
vm_tags.append(tag_name)

# get vCenter tags
vm_tags.extend(self.get_object_tags(obj))

vm_data = {
"name": name,
"cluster": {"name": cluster_name},
Expand All @@ -1821,10 +1823,6 @@ def add_virtual_machine(self, obj):
if len(vm_tags) > 0:
vm_data["tags"] = vm_tags

vm_tags = self.get_object_tags(obj)
if len(vm_tags) > 0:
vm_data["tags"] = vm_tags

vm_primary_ip4 = None
vm_primary_ip6 = None
vm_default_gateway_ip4 = None
Expand Down

0 comments on commit 391c3c4

Please sign in to comment.