Skip to content

Commit 6010f39

Browse files
authored
fix ESXiHost edge (#2032)
1 parent e9ed544 commit 6010f39

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

plugins/vsphere/fix_plugin_vsphere/__init__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,22 @@ def collect(self) -> None:
148148
except Exception:
149149
log.warning(f"Resourcepool error for cluster {cluster._moId} {cluster.name}")
150150

151+
# get hosts from a cluster
152+
for host in cluster.host: #
153+
log.debug(f"Found host - {host._moId} - {host.name}")
154+
hostObj = VSphereESXiHost(id=host._moId, name=host.name)
155+
self.graph.add_resource(clusterObj, hostObj)
156+
# get vms for each host and read from the vm list
157+
for vm in host.vm:
158+
if vm._moId in self.instances_dict:
159+
vmObj = self.instances_dict[vm._moId]
160+
log.debug(
161+
f"lookup vm - {vm._moId} - {vmObj.name} and assign to host {host._moId} - {host.name}"
162+
)
163+
self.graph.add_edge(hostObj, vmObj)
164+
else:
165+
log.warning(f"host {host._moId} - {host.name} reports {vm._moId} but instance not found")
166+
151167
for datastore in dc.datastoreFolder.childEntity:
152168
if datastore._wsdlName == "Datastore":
153169
log.debug(f"Found Datastore - {datastore._moId} - {datastore.name}")
@@ -169,22 +185,6 @@ def collect(self) -> None:
169185
vmObj = self.instances_dict[vm._moId]
170186
self.graph.add_edge(dsObj, vmObj)
171187

172-
# get hosts from a cluster
173-
for host in cluster.host: #
174-
log.debug(f"Found host - {host._moId} - {host.name}")
175-
hostObj = VSphereESXiHost(id=host._moId, name=host.name)
176-
self.graph.add_resource(clusterObj, hostObj)
177-
# get vms for each host and read from the vm list
178-
for vm in host.vm:
179-
if vm._moId in self.instances_dict:
180-
vmObj = self.instances_dict[vm._moId]
181-
log.debug(
182-
f"lookup vm - {vm._moId} - {vmObj.name} and assign to host {host._moId} - {host.name}"
183-
)
184-
self.graph.add_edge(hostObj, vmObj)
185-
else:
186-
log.warning(f"host {host._moId} - {host.name} reports {vm._moId} but instance not found")
187-
188188
@staticmethod
189189
def add_config(config: Config) -> None:
190190
config.add_config(VSphereConfig)

0 commit comments

Comments
 (0)