mirror of https://github.com/Kodomo/esxi-vm
Fixed VMNIC and MEMORY in MB
parent
d7b891a70b
commit
205f089605
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import argparse # Argument parser
|
import argparse # Argument parser
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ parser.add_argument("-P", "--Password", dest='PASSWORD', type=str, help="ESXi Ho
|
||||||
parser.add_argument("-K", "--Key", dest='KEY', type=str, help="ESXi Host path to private key ({})".format(KEY))
|
parser.add_argument("-K", "--Key", dest='KEY', type=str, help="ESXi Host path to private key ({})".format(KEY))
|
||||||
parser.add_argument("-n", "--name", dest='NAME', type=str, help="VM name ()".format(NAME))
|
parser.add_argument("-n", "--name", dest='NAME', type=str, help="VM name ()".format(NAME))
|
||||||
parser.add_argument("-c", "--cpu", dest='CPU', type=int, help="Number of vCPUS ({})".format(CPU))
|
parser.add_argument("-c", "--cpu", dest='CPU', type=int, help="Number of vCPUS ({})".format(CPU))
|
||||||
parser.add_argument("-m", "--mem", type=int, help="Memory in GB ({})".format(MEM))
|
parser.add_argument("-m", "--mem", type=int, help="Memory in MB ({})".format(MEM))
|
||||||
parser.add_argument("-v", "--vdisk", dest='HDISK', type=str, help="Size of virt hdisk ({})".format(HDISK))
|
parser.add_argument("-v", "--vdisk", dest='HDISK', type=str, help="Size of virt hdisk ({})".format(HDISK))
|
||||||
parser.add_argument("-i", "--iso", dest='ISO', type=str, help="CDROM ISO Path | None ({})".format(ISO))
|
parser.add_argument("-i", "--iso", dest='ISO', type=str, help="CDROM ISO Path | None ({})".format(ISO))
|
||||||
parser.add_argument("-N", "--net", dest='NET', type=str, help="Network Interface | None ({})".format(NET))
|
parser.add_argument("-N", "--net", dest='NET', type=str, help="Network Interface | None ({})".format(NET))
|
||||||
|
@ -178,7 +178,9 @@ try:
|
||||||
VMNICS = []
|
VMNICS = []
|
||||||
for line in stdout.readlines():
|
for line in stdout.readlines():
|
||||||
splitLine = re.split('[,\n]', line)
|
splitLine = re.split('[,\n]', line)
|
||||||
VMNICS.append(splitLine[0])
|
for nics in splitLine:
|
||||||
|
if nics.strip():
|
||||||
|
VMNICS.append(nics.strip())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("The Error is {}".format(e))
|
print("The Error is {}".format(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -239,10 +241,10 @@ if CPU < 1 or CPU > 128:
|
||||||
ErrorMessages += " {} CPU out of range. [1-128].".format(CPU)
|
ErrorMessages += " {} CPU out of range. [1-128].".format(CPU)
|
||||||
CheckHasErrors = True
|
CheckHasErrors = True
|
||||||
|
|
||||||
# Check MEM
|
# Check MEM below 16GiB
|
||||||
if MEM < 1 or MEM > 4080:
|
if MEM < 256 or MEM > 16384:
|
||||||
print("{} GB Memory out of range. [1-4080].".format(MEM))
|
print("{} MB Memory out of range. [256-16384].".format(MEM))
|
||||||
ErrorMessages += " {} GB Memory out of range. [1-4080].".format(MEM)
|
ErrorMessages += " {} MB Memory out of range. [256-16384].".format(MEM)
|
||||||
CheckHasErrors = True
|
CheckHasErrors = True
|
||||||
|
|
||||||
# Check HDISK
|
# Check HDISK
|
||||||
|
@ -300,7 +302,7 @@ vmx = {
|
||||||
'scsi0.present': 'TRUE',
|
'scsi0.present': 'TRUE',
|
||||||
'scsi0.sharedBus': 'none',
|
'scsi0.sharedBus': 'none',
|
||||||
'scsi0.virtualDev': 'pvscsi',
|
'scsi0.virtualDev': 'pvscsi',
|
||||||
'memsize': str(MEM * 1024),
|
'memsize': str(MEM),
|
||||||
'scsi0:0.present': 'TRUE',
|
'scsi0:0.present': 'TRUE',
|
||||||
'scsi0:0.fileName': "{}.vmdk".format(NAME),
|
'scsi0:0.fileName': "{}.vmdk".format(NAME),
|
||||||
'scsi0:0.deviceType': 'scsi-hardDisk',
|
'scsi0:0.deviceType': 'scsi-hardDisk',
|
||||||
|
@ -436,7 +438,7 @@ if isSummary:
|
||||||
print("ESXi Port: {}".format(PORT))
|
print("ESXi Port: {}".format(PORT))
|
||||||
print("VM NAME: {}".format(NAME))
|
print("VM NAME: {}".format(NAME))
|
||||||
print("vCPU: {}".format(CPU))
|
print("vCPU: {}".format(CPU))
|
||||||
print("Memory: {} GB".format(MEM))
|
print("Memory: {} MB".format(MEM))
|
||||||
print("VM Disk: {} GB".format(HDISK))
|
print("VM Disk: {} GB".format(HDISK))
|
||||||
if isVerbose:
|
if isVerbose:
|
||||||
print("Format: {}".format(DISKFORMAT))
|
print("Format: {}".format(DISKFORMAT))
|
||||||
|
|
|
@ -34,9 +34,9 @@ def setup_config():
|
||||||
PASSWORD="",
|
PASSWORD="",
|
||||||
KEY="",
|
KEY="",
|
||||||
|
|
||||||
# Default number of vCPU's, GB Mem, & GB boot disk
|
# Default number of vCPU's, MB Mem, & GB boot disk
|
||||||
CPU=2,
|
CPU=2,
|
||||||
MEM=4,
|
MEM=4096,
|
||||||
HDISK=20,
|
HDISK=20,
|
||||||
|
|
||||||
# Default Disk format thin, zeroedthick, eagerzeroedthick
|
# Default Disk format thin, zeroedthick, eagerzeroedthick
|
||||||
|
@ -55,7 +55,7 @@ def setup_config():
|
||||||
ISO="None",
|
ISO="None",
|
||||||
|
|
||||||
# Default GuestOS type. (See VMware documentation for all available options)
|
# Default GuestOS type. (See VMware documentation for all available options)
|
||||||
GUESTOS="centos-64",
|
GUESTOS="debian8-64",
|
||||||
|
|
||||||
# Extra VMX options
|
# Extra VMX options
|
||||||
VMXOPTS=""
|
VMXOPTS=""
|
||||||
|
|
Loading…
Reference in New Issue