mahmn
Enthusiast
Enthusiast

VM control from command line

I would like to control VMs from vcenter or another real machine within the network by some scheduled scripts. By control, I mean power on/off or plug/unplug the network interface.

Assume a VM IP is 10.1.1.10 and the vcenter is 10.1.1.3.

Another real machine (centos) is also available with 10.1.1.1. Actually, from the centos machine I open the web console of the vsphere/esxi/...

For the first step, I want to send a shutdown command to a running VM. I searched for that and saw some topics. But the method is not clear for me. Any advice?

0 Kudos
2 Replies
IRIX201110141
Virtuoso
Virtuoso

Rest, Powershell, vSphereCLI(Perl), SOAP, pyvmomi

Regards,
Joerg

0 Kudos
mahmn
Enthusiast
Enthusiast

I am trying to use bash commands at the moment.

Right know, I use

vim-cmd vmsvc/power.on VMID

to power on a vm and

vim-cmd vmsvc/power.off VMID

to power off the vm.

To get the VMID, I simply run

vim-cmd vmsvc/getallvms | grep NAME_REGEX | cut -d " " -f 1

0 Kudos