Skip to content

Testing Host: VMware

netniV edited this page Jan 9, 2018 · 2 revisions

VMWare

List Virtual Machines

vim-cmd vmsvc/getallvms

For more information use:

esxcli vm process list

Reload VM config

vim-cmd vmsvc/reload _vm_id_

Snapshot management

vim-cmd vmsvc/snapshot.get _vm_id_

Gets a list of the snapshots for a VM

vim-cmd vmsvc/snapshot.create _vm_id_ _snapshot_name_ _snapshot_description_

Creates a new snapshot for a VM with the given name and description

vim-cmd vmsvc/snapshot.remove _vm_id_ _snapshot_id_

Removes a snapshot from a VM

vim-cmd vmsvc/snapshot.removeAll _vm_id_

Removes all snapshots from a VM

In practice, this can be used to create a snapshot against each VM with the same name using something like:

~ # vim-cmd vmsvc/getallvms
Vmid        Name                               File                         Guest OS      Version   Annotation
102    testfw1           [vmstorage2] Firewall/testfw1.vmx               freebsd64Guest   vmx-08              
113    CentOS6           [vmstorage2] CentOS/CentOS6.vmx                 centos64Guest    vmx-08              
114    CentOS7           [vmstorage2] CentOS/CentOS7.vmx                 centos64Guest    vmx-08              
125    Ubuntu1710        [vmstorage2] Ubuntu/Ubuntu1710.vmx              ubuntu64Guest    vmx-08              
136    FreeBSD104        [vmstorage2] FreeBSD/FreeBSD104.vmx             freebsd64Guest   vmx-08              
137    FreeBSD111        [vmstorage2] FreeBSD/FreeBSD111.vmx             freebsd64Guest   vmx-08              
148    openSUSELeep423   [vmstorage2] openSUSELeep/openSUSELeep423.vmx   sles11_64Guest   vmx-08              

~ # for i in 113 114 125 136 137 148; do vim-cmd vmsvc/snapshot.create $i snapshot-test "This is a test of a snapshot.create"; done
Create Snapshot:
Create Snapshot:
Create Snapshot:
Create Snapshot:
Create Snapshot:
Create Snapshot: