fix: Handle hypervisor_id option properly#428
Open
jirihnidek wants to merge 1 commit into
Open
Conversation
3e33020 to
ce7520f
Compare
* Card ID: CCT-2241 * When hypervisor_id is set to hostname and Nutanix does not provide `name` property in host object, then fallback to uuid for hypervisor_id * Modified code for both versions of API (2 and 3) * Added one unit test for API version 2 Signed-off-by: Jiri Hnidek <jhnidek@redhat.com>
ce7520f to
bec6043
Compare
cnsnyder
reviewed
Apr 16, 2026
Comment on lines
+117
to
+126
| hypervisor_id = host_uuid | ||
| if self.config['hypervisor_id'] == 'uuid': | ||
| self.logger.debug("Using hypervisor_id: uuid: %s", hypervisor_id) | ||
| elif self.config['hypervisor_id'] == 'hostname': | ||
| try: | ||
| hypervisor_id = host['name'] | ||
|
|
||
| except KeyError: | ||
| self.logger.debug("Host '%s' doesn't have hypervisor_id property", host_uuid) | ||
| continue | ||
| self.logger.debug("Using hypervisor_id: hostname: %s", hypervisor_id) | ||
| except KeyError: | ||
| self.logger.warning("Host '%s' doesn't have 'name' property", host_uuid) | ||
| self.logger.warning("Falling back to default hypervisor_id: uuid") |
Member
There was a problem hiding this comment.
Non-nacking comment: Since this is repeated is it worth having a helper function to do this?
Collaborator
Author
There was a problem hiding this comment.
Well, the fact that we handle two versions of API in the same code (ahv.py) has been reason for many confusions. We also do not know yet, if the behavior will be the same in both versions of API. Thus, I would keep it as it is now.
cnsnyder
approved these changes
Apr 16, 2026
cnsnyder
left a comment
Member
There was a problem hiding this comment.
Overall LGTM, just one question which I don't think should block merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hypervisor_idis set to hostname and Nutanix does not providenameproperty in host object, then fallback touuidforhypervisor_id