Create VSphere resources using terraform
Project description
terraformvspherevm
This tool create and delete machine with terraform on vSphere infrastructure.
System Requirements
- python3
- terraform
Installation
pip install terraformvspherevm
Develop
Usage
Command line
Usage
$ terraformvspherevm --help
usage: terraformvspherevm [-h] --action {create,destroy} --datacenter DATACENTER
--datastore DATASTORE --pool POOL --folder FOLDER
--template TEMPLATE --guestid GUESTID --name NAME
[--nic NIC] [--ip IP] [--cidr CIDR] [--gateway GATEWAY]
--cpu CPU --ram RAM [--disk DISK] [--dns DNS] --esxhost
ESXHOST --esxuser ESXUSER --esxpassvar ESXPASSVAR --domain
DOMAIN --timezone TIMEZONE [-debug]
Manage vSphere Virtual Machines
optional arguments:
-h, --help show this help message and exit
--action {create,destroy}
Action to Execute against vSphere
--datacenter DATACENTER
ESXi Datacenter
--datastore DATASTORE
ESXi Datastore
--pool POOL ESXi Resource Pool
--folder FOLDER ESXi VM Folder
--template TEMPLATE Template Name
--guestid GUESTID Guest ID
--name NAME Virtual Machine Name
--nic NIC Network Interface. Repeat option for several NICs
--ip IP NIC IP address. Repeat option for several NICs
--cidr CIDR NIC CIDR. Repeat option for several NICs
--gateway GATEWAY Default gateway
--cpu CPU CPUs
--ram RAM Memory
--disk DISK Additionnal disk in GB. Repeat option for several
disks
--dns DNS DNS server
--esxhost ESXHOST ESXi host
--esxuser ESXUSER ESXi Username
--esxpassvar ESXPASSVAR
Environment variable that contain ESXi password
--domain DOMAIN DNS domain
--timezone TIMEZONE TimeZone
-debug Verbose Output
When you want to destroy a VM, tfstate file is not required
Examples
Create a VM
terraformvspherevm --name terrascript-test --datacenter "DC" --datastore "MyDatastore" \
--pool "ressource_pool" --template "rhel-7.5-vmw6.0" --guestid "rhel7_64Guest" --nic DvP_Nmae \
--ip 10.0.123.123 --cidr 24 --gateway 10.0.123.1 --cpu 1 --ram 1024 --disk 10 --dns 10.0.123.50 \
--dns 10.0.123.100 --esxhost esxhost.domain.com --esxuser "esxusername" --folder "terraformed" \
--domain my.domaon --timezone "Etc/UTC" --esxpassvar ESXPASS --action create
Destroy a VM
terraformvspherevm --name terrascript-test --datacenter "DC" --datastore "MyDatastore" \
--pool "ressource_pool" --template "rhel-7.5-vmw6.0" --guestid "rhel7_64Guest" --cpu 1 \
--ram 1024 --esxhost esxhost.domain.com --esxuser "esxusername" --folder "terraformed" \
--esxpassvar ESXPASS --action destroy
In Python Code
from terraformvspherevm import TerraformVM
vmProperties = {'name': 'myVM', ...}
tvm = TerraformVM()
tvm.addVirtualMachine(vmProperties)
tvm.createVM('myVM')
tvm.destroyVM('myVM')
Development
Virtualenv and dependencies
python -m venv venv
source ./venv/bin/activate
python -m pip install -r requirements.txt
Run command
$ python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import terraformvm
>>> terraformvm.main(['--help'])
Build
python setup.py sdist bdist_wheel
Upload PyPi
twine upload dist/*
TODOLIST
- Code documentation
- arguments validation
- Error management
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for terraformvspherevm-0.0.12.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d22b8fb2de6f2ad074867298cbcf3fcda6d0b7e6c2febd452117c4288878ef2b |
|
MD5 | f7cd95853ccb7b06fe2ee6f84b483e3e |
|
BLAKE2b-256 | c8cf9ab0fd8f125be99ceab14405b06c9e619b62f4f32d9ee75dbcf755b550c1 |
Close
Hashes for terraformvspherevm-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e4e9d93a9ea6aa6d4b43ccdd013e6c61043c3d28a9147aa227391438c9847e0 |
|
MD5 | aeb1568abb01b142729b80afba91703b |
|
BLAKE2b-256 | 177ee49d7399b9aed25bc1efd521406ff345885353b1580cd8258326de97cbf9 |