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
Metadata
Release files for terraformvspherevm 0.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| terraformvspherevm-0.0.13.tar.gz | 7.8 kB | Without provenance | Details for terraformvspherevm-0.0.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| terraformvspherevm-0.0.13-py3-none-any.whl | Python 3 | none | any | Details for terraformvspherevm-0.0.13-py3-none-any.whl |
Total release size: 16.5 kB
Release files / terraformvspherevm-0.0.13.tar.gz
| Download URL | terraformvspherevm-0.0.13.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70d128be36dccb3d932efcc6d4a706efb753b3dba49a054baa744aa6f7ba42ad
|
|
BLAKE2b-256 checksum How to use checksums |
6927f35562daa8a06e9faa1c39eb1c0d19d3de74691edeee7c89ca1e63e7b79c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
|
Release files / terraformvspherevm-0.0.13-py3-none-any.whl
| Download URL | terraformvspherevm-0.0.13-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
041758feafa133d723016b5770d31cee8c4ec00d5ff1047936f402a1b3ab1f36
|
|
BLAKE2b-256 checksum How to use checksums |
b003cbe2bc89ebd018a7ec6bd9ac265b784d41720e18f6fc174a256d17d8212b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
|
Security for terraformvspherevm 0.0.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.