-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from snobear/develop
Destroy method, pypi build
- Loading branch information
Showing
9 changed files
with
139 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
LICENSE.txt | ||
requirements.txt | ||
setup.py | ||
bin/ezmomi | ||
ezmomi/__init__.py | ||
ezmomi/cli.py | ||
ezmomi/ezmomi.py | ||
ezmomi/params.py | ||
ezmomi/config/config.yml.example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,50 +6,58 @@ A simple command line interface for common VMware vSphere tasks. | |
EZmomi uses [pyvmomi](https://github.com/vmware/pyvmomi) (VMware vSphere API Python Bindings). | ||
|
||
|
||
#### Example Usage | ||
### Install | ||
|
||
``` | ||
pip install ezmomi | ||
``` | ||
|
||
### Example Usage | ||
|
||
Clone a template with two static IPs: | ||
##### Clone a template with two static IPs: | ||
|
||
``` | ||
./ezmomi.py clone --hostname foo01 --cpus 2 --mem 4 --ips 172.10.16.203 172.10.16.204 | ||
ezmomi clone --template centos65 --hostname test01 --cpus 2 --mem 4 --ips 172.10.16.203 172.10.16.204 | ||
``` | ||
|
||
`ips` takes any number of ips. | ||
`ips` takes any number of ips. See `ezmomi clone --help` for a list of params. | ||
|
||
Get info about available resources, e.g.: | ||
##### Destroy a VM | ||
|
||
``` | ||
./ezmomi.py list --type Network | ||
./ezmomi.py list --type Datastore | ||
./ezmomi.py list --type VirtualMachine | ||
ezmomi destroy --name test01 | ||
``` | ||
|
||
##### Listing your resources: | ||
|
||
``` | ||
ezmomi list --type VirtualMachine | ||
ezmomi list --type Network | ||
ezmomi list --type Datastore | ||
etc... | ||
``` | ||
|
||
See [Managed Object Types](http://pubs.vmware.com/vsphere-50/index.jsp#com.vmware.wssdk.apiref.doc_50/mo-types-landing.html) in the vSphere API docs for a list of types to look up. | ||
|
||
#### Help | ||
### Help | ||
|
||
Each command section has its own help: | ||
|
||
``` | ||
./ezmomi.py --help | ||
./ezmomi.py clone --help | ||
./ezmomi.py list --help | ||
ezmomi --help | ||
ezmomi clone --help | ||
ezmomi list --help | ||
etc... | ||
``` | ||
|
||
#### Install/Setup | ||
|
||
I'm working on making this available via pip, but currently you can just clone via github: | ||
### Install via github | ||
|
||
``` | ||
git clone [email protected]:snobear/ezmomi.git | ||
virtualenv --no-site-packages ezmomi | ||
cd ezmomi && source bin/activate | ||
pip install -r requirements.txt | ||
mv config.yml.example config.yml | ||
``` | ||
|
||
Then define your credentials, networks, and VMware objects in config.yml and you're all set. | ||
|
||
#### Contributing | ||
### Contributing | ||
Pull requests, bug reports, and feature requests are extremely welcome. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ezmomi | ||
====== | ||
|
||
A simple command line interface for common VMware vSphere tasks. Please see https://github.com/snobear/ezmomi for usage examples. | ||
|
||
ezmomi uses the lovely `pyvmomi <https://github.com/vmware/pyvmomi>`_ VMware vSphere API Python Bindings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env python | ||
from ezmomi import cli | ||
if __name__ == '__main__': | ||
cli() | ||
cli.cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
''' | ||
Command line option definitions | ||
''' | ||
def add_params(subparsers): | ||
# list | ||
list_parser = subparsers.add_parser('list',help='List VMware objects on your VMware server') | ||
|
||
list_parser.add_argument('--type', | ||
default='all', | ||
help='Object type, e.g. Network, VirtualMachine.') | ||
|
||
# clone | ||
clone_parser = subparsers.add_parser('clone', help='Clone a VM template to a new VM') | ||
clone_parser.add_argument('--server', | ||
type=str, | ||
help='vCenter server', | ||
) | ||
clone_parser.add_argument('--port', | ||
type=str, | ||
help='vCenter server port', | ||
) | ||
clone_parser.add_argument('--username', | ||
type=str, | ||
help='vCenter username', | ||
) | ||
clone_parser.add_argument('--password', | ||
type=str, | ||
help='vCenter password', | ||
) | ||
clone_parser.add_argument('--template', | ||
type=str, | ||
help='VM template name to clone from') | ||
clone_parser.add_argument('--hostname', | ||
type=str, | ||
help='New host name', | ||
) | ||
clone_parser.add_argument('--ips', | ||
type=str, | ||
help='Static IPs of new host, separated by a space. List primary IP first.', | ||
nargs='+', | ||
) | ||
clone_parser.add_argument('--cpus', | ||
type=int, | ||
help='Number of CPUs') | ||
clone_parser.add_argument('--mem', | ||
type=int, | ||
help='Memory in GB') | ||
clone_parser.add_argument('--domain', | ||
type=str, | ||
help='Domain, e.g. "example.com"', | ||
) | ||
|
||
# destroy | ||
destroy_parser = subparsers.add_parser('destroy', | ||
help='Destroy/delete a Virtual Machine') | ||
|
||
destroy_parser.add_argument('--name', | ||
required=True, | ||
help='VM name (case-sensitive)') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters