Awesome Open Source
Awesome Open Source

Build Status ezmomi

A simple Linux command line interface for common VMware vSphere VM tasks.

EZmomi uses pyvmomi (VMware vSphere API Python Bindings).

Requirements

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)

Install

pip install ezmomi

Example Usage

Clone a template with two static IPs:
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.

Clone a template and put vm is specific folder
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.

Power Operations

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
Power Status
ezmomi status --name test01
# for much more information add --extra:
ezmomi status --name test01 --extra
Destroy a VM
ezmomi destroy --name test01
VM Snapshot operations

See help for more info on each operation:

ezmomi listSnapshots --help
ezmomi createSnapshot --help
ezmomi removeSnapshot --help
ezmomi revertSnapshot --help
Listing your resources:
ezmomi list --type VirtualMachine
ezmomi list --type Network
ezmomi list --type Datastore
etc...
Disable ssl warnings
ezmomi --no-ssl-verify [command] [options]
Sync a VM's time with ESXi host
ezmomi syncTimeWithHost --name somevm01

See Managed Object Types in the vSphere API docs for a list of types to look up.

Help

Each command section has its own help:

ezmomi --help
ezmomi clone --help
ezmomi list --help
etc...

Install via github

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

Contributing

Pull requests, bug reports, and feature requests are extremely welcome.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (55,471
linux (2,568
deployment (237
management (136
vmware (46