from .xlate import XLATOR
-__version__ = '1.5.11'
+__version__ = '1.6.1'
LOG = logging.getLogger(__name__)
TZ = pytz.timezone('Europe/Berlin')
"""
max_depth = 10
+ vm_boot_delay_secs = 5
re_local_ds = re.compile(r'^local[_-]', re.IGNORECASE)
re_share_nfs_ds = re.compile(r'(?:share[_-]*nfs|nfs[_-]*share)', re.IGNORECASE)
self.tpl_vm = None
self.tpl_vm_hostname = None
self.tpl_macaddress = None
+ self.tpl_ip = None
self.ts_start_install = None
self.ts_finish_install = None
self.initial_sleep = 60
self.vsphere.poweron_vm(self.tpl_vm, max_wait=self.config.max_wait_for_poweron_vm)
self.ts_start_install = time.time()
-# self.wait_for_finish_install()
+ self.eval_tpl_ip()
+ self.wait_for_finish_install()
# self.get_postinstall_error()
# if self.abort:
vm_spec = self.vsphere.generate_vm_create_spec(
name=self.tpl_vm_fqdn, datastore=self.tpl_data_store.name,
disks=[disk_size], nw_interfaces=[iface], graphic_ram_mb=256,
- videao_ram_mb=32, boot_delay_secs=5, ram_mb=self.config.ram_mb,
+ videao_ram_mb=32, boot_delay_secs=self.vm_boot_delay_secs, ram_mb=self.config.ram_mb,
num_cpus=self.config.num_cpus, ds_with_timestamp=True,
os_version=self.config.os_version, cfg_version=self.config.vmware_cfg_version)
name=self.tpl_vm_fqdn, vm_folder=tpl_vm_folder, vm_config_spec=vm_spec,
pool=self.cluster.resource_pool, max_wait=self.config.max_wait_for_create_vm)
+ # -------------------------------------------------------------------------
+ def eval_tpl_ip(self):
+
+ LOG.info(_("Trying to evaluate the IP address of the template VM ..."))
+
+ initial_delay = self.vm_boot_delay_secs + 10
+
+ LOG.debug(_("Waiting initially for {} seconds:").format(initial_delay))
+ print(' ==> ', end='', flush=True)
+
+ start_time = time.time()
+ cur_time = start_time
+ cur_duration = 0
+
+ while cur_duration <= initial_delay:
+ time.sleep(1)
+ cur_time = time.time()
+ print('.', end='', flush=True)
+ cur_duration = cur_time - start_time
+ print('', flush=True)
+
+ self.tpl_ip = self.cobbler.get_dhcp_ip(self.tpl_macaddress)
+ if not self.tpl_ip:
+ msg = _(
+ "Did not got the IP address of MAC address {mac!r} after "
+ "{delay} seconds.").format(mac=self.tpl_macaddress, delay=initial_delay)
+ raise ExpectedHandlerError(msg)
+
+ LOG.info(_("Got IP address {!r} for template VM.").format(self.tpl_ip))
+
# -------------------------------------------------------------------------
def wait_for_finish_install(self):
LOG.debug(_("Waiting for SSH available ..."))
- addr_infos = socket.getaddrinfo(
- self.config.template_vm, 22, socket.AF_INET, socket.SOCK_STREAM)
+ addr_infos = socket.getaddrinfo(self.tpl_ip, 22, socket.AF_INET, socket.SOCK_STREAM)
if self.verbose > 1:
msg = _("Got following address_infos for {h!r}, IPv4 TCP port {p}:").format(
- h=self.config.template_vm, p=22)
+ h=self.tpl_ip, p=22)
msg += '\n' + pp(addr_infos)
LOG.debug(msg)
if not addr_infos:
raise HandlerError(_("Did not get address infos for {h!r}, IPv4 TCP port {p}.").format(
- h=self.config.template_vm, p=22))
+ h=self.tpl_ip, p=22))
addr_info = random.choice(addr_infos)
LOG.debug(_("Using address info: {}").format(pp(addr_info)))