Update documentation

master
Jonathan Senkerik 2017-05-19 08:07:34 -04:00
parent 76043fcab2
commit c8c430a4ea
1 changed files with 73 additions and 71 deletions

110
README.md
View File

@ -7,34 +7,41 @@ Introduction
Usage
-----
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.
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 the defaults by specifying --updateDefaults.
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.
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.
The Dry run (--dry) option will go through all the sanity checks, but will not create the VM.
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.
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 ISO is set to "None". Specify the full path to the ISO image. If you specify just the ISO image (no path), the system will attempt to find the ISO image on the 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 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.
Requirements
------------
You must enable ssh access on your ESXi server.
You must enable ssh access on your ESXi server. 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.
Python and paramiko is a software requirement.
```
yum -y install python-paramiko
yum -y install python python-paramiko
```
@ -42,45 +49,47 @@ Command Line Args
-----------------
```
./esxi-vm-create -h
usage: esxi-vm-create [-h] [-d] [-v] [-H HOST] [-U USER] [-P PASSWORD]
[-n NAME] [-c CPU] [-m MEM] [-s SIZE] [-i ISO] [-N NET]
[-S STORE] [-g GUESTOS] [-u]
./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] [-V] [--summary] [-u]
ESXi Create VM utility.
ESXi Create VM utility.
optional arguments:
optional arguments:
-h, --help show this help message and exit
-d, --dry Enable Dry Run mode (False)
-v, --verbose Enable Verbose mode (False)
-H HOST, --Host HOST ESXi Host (esxi)
-H HOST, --Host HOST ESXi Host/IP (esxi)
-U USER, --User USER ESXi Host username (root)
-P PASSWORD, --Password PASSWORD
ESXi Host password (*****)
-n NAME, --name NAME VM name
-c CPU, --cpu CPU Number of vCPUS (2)
-m MEM, --mem MEM Memory in GB (4)
-s SIZE, --size SIZE Size of virt disk (20)
-m MEM, --mem MEM Memory in GB (2)
-v HDISK, --vdisk HDISK
Size of virt hdisk (12)
-i ISO, --iso ISO CDROM ISO Path | None (None)
-N NET, --net NET Network Interface | None (None)
-M MAC, --MAC MAC MAC address
-N NET, --net NET Network Interface | None (192.168.1)
-M MAC, --mac MAC MAC address
-S STORE, --store STORE
vmfs Store | LeastUsed (DS_3TB_m)
-g GUESTOS, --guestos GUESTOS
Guest OS. (centos-64)
-V, --verbose Enable Verbose mode (False)
--summary Display Summary (False)
-u, --updateDefaults Update Default VM settings stored in ~/.esxi-vm.yml
```
Examples
--------
Example Usage
-------------
Running the script for the first time it's recommended to specify your defaults. (ESXi HOST, PASSWORD)
```
./esxi-vm-create -H esxi -P MySecurePassword -u
Saving new Defaults to ~/.esxi-vm.yml
./esxi-vm-create -H esxi -P MySecurePassword -u
Saving new Defaults to ~/.esxi-vm.yml
```
@ -96,7 +105,6 @@ Examples
VM Disk: 20GB
DS Store: DS_4TB
Network: None
```
Change default number of vCPUs to 4, Memory to 8GB and vDisk size to 40GB.
@ -105,50 +113,44 @@ Examples
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.
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
Create VM Success
ESXi Host: esxi
VM NAME: testvm02
vCPU: 4
Memory: 8GB
VM Disk: 40GB
DS Store: DS_4TB
Network: 192.168.1
./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.
```
./esxi-vm-create -n testvm03 -N BadNet -S BadDS
ERROR: Disk Storage BadDS doesn't exist.
./esxi-vm-create -n testvm03 -N BadNet -S BadDS
ERROR: Disk Storage BadDS doesn't exist.
Available Disk Stores: ['DS_SSD500s', 'DS_SSD500c', 'DS_SSD250', 'DS_4TB', 'DS_3TB_m']
LeastUsed Disk Store : DS_4TB
ERROR: Virtual NIC BadNet doesn't exist.
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, enabled verbose and saving the settings 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 -v -u
Saving new Defaults to ~/.esxi-vm.yml
Create testvm03.vmx file
Create testvm03.vmdk file
Register VM
Power ON VM
./esxi-vm-create -n testvm03 -N 192.168.1 -S DS_3TB_m --summary --verbose --updateDefaults
Saving new Defaults to ~/.esxi-vm.yml
Create testvm03.vmx file
Create testvm03.vmdk file
Register VM
Power ON VM
Create VM Success
ESXi Host: esxi
VM NAME: testvm03
vCPU: 4
Memory: 8GB
VM Disk: 40GB
Format: thin
DS Store: DS_3TB_m
Network: 192.168.1
Guest OS: centos-64
Create VM Success:
ESXi Host: esxi
VM NAME: testvm03
vCPU: 2
Memory: 4GB
VM Disk: 20GB
Format: thin
DS Store: DS_3TB_m
Network: 192.168.1
Guest OS: centos-64
MAC: 00:0c:29:32:63:92
00:0c:29:32:63:92
```
License