diff --git a/README.md b/README.md index f1cb984..cc26bfe 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Usage 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 or Network are set to "None". + By default the ISO and Network are set to "None". 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. Use COBBLER, Foreman, Razor, or your favorite provisioning tools. diff --git a/esxi-vm-create b/esxi-vm-create index 611da84..881ba08 100755 --- a/esxi-vm-create +++ b/esxi-vm-create @@ -173,8 +173,18 @@ if ISO != "": try: (stdin, stdout, stderr) = ssh.exec_command("ls " + str(ISO)) type(stdin) - if not stdout.readlines() and stderr.readlines(): + if stdout.readlines() and not stderr.readlines(): ISOfound = True + else: + # If ISO has no "/", try to find the ISO + if not re.match('/', ISO): + #(stdin, stdout, stderr) = ssh.exec_command("find /vmfs/volumes/ -type f -name " + ISO + "-exec sh -c 'echo $1; kill $PPID' sh {} 2>/dev/null \;") + (stdin, stdout, stderr) = ssh.exec_command("find /vmfs/volumes/ -type f -name " + ISO ) + type(stdin) + FoundISOPath = str(stdout.readlines()) + print "FoundISOPath: " + str(FoundISOPath) + if re.match('/', FoundISOPath): + ISO = FoundISOPath except: e = sys.exc_info()[0] print "The Error is " + str(e)