# Own modules
from fb_tools.config import ConfigError, BaseConfiguration
-__version__ = '1.1.1'
+__version__ = '1.2.0'
LOG = logging.getLogger(__name__)
default_network = '192.168.88.0_23'
default_mac_address = '00:16:3e:54:ab:2b'
default_max_wait_for_general = 15
+ default_max_wait_for_shutdown = 600
default_max_wait_for_finish_install = 60 * 60
default_max_nr_templates_stay = 4
default_vmware_cfg_version = 'vmx-13'
self.max_wait_for_general = self.default_max_wait_for_general
self.max_wait_for_create_vm = None
self.max_wait_for_poweron_vm = None
- self.max_wait_for_shutdown_vm = None
+ self.max_wait_for_shutdown_vm = self.default_max_wait_for_shutdown
+ self.max_wait_for_purge_vm = None
self.max_wait_for_finish_install = self.default_max_wait_for_finish_install
self.max_nr_templates_stay = self.default_max_nr_templates_stay
self.vmware_cfg_version = self.default_vmware_cfg_version
return res
+ # -------------------------------------------------------------------------
+ def eval_config(self, config):
+ """Evaluating of all found configuration options."""
+
+ super(CrTplConfiguration, self).eval_config(config)
+
+ if self.verbose > 1:
+ LOG.debug("Checking for unconfigured options ...")
+
+ if self.max_wait_for_create_vm is None:
+ self.max_wait_for_create_vm = self.max_wait_for_general
+ if self.max_wait_for_poweron_vm is None:
+ self.max_wait_for_poweron_vm = self.max_wait_for_general
+ if self.max_wait_for_purge_vm is None:
+ self.max_wait_for_purge_vm = self.max_wait_for_general
+ if self.max_wait_for_shutdown_vm is None:
+ self.max_wait_for_shutdown_vm = self.max_wait_for_general
+
# -------------------------------------------------------------------------
def eval_config_section(self, config, section_name):
elif key.lower() == 'os_version':
self.os_version = value.strip()
- self._eval_config_timeouts(config, section_name)
-
return
# -------------------------------------------------------------------------
prop_name='max_wait_for_shutdown_vm', value=value,
min_val=self.min_max_wait_for_finish_general,
max_val=self.max_max_wait_for_finish_general,
+ default_val=self.default_max_wait_for_shutdown)
+ elif key.lower() == 'max_wait_for_purge_vm':
+ self._eval_timeout_value(
+ prop_name='max_wait_for_purge_vm', value=value,
+ min_val=self.min_max_wait_for_finish_general,
+ max_val=self.max_max_wait_for_finish_general,
default_val=self.max_wait_for_general)
elif key.lower() == 'max_wait_for_finish_install':
self._eval_timeout_value(
max_val=self.max_max_wait_for_finish_install,
default_val=self.default_max_wait_for_finish_install)
- if self.max_wait_for_create_vm is None:
- self.max_wait_for_create_vm = self.max_wait_for_general
- if self.max_wait_for_poweron_vm is None:
- self.max_wait_for_poweron_vm = self.max_wait_for_general
- if self.max_wait_for_shutdown_vm is None:
- self.max_wait_for_shutdown_vm = self.max_wait_for_general
-
# =============================================================================
if __name__ == "__main__":
from .config import CrTplConfiguration
-__version__ = '1.1.0'
+__version__ = '1.2.0'
LOG = logging.getLogger(__name__)
TZ = pytz.timezone('Europe/Berlin')
self.ssh_port = 22
self.ssh_user = 'root'
self.ssh_timeout = 30
- self.max_wait_for_shutdown = 600
self.rotate_only = False
self.abort = False
self.postinstall_errors = None
else:
raise HandlerError("Could not find VM after creating.")
- self.vsphere.poweron_vm(self.tpl_vm)
+ 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()
else:
self.post_install_tasks_ssh()
if self.postinstall_errors:
- self.vsphere.purge_vm(self.tpl_vm)
+ self.vsphere.purge_vm(self.tpl_vm, max_wait=self.config.max_wait_for_purge_vm)
return 10
else:
self.poweroff_vm()
self.vsphere.create_vm(
name=self.config.template_vm, vm_folder=tpl_vm_folder, vm_config_spec=vm_spec,
- pool=self.cluster.resource_pool, max_wait=15)
+ pool=self.cluster.resource_pool, max_wait=self.config.max_wait_for_create_vm)
# -------------------------------------------------------------------------
def wait_for_finish_install(self):
LOG.info("Template VM {h!r} was shutting down in {t:0.1f} seconds.".format(
h=self.config.template_vm, t=cur_diff))
return
- if cur_diff >= self.max_wait_for_shutdown:
+ if cur_diff >= self.config.max_wait_for_shutdown_vm:
break
print('', flush=True)