Other VMware Control Projects

There are a number of existing alternatives for controlling VMware. None of them are particularly satisfactory.

VMPlayer Command Line

We can use this application to start a VM. And not much more.

"C:\Program Files\VMware\VMware Player\vmplayer.exe" "C:\VMWareGuests\Server\Windows Server 2003 Standard Edition.vmx"

http://sanbarrow.com/vmx.html

This doesn’t do much.

VIX vmrun command

C:\Program Files\VMware\VMware VIX\vmrun

vmrun version 2.0.2 build-203138

Usage:

vmrun [AUTHENTICATION-FLAGS] COMMAND [PARAMETERS]

AUTHENTICATION-FLAGS:

These must appear before the command and any command parameters.

-h <hostName>

Specify the host to control. (not needed for Workstation)

-P <hostPort>

Specify the port number to be used. (not needed for Workstation)

-T <hostType> (ws|server|server1) for example, use '-T server' for Server 2.0 use '-T server1' for Server 1.0
-u <userName in host OS>

Authentication required for host access. (not needed for Workstation)

-p <password in host OS>

Authentication password required for host access. (not needed for Workstation)

-gu <userName in guest OS>

Guest username for commands which require a valid login.

-gp <password in guest OS>

Guest password for commands which require a valid login.

POWER COMMANDS:

start Path to vmx file Start a VM
[gui|nogui]
stop Path to vmx file Stop a VM
[hard|soft]
reset Path to vmx file Reset a VM
[hard|soft]
suspend Path to vmx file Suspend a VM
[hard|soft]

pause Path to vmx file Pause a VM

unpause Path to vmx file Unpause a VM

SNAPSHOT COMMANDS:

snapshot Path to vmx file Create a snapshot of a VM
Snapshot name
deleteSnapshot Path to vmx file Remove a snapshot from a VM
Snapshot name
revertToSnapshot Path to vmx file Set VM state to a snapshot
Snapshot name

RECORD/REPLAY COMMANDS:

beginRecording Path to vmx file Begin recording a VM
Snapshot name

endRecording Path to vmx file End recording a VM

beginReplay Path to vmx file Begin replaying a VM
Snapshot name

endReplay Path to vmx file End replaying a VM

GUEST OS COMMANDS:

runProgramInGuest Path to vmx file Run a program in Guest OS
[-noWait] [-activeWindow] [-interactive] Complete-Path-To-Program [Program arguments]

fileExistsInGuest Path to vmx file Check if a file exists in Guest OS

Path to file in guest
setSharedFolderState Path to vmx file Modify a Host-Guest shared folder
Share name Host path writable | readonly
addSharedFolder Path to vmx file Add a Host-Guest shared folder
Share name New host path
removeSharedFolder Path to vmx file Remove a Host-Guest shared folder
Share name

listProcessesInGuest Path to vmx file List running processes in Guest OS

killProcessInGuest Path to vmx file Kill a process in Guest OS
process id
runScriptInGuest Path to vmx file Run a script in Guest OS
Interpreter path script_text
deleteFileInGuest Path to vmx file Delete a file in Guest OS
Path in guest
createDirectoryInGuest Path to vmx file Create a directory in Guest OS
Directory path in guest
deleteDirectoryInGuest Path to vmx file Delete a directory in Guest OS
Directory path in guest
listDirectoryInGuest Path to vmx file List a directory in Guest OS
Directory path in guest
copyFileFromHostToGuest Path to vmx file Copy a file from host OS to guest OS
Path on host Path in guest
copyFileFromGuestToHost Path to vmx file Copy a file from guest OS to host OS
Path in guest Path on host
renameFileInGuest Path to vmx file Rename a file in Guest OS
Original name New name
captureScreen Path to vmx file Capture the screen of the VM to a local file
Path on host
writeVariable Path to vmx file Write a variable in the VM state
[runtimeConfig|guestEnv] variable name variable value
readVariable Path to vmx file Read a variable in the VM state
[runtimeConfig|guestEnv] variable name

VPROBE COMMANDS:

vprobeVersion Path to vmx file List VP version

vprobeLoad Path to vmx file Load VP script
‘VP script text’

vprobeReset Path to vmx file Disable all vprobes

vprobeListProbes Path to vmx file List probes

vprobeListGlobals Path to vmx file List global variables

GENERAL COMMANDS:

list List all running VMs

upgradevm Path to vmx file Upgrade VM file format, virtual hw

installtools Path to vmx file Install Tools in Guest

register Path to vmx file Register a VM

unregister Path to vmx file Unregister a VM

listRegisteredVM List registered VMs

clone Path to vmx file Create a copy of the VM
Path to destination vmx file full|linked [Snapshot name]

Examples

Starting a virtual machine with Workstation on a Windows host

vmrun -T ws start "c:\my VMs\myVM.vmx"

Stopping a virtual machine with Server on a linux host

vmrun -T server -h https://myHost.com/sdk -u hostUser -p hostPassword stop "[storage1] vm/myVM.vmx"

Running a program in a virtual machine with Workstation on a Windows host with Windows guest

vmrun -T ws -gu guestUser -gp guestPassword runProgramInGuest "c:\my VMs\myVM.vmx" "c:\Program Files\myProgram.exe"

Running a program in a virtual machine with Server on a linux host with linux guest

vmrun -T server -h https://myHost.com/sdk -u hostUser -p hostPassword -gu guestUser -gp guestPassword runProgramInGuest "[storage1] vm/myVM.vmx" /usr/bin/X11 /xclock -display :0

Creating a snapshot of a virtual machine with Workstation on a Windows host

vmrun -T ws snapshot "c:\my VMs\myVM.vmx" mySnapshot

Reverting to a snapshot with Workstation on a Windows host

vmrun -T ws revertToSnapshot "c:\my VMs\myVM.vmx" mySnapshot

Deleting a snapshot with Workstation on a Windows host

vmrun -T ws deleteSnapshot "c:\my VMs\myVM.vmx" mySnapshot

PyVix

PyVix is old. http://sourceforge.net/projects/pyvix/

It also has a very complex build, since it creates it’s own VIX library, rather than relying on the VMware VIX installation.

Needs Win32API – http://sourceforge.net/projects/pywin32/files/pywin32/

Needs Mingw or some other C compiler. mingw-get install gcc may work.

It may benefit from installing the VMware VIX SDK. The title is “VMware Virtual Machine Automation APIs”

An older link: http://www.vmware.com/download/sdk/vmauto.html

The install script looks for the server. However, this can be fixed to look for just VIX.

setup.py Lines 107:

serverInstKey = _winreg.OpenKey(r,
    #r'SOFTWARE\VMware, Inc.\VMware Server'
    r'SOFTWARE\VMware, Inc.\VMware VIX'
  )

Also _support.py lines 14:

serverInstKey = _winreg.OpenKey(r,
    #r'SOFTWARE\VMware, Inc.\VMware Server'
    r'SOFTWARE\VMware, Inc.\VMware VIX'
  )

Before using MinGW, you should add C:\MinGW\bin; to the PATH environment variable

python setup.py build -c mingw32 install

Compile Notes: http://www.vmware.com/support/developer/vix-api/vix17_reference/

Also...

As noted by clintd, one can choose a specific vix.lib; the ViX documentation (available in “C:Program FilesVMwareVMware VIXdoc”) calls this “Compiling Without the Wrapper Library”, and hints that ws-1 is for VMware Server 1.0, ws-2 for Workstation 6.0 and ws-3 for Workstation 6.0.1 (I found no description of ws-4 and ws-5, though).

PyVMWare

PyVMWare is old. http://code.google.com/p/pyvmware/

Only does a few things. A good jumping-off point.

There’s little benefit in “completing” it. It has the wrong object model.

Table Of Contents

Previous topic

PyVIX2 Build

Next topic

Implementation

This Page