I have shell scripts that I use to programmatically configure my Virtual Machines (VMs) on my vmware ESXi host. I use the "govc" command-line-interface (CLI) which provides a suite of commands to configure my VMs that run on my ESXI (i.e. powering on, setting ram, etc...)
I am trying now to set the CPU affinity for some of my virtual machines (i.e. VM #2 should use CPUs 9-16 where-as VM#1 should use CPU 2-8). However, I cannot find any govc command to do this programmatically, though I can very clearly see how to do this within the ESXI web-based gui:
I reference the govc API for commands here, but again, I could not find anything. The CPU affinity should be set for a specific VM, and there should be an argument of CPU numbers separated by comma or with hypen (-) for a range, I would imagine: https://github.com/vmware/govmomi/blob/master/govc/USAGE.md
Can anyone who is familiar with vmware ESXi and govc please help?
Thank you.
I didn't figure out how to do it through govc CLI, but I figured out you can add
sched.cpu.affinity = 2-8,9
to your VMX file in your ESXi datastore, and it will set the CPU affinity for that specific VM accordingly. In the example above, it would mean CPUs 2 through 8 and CPU 9 would have the affinity set for this specific VM.