mirror of https://github.com/Kodomo/esxi-vm
Reformat README, add clarifications about software requirements and add the new parameters --T and --K.
parent
40f5233f85
commit
59c4a5b11c
92
README.md
92
README.md
|
@ -1,47 +1,45 @@
|
|||
Introduction
|
||||
------------
|
||||
|
||||
This utility is a simple to use comand line tool to create VMs on an ESXi host from from a system running python and ssh. vCenter is not required. This tool is an easy way to automate building VM's from command line or from other testing or automation tools such as Bamboo, Puppet, Saltstack, or Chef.
|
||||
|
||||
This utility is a simple to use comand line tool to create VMs on an ESXi host from from a system running python and SSH. vCenter is **not required**. This tool is an easy way to automate building VM's from command line or from other testing or automation tools such as Bamboo, Puppet, Saltstack, or Chef.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Get help using --help option. The defaults will be displayed in the help output.
|
||||
* Get help using `--help` option. The defaults will be displayed in the help output.
|
||||
|
||||
The only command line required paramater is the VM name (-n), all other command line arguments are optional.
|
||||
* The only command line required paramater is the VM name (`-n`), all other command line arguments are optional.
|
||||
|
||||
* Defaults are stored in your home directory in `~/.esxi-vm.yml`. You can edit this file directly, or you can use the tool to update most the defaults by specifying `--updateDefaults`.
|
||||
|
||||
Defaults are stored in your home directory in ~/.esxi-vm.yml. You can edit this file directly, or you can use the tool to update most the defaults by specifying --updateDefaults.
|
||||
* One of the first settings to set and save as defaults is the `--Host` (`-H`), `--User` (`-U`) and `--Password` (`-P`).
|
||||
|
||||
One of the first settings to set and save as defaults is the --Host (-H), --User (-U) and --Password (-P).
|
||||
* Some basic sanity checks are done on the ESXi host before creating the VM. The `--verbose` (`-V`) option will give you a little more details in the creation process. If an invalid Disk Stores or Network Interface is specified, the available devices will be shown in the error message. The tool will not show the list of available ISO images, and Guest OS types. CPU, Memory, Virtual Disk sizes are based on ESXi 6.0 limitations.
|
||||
|
||||
Some basic sanity checks are done on the ESXi host before creating the VM. The --verbose (-V) option will give you a little more details in the creation process. If an invalid Disk Stores or Network Interface is specified, the available devices will be shown in the error message. The tool will not show the list of available ISO images, and Guest OS types. CPU, Memory, Virtual Disk sizes are based on ESXi 6.0 limitations.
|
||||
* The `--dry` (`-d`) option will go through the sanity checks, but will not create the VM.
|
||||
|
||||
The --dry (-d) option will go through the sanity checks, but will not create the VM.
|
||||
* By default the Disk Store is set to `LeastUsed. This will use the Disk Store with the most free space (in bytes).
|
||||
|
||||
By default the Disk Store is set to "LeastUsed". This will use the Disk Store with the most free space (in bytes).
|
||||
* By default the ISO is set to `None`. Specify the full path to the ISO image. If you specify just the ISO image filename (no path), the system will attempt to find the ISO image on your DataStores.
|
||||
|
||||
By default the ISO is set to "None". Specify the full path to the ISO image. If you specify just the ISO image filename (no path), the system will attempt to find the ISO image on your DataStores.
|
||||
* By default the Network set set to `None`. A full or partial MAC address can be specified. A partial MAC address argument would be 3 Hex pairs which would then be prepended by VMware's OEM `00:50:56`.
|
||||
|
||||
By default the Network set set to "None". A full or partial MAC address can be specified. A partial MAC address argument would be 3 Hex pairs which would then be prepended by VMware's OEM "00:50:56".
|
||||
* By default the VM is powered on. If an ISO was specified, then it will boot the ISO image. Otherwise, the VM will attempt a PXE boot if a Network Interface was specified. You could customize the ISO image to specify the kickstart file, or PXE boot using COBBLER, Foreman, Razor, or your favorite provisioning tool.
|
||||
|
||||
By default the VM is powered on. If an ISO was specified, then it will boot the ISO image. Otherwise, the VM will attempt a PXE boot if a Network Interface was specified. You could customize the ISO image to specify the kickstart file, or PXE boot using COBBLER, Foreman, Razor, or your favorite provisioning tool.
|
||||
|
||||
To help with automated provisioning, the script will output the full MAC address and exit code 0 on success. You can specify --summary to get a more detailed summary of the VM that was created.
|
||||
* To help with automated provisioning, the script will output the full MAC address and exit code 0 on success. You can specify `--summary` to get a more detailed summary of the VM that was created.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
You must enable ssh access on your ESXi server. Google 'how to enable ssh access on esxi' for instructions. The VMware VIX API tools are not required.
|
||||
* You must enable ssh access on your ESXi server. Google 'how to enable ssh access on esxi' for instructions. The VMware VIX API tools are **not required**.
|
||||
|
||||
It's HIGHLY RECOMMENDED to use password-less authentication by copying your ssh public keys to the ESXi host, otherwise your ESXi root password could be stored in clear-text in your home directory.
|
||||
* It's **highly recommenced** to use password-less authentication by copying your ssh public keys to the ESXi host, otherwise your ESXi root password could be stored in clear-text in your home directory.
|
||||
|
||||
Python and paramiko is a software requirement.
|
||||
* Python 2.7 [paramiko](http://www.paramiko.org) and [PyYAML](https://github.com/yaml/pyyaml) are software requirements.
|
||||
|
||||
```
|
||||
yum -y install python python-paramiko
|
||||
pip install paramiko pyyaml
|
||||
```
|
||||
|
||||
|
||||
|
@ -51,10 +49,10 @@ Command Line Args
|
|||
```
|
||||
./esxi-vm-create --help
|
||||
|
||||
usage: esxi-vm-create [-h] [-d] [-H HOST] [-U USER] [-P PASSWORD] [-n NAME]
|
||||
[-c CPU] [-m MEM] [-v HDISK] [-i ISO] [-N NET] [-M MAC]
|
||||
[-S STORE] [-g GUESTOS] [-o VMXOPTS] [-V] [--summary]
|
||||
[-u]
|
||||
usage: esxi-vm-create [-h] [-d] [-H HOST] [-T PORT] [-U USER] [-P PASSWORD]
|
||||
[-K KEY] [-n NAME] [-c CPU] [-m MEM] [-v HDISK] [-i ISO]
|
||||
[-N NET] [-M MAC] [-S STORE] [-g GUESTOS] [-o VMXOPTS]
|
||||
[-V] [--summary] [-u]
|
||||
|
||||
ESXi Create VM utility.
|
||||
|
||||
|
@ -62,9 +60,11 @@ optional arguments:
|
|||
-h, --help show this help message and exit
|
||||
-d, --dry Enable Dry Run mode (False)
|
||||
-H HOST, --Host HOST ESXi Host/IP (esxi)
|
||||
-T PORT, --Port PORT ESXi Port number (22)
|
||||
-U USER, --User USER ESXi Host username (root)
|
||||
-P PASSWORD, --Password PASSWORD
|
||||
ESXi Host password (*****)
|
||||
-K KEY, --Key KEY ESXi Host connection key (path to private key)
|
||||
-n NAME, --name NAME VM name
|
||||
-c CPU, --cpu CPU Number of vCPUS (2)
|
||||
-m MEM, --mem MEM Memory in GB (4)
|
||||
|
@ -84,19 +84,18 @@ optional arguments:
|
|||
-u, --updateDefaults Update Default VM settings stored in ~/.esxi-vm.yml
|
||||
```
|
||||
|
||||
|
||||
Example Usage
|
||||
-------------
|
||||
|
||||
Running the script for the first time it's recommended to specify your defaults. (ESXi HOST, PASSWORD)
|
||||
* Running the script for the first time is recommended to specify your defaults (ESXi HOST, PASSWORD).
|
||||
|
||||
```
|
||||
./esxi-vm-create -H esxi -P MySecurePassword -u
|
||||
Saving new Defaults to ~/.esxi-vm.yml
|
||||
```
|
||||
|
||||
* Create a new VM named `testvm01` using all defaults from `~/.esxi-vm.yml`.
|
||||
|
||||
Create a new VM named testvm01 using all defaults from ~/.esxi-vm.yml.
|
||||
```
|
||||
./esxi-vm-create -n testvm01 --summary
|
||||
|
||||
|
@ -107,22 +106,23 @@ Memory: 4GB
|
|||
VM Disk: 20GB
|
||||
DS Store: DS_4TB
|
||||
Network: None
|
||||
|
||||
```
|
||||
|
||||
Change default number of vCPUs to 4, Memory to 8GB and vDisk size to 40GB.
|
||||
* Change default number of vCPUs to `4`, Memory to `8GB` and vDisk size to `40GB`.
|
||||
|
||||
```
|
||||
./esxi-vm-create -c 4 -m 8 -s 40 -u
|
||||
./esxi-vm-create -c 4 -m 8 -v 40 -u
|
||||
Saving new Defaults to ~/.esxi-vm.yml
|
||||
```
|
||||
|
||||
Create a new VM named testvm02 using new defaults from ~/.esxi-vm.yml and specifying a Network interface and partial MAC.
|
||||
* Create a new VM named `testvm02` using new defaults from `~/.esxi-vm.yml` and specifying a Network interface and partial MAC.
|
||||
|
||||
```
|
||||
./esxi-vm-create -n testvm02 -N 192.168.1 -M 01:02:03
|
||||
00:50:56:01:02:03
|
||||
```
|
||||
|
||||
Available Network Interfaces and Available Disk Storage volumes will be listed if an invalid option is specified.
|
||||
* Available *Network Interfaces* and *Available Disk Storage* volumes are listed if an invalid option is specified.
|
||||
|
||||
```
|
||||
./esxi-vm-create -n testvm03 -N BadNet -S BadDS
|
||||
|
@ -133,7 +133,8 @@ ERROR: Virtual NIC BadNet doesn't exist.
|
|||
Available VM NICs: ['192.168.1', '192.168.0', 'VM Network test'] or 'None'
|
||||
```
|
||||
|
||||
Create a new VM named testvm03 using a valid Network Interface, valid Disk Storage volume, summary and verbose enabled. Save as default.
|
||||
* Create a new VM named `testvm03` using a valid *Network Interface*, valid *Disk Storage* volume, summary and verbose enabled. Save as default.
|
||||
|
||||
```
|
||||
./esxi-vm-create -n testvm03 -N 192.168.1 -S DS_3TB_m --summary --verbose --updateDefaults
|
||||
Saving new Defaults to ~/.esxi-vm.yml
|
||||
|
@ -156,7 +157,8 @@ MAC: 00:0c:29:32:63:92
|
|||
00:0c:29:32:63:92
|
||||
```
|
||||
|
||||
Create a new VM named testvm04 specifying an ISO file to boot.
|
||||
* Create a new VM named `testvm04` specifying an ISO file to boot.
|
||||
|
||||
```
|
||||
./esxi-vm-create -n testvm04 --summary --iso CentOS-7-x86_64-Minimal-1611.iso
|
||||
FoundISOPath: /vmfs/volumes/5430094d-5a4fa180-4962-0017a45127e2/ISO/CentOS-7-x86_64-Minimal-1611.iso
|
||||
|
@ -181,16 +183,32 @@ MAC: 00:0c:29:ea:a0:42
|
|||
|
||||
```
|
||||
|
||||
Merge/Add extra VMX options, saved as default.
|
||||
* Merge/Add extra VMX options, saved as default.
|
||||
|
||||
```
|
||||
./esxi-vm-create -o 'floppy0.present = "TRUE",svga.autodetect = "TRUE",svga.present = "TRUE"' -u
|
||||
Saving new Defaults to ~/.esxi-vm.yml
|
||||
```
|
||||
|
||||
* Create a new VM named `testvm04` on the host `esxi2` accessible on port `2222` (instead of the usual `22`) and with an explicit private key `/home/user1/.ssh/id_rsa_esxi2`.
|
||||
|
||||
```
|
||||
./esxi-vm-create -H esxi2 -T 2222 -K /home/user1/.ssh/id_rsa_esxi2 -n testvm04 --summary
|
||||
|
||||
Create VM Success:
|
||||
VM NAME: testvm04
|
||||
vCPU: 2
|
||||
Memory: 4GB
|
||||
VM Disk: 20GB
|
||||
DS Store: DS_4TB
|
||||
Network: None
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (C) 2017 Jonathan Senkerik
|
||||
* Copyright (C) 2017 Jonathan Senkerik
|
||||
* Modifications Copyright (C) 2018 Sebastien Andrivet
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -206,9 +224,3 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
Support
|
||||
-------
|
||||
Website : http://www.jintegrate.co
|
||||
github : http://github.com/josenk/
|
||||
bitcoin : 1HCTVkmSXepQahJfvuxQRhUMem1HpHq3Mq
|
||||
paypal : josenk@jintegrate.co
|
||||
|
|
|
@ -51,7 +51,7 @@ parser.add_argument("-H", "--Host", dest='HOST', type=str, help="ESXi Host/IP (
|
|||
parser.add_argument("-T", "--Port", dest='PORT', type=str, help="ESXi Port number (" + str(PORT) + ")")
|
||||
parser.add_argument("-U", "--User", dest='USER', type=str, help="ESXi Host username (" + str(USER) + ")")
|
||||
parser.add_argument("-P", "--Password", dest='PASSWORD', type=str, help="ESXi Host password (*****)")
|
||||
parser.add_argument("-K", "--Key", dest='KEY', type=str, help="ESXi Host connection key")
|
||||
parser.add_argument("-K", "--Key", dest='KEY', type=str, help="ESXi Host connection key (path to private key)")
|
||||
parser.add_argument("-n", "--name", dest='NAME', type=str, help="VM name")
|
||||
parser.add_argument("-c", "--cpu", dest='CPU', type=int, help="Number of vCPUS (" + str(CPU) + ")")
|
||||
parser.add_argument("-m", "--mem", type=int, help="Memory in GB (" + str(MEM) + ")")
|
||||
|
|
Loading…
Reference in New Issue