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

1569299: try/exception needed for hypervisor_id check #138

Merged
merged 1 commit into from Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions tests/complex/data/esx/esx_waitforupdatesexresponse_0.xml
Expand Up @@ -169,6 +169,40 @@
<val xsi:type="ArrayOfManagedObjectReference"></val>
</changeSet>
</objectSet>
<objectSet>
<kind>enter</kind>
<obj type="HostSystem">ha-host4</obj>
<changeSet>
<name>hardware.cpuInfo.numCpuPackages</name>
<op>assign</op>
<val xsi:type="xsd:short">1</val>
</changeSet>
<changeSet>
<name>config.network.dnsConfig.hostName</name>
<op>assign</op>
<val xsi:type="xsd:string">localhost百度</val>
</changeSet>
<changeSet>
<name>config.network.dnsConfig.domainName</name>
<op>assign</op>
<val xsi:type="xsd:string">localdomain</val>
</changeSet>
<changeSet>
<name>name</name>
<op>assign</op>
<val xsi:type="xsd:string">localhost百度.localdomain</val>
</changeSet>
<changeSet>
<name>parent</name>
<op>assign</op>
<val type="ClusterComputeResource" xsi:type="ManagedObjectReference">ha-compute-res</val>
</changeSet>
<changeSet>
<name>vm</name>
<op>assign</op>
<val xsi:type="ArrayOfManagedObjectReference"></val>
</changeSet>
</objectSet>
</filterSet>
</returnval>
</WaitForUpdatesExResponse>
Expand Down
23 changes: 14 additions & 9 deletions virtwho/virt/esx/esx.py
Expand Up @@ -258,15 +258,20 @@ def getHostGuestMapping(self):
continue
guests = []

if self.config['hypervisor_id'] == 'uuid':
uuid = host['hardware.systemInfo.uuid']
elif self.config['hypervisor_id'] == 'hwuuid':
uuid = host_id
elif self.config['hypervisor_id'] == 'hostname':
uuid = host['config.network.dnsConfig.hostName']
domain_name = host['config.network.dnsConfig.domainName']
if domain_name:
uuid = self._format_hostname(uuid, domain_name)
try:
if self.config['hypervisor_id'] == 'uuid':
uuid = host['hardware.systemInfo.uuid']
elif self.config['hypervisor_id'] == 'hwuuid':
uuid = host_id
elif self.config['hypervisor_id'] == 'hostname':
uuid = host['config.network.dnsConfig.hostName']
domain_name = host['config.network.dnsConfig.domainName']
if domain_name:
uuid = self._format_hostname(uuid, domain_name)
except KeyError:
self.logger.debug("Host '%s' doesn't have hypervisor_id property", host_id)
continue

if host['vm']:
for vm_id in host['vm'].ManagedObjectReference:
if vm_id.value not in self.vms:
Expand Down