Controlling vmware server from the command line

This articles was originally from but was edit in order to adapt in my installation using CentOS 4.4

Vmware is a nice way to take some administration burden off of your shoulders. Have you ever wanted to start or stop a virtual machine from the command line? If not then you really are not a great admin :P. Seriously though virtual machines can easily be managed at the command line with the vmware provided vmware-cmd utility.

Starting a virtual machine is as easy as vmware-cmd /path/machine.vmx start
This can easily be rolled into init scripts to start and stop guest virtual machines on host startup and shutdown.

Check out the help to see all the fun information you can find out from the command line.

Usage: /usr/bin/vmware-cmd
/usr/bin/vmware-cmd -s

Connection Options:
-H specifies an alternative host (if set, -U and -P must also be set)
-O specifies an alternative port
-U specifies a user
-P specifies a password

General Options:
-h More detailed help.
-q Quiet. Minimal output
-v Verbose.

Server Operations:
/usr/bin/vmware-cmd -l
— lists the registered VMs
/usr/bin/vmware-cmd -s register
— registers a VM
/usr/bin/vmware-cmd -s unregister
— unregisters a VM
/usr/bin/vmware-cmd -s getresource
— retrieves a server resource
/usr/bin/vmware-cmd -s setresource
— sets a server resource

VM Operations:
/usr/bin/vmware-cmd getconnectedusers
/usr/bin/vmware-cmd getstate
— gets the execution state of the VM
/usr/bin/vmware-cmd start
— powers on or resumes a VM
/usr/bin/vmware-cmd stop
— stops a VM
/usr/bin/vmware-cmd reset
— resets a VM
/usr/bin/vmware-cmd suspend
— suspends a VM
/usr/bin/vmware-cmd setconfig
— sets a configuration variable
/usr/bin/vmware-cmd getconfig
— retrieves the value for a configuration variable
/usr/bin/vmware-cmd setguestinfo
— sets a guest info variable
/usr/bin/vmware-cmd getguestinfo
— retrieves the value for a guest info variable
/usr/bin/vmware-cmd getid
— retrieves the VM id
/usr/bin/vmware-cmd getpid
— retrieves the process id of the running VM
/usr/bin/vmware-cmd getproductinfo — gets various product information
/usr/bin/vmware-cmd connectdevice
— connects a virtual device to a VM
/usr/bin/vmware-cmd disconnectdevice
— disconnects a virtual device from a VM
/usr/bin/vmware-cmd getconfigfile
— retrieves the path to the configuration file
/usr/bin/vmware-cmd getheartbeat
— retrieves the heartbeat value of the guest OS
/usr/bin/vmware-cmd getuptime
— retrieves the uptime of the guest OS
/usr/bin/vmware-cmd getremoteconnections
— retrieves the number of remote connections to a VM
/usr/bin/vmware-cmd gettoolslastactive
— retrieves the number of seconds since last notification from the tools
/usr/bin/vmware-cmd getresource
— retrieves a VM resource
/usr/bin/vmware-cmd setresource
— sets a VM resource
/usr/bin/vmware-cmd setrunasuser — sets the user that the VM runs as
/usr/bin/vmware-cmd getrunasuser
— retrieves the user that the VM runs as
/usr/bin/vmware-cmd getcapabilities
— retrieves the access permissions of the current user on a VM
/usr/bin/vmware-cmd addredo
— adds a redo log to a virtual disk
/usr/bin/vmware-cmd commit
— commits the redo log of a virtual disk
/usr/bin/vmware-cmd answer
— answers a question for a VM requesting input



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s