A simple Linux command line interface for common VMware vSphere VM tasks.
EZmomi uses pyvmomi (VMware vSphere API Python Bindings).
vSphere 6
Python 2.7 or 3.x
(If you are using vSphere 5, install the older ezmomi 0.x: pip install ezmomi==0.4.2
)
pip install ezmomi
ezmomi clone --template centos67 --hostname test01 --cpus 2 --mem 4 --ips 172.10.16.203 172.10.16.204
ips
takes any number of ips. See ezmomi clone --help
for a list of params.
To optionally run a command/script after clone has started:
ezmomi clone --template centos6 --hostname test01 --cpus 2 --mem 4 --ips 172.10.16.203 172.10.16.204 --post-clone-cmd /usr/local/bin/additional-provisioning-steps.sh
This example would run /usr/local/bin/additional-provisioning-steps.sh on the same host ezmomi is run on. You can reference the EZMOMI_CLONE_HOSTNAME
environment variable in your script to retrieve the --hostname
.
ezmomi clone --server vcenter_url --template centos67 --hostname test01 --cpus 2 --mem 4 --destination-folder "/DC/folder/" --ips 172.10.16.203 172.10.16.204
This example will put the cloned vm to specific destination folder in specified vcenter.
Guest shutdown
ezmomi shutdown --name test01
This command falls back to powerOff if VMware guest tools are not installed/available.
Power On/Off
ezmomi powerOn --name test01
ezmomi powerOff --name test01
ezmomi status --name test01
# for much more information add --extra:
ezmomi status --name test01 --extra
ezmomi destroy --name test01
See help for more info on each operation:
ezmomi listSnapshots --help
ezmomi createSnapshot --help
ezmomi removeSnapshot --help
ezmomi revertSnapshot --help
ezmomi list --type VirtualMachine
ezmomi list --type Network
ezmomi list --type Datastore
etc...
ezmomi --no-ssl-verify [command] [options]
ezmomi syncTimeWithHost --name somevm01
See Managed Object Types in the vSphere API docs for a list of types to look up.
Each command section has its own help:
ezmomi --help
ezmomi clone --help
ezmomi list --help
etc...
git clone https://github.com/snobear/ezmomi.git
# using python2.7 virtualenv
virtualenv -p python2.7 --no-site-packages ezmomi
cd ezmomi && source bin/activate
pip install -r requirements.txt
export PYTHONPATH=$PWD:$PYTHONPATH
ezmomi --help
Pull requests, bug reports, and feature requests are extremely welcome.