ScaleComputing / HyperCoreAnsibleCollection

Official Ansible collection for Scale Computing SC//HyperCore (HC3) v1 API
GNU General Public License v3.0
12 stars 8 forks source link

:lady_beetle: Bug: Passing VCPU via environment variable creates VM with 0 cores #342

Open christianhahnsft22 opened 4 days ago

christianhahnsft22 commented 4 days ago

I'm trying to pass in the number of vcpu via an environment variable like this:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "There was a problem during this task execution. Task details: {\"taskTag\": \"316\", \"progressPercent\": 50, \"state\": \"ERROR\", \"formattedDescription\": \"Start Virtual Machine %@\", \"descriptionParameters\": [\"jumphost\"], \"formattedMessage\": \"Cannot start virtual machine 'jumphost'\", \"messageParameters\": [], \"objectUUID\": \"7f742bf2-128e-4f48-883c-0283df4286f3\", \"created\": 1731266925, \"modified\": 1731266937, \"completed\": 1731266937, \"sessionID\": \"a04a8728-932c-4b70-a39d-31b8fbbbe780\", \"nodeUUIDs\": [\"\"]}"}

In the UI I see afterwards a VM which has 0 cores assigned.

justinc1 commented 3 days ago

Hi. If NUMBER_CPU is not set in environ lookup will return empty string, and int will convert it to number 0. Provide a default value for this case - jumphost_cpus: "{{ lookup('env', 'NUMBER_CPU') or 2 | int }}".