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

Fix Proxmox node, name condition. #5108

Merged
merged 2 commits into from
Aug 12, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/5108-proxmox-node-name-condition.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- proxmox_kvm - fix wrong condition (https://github.com/ansible-collections/community.general/pull/5108).
2 changes: 1 addition & 1 deletion plugins/modules/cloud/misc/proxmox_kvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ def main():
module.exit_json(changed=False, vmid=vmid, msg="VM with vmid <%s> already exists" % vmid)
elif proxmox.get_vmid(name, ignore_missing=True) and not (update or clone):
module.exit_json(changed=False, vmid=proxmox.get_vmid(name), msg="VM with name <%s> already exists" % name)
elif not (node, name):
elif (not node) or (not name):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be overkill, but it could also be expressed as:

Suggested change
elif (not node) or (not name):
elif not all(node, name):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I find the previous version easier to understand since I don't usually write Python.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suit yourself 😁

module.fail_json(msg='node, name is mandatory for creating/updating vm')
elif not proxmox.get_node(node):
module.fail_json(msg="node '%s' does not exist in cluster" % node)
Expand Down