]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding boot delay, changing debug output
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 12 Apr 2018 10:26:56 +0000 (12:26 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 12 Apr 2018 10:26:56 +0000 (12:26 +0200)
lib/cr_vmware_tpl/handler.py

index bd413da8083178dde9840df39366ee3ef56110c4..ef3bdb498e15f3af6425487fd13b1fa9c32b00c3 100644 (file)
@@ -29,7 +29,7 @@ from pyVmomi import vim, vmodl
 from pyVim.connect import SmartConnect, Disconnect
 
 # Own modules
-from .common import pp
+from .common import pp, to_str
 
 from .errors import FunctionNotImplementedError, PpError
 
@@ -37,7 +37,7 @@ from .obj import PpBaseObject
 
 from .config import CrTplConfiguration
 
-__version__ = '0.6.3'
+__version__ = '0.6.4'
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
 
@@ -582,14 +582,21 @@ class CrTplHandler(PpBaseObject):
         created_opt.value = int(time.time())
         extra_opts.append(created_opt)
 
+        # Set waiting for 3 second in BIOS before booting
+        boot_opts = vim.vm.BootOptions()
+        boot_opts.bootDelay = 3000
+        boot_opts.bootRetryEnabled = False
+        boot_opts.enterBIOSSetup = False
+
         config = vim.vm.ConfigSpec(
             name=self.config.template_vm, deviceChange=dev_changes,
             flags=vm_flags, extraConfig=extra_opts,
             memoryMB=self.config.ram_mb, memoryHotAddEnabled=True,
             numCPUs=self.config.num_cpus, cpuHotAddEnabled=True, cpuHotRemoveEnabled=True,
             files=vm_file_info,
-            guestId = 'oracleLinux64Guest',
-            version = 'vmx-11',
+            guestId='oracleLinux64Guest',
+            version='vmx-11',
+            bootOptions=boot_opts,
             #guestFullName='Oracle Enterprise Linux 7 (64 Bit)',
             #alternateGuestName='OEL 7/64',
         )
@@ -668,15 +675,16 @@ class CrTplHandler(PpBaseObject):
             cur_time = time.time()
             cur_duration = cur_time - self.ts_start_install
             if (cur_time - last_dot) >= self.interval_dot:
-                print('.', end='', flush=True)
-                i += 1
-                if i >= 60:
-                    print('', flush=True)
-                    print('       ', end='', flush=True)
-                    i = 0
-                last_dot = cur_time
+                if self.verbose < 3:
+                    print('.', end='', flush=True)
+                    i += 1
+                    if i >= 60:
+                        print('', flush=True)
+                        print('       ', end='', flush=True)
+                        i = 0
+                    last_dot = cur_time
 
-            if self.verbose > 2:
+            if self.verbose > 3:
                 LOG.debug("Trying to connect to {a} via TCP port {p} ...".format(
                     a=sockaddr[0], p=sockaddr[1]))
 
@@ -692,7 +700,7 @@ class CrTplHandler(PpBaseObject):
             except socket.error as e:
                 sock.close()
                 sock = None
-                if self.verbose > 2:
+                if self.verbose > 3:
                     LOG.debug("Could not connect: {}".format(e))
                 continue