From 7b0f6e479b5c4ce3d720546949c70db3d20b5a11 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 13 Apr 2018 13:32:31 +0200 Subject: [PATCH] Adding config parameter max_nr_templates_stay --- lib/cr_vmware_tpl/config.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/cr_vmware_tpl/config.py b/lib/cr_vmware_tpl/config.py index 35619ba..fed0751 100644 --- a/lib/cr_vmware_tpl/config.py +++ b/lib/cr_vmware_tpl/config.py @@ -27,7 +27,7 @@ from .errors import FunctionNotImplementedError, PpError from .obj import PpBaseObject -__version__ = '0.5.2' +__version__ = '0.5.3' LOG = logging.getLogger(__name__) @@ -59,6 +59,7 @@ class CrTplConfiguration(PpBaseObject): default_network = '192.168.88.0_23' default_mac_address = '00:16:3e:54:ab:2b' default_max_wait_for_finish_install = 60 * 60 + default_max_nr_templates_stay = 4 min_max_wait_for_finish_install = 3 * 60 max_max_wait_for_finish_install = 24 * 60 * 60 @@ -81,6 +82,7 @@ class CrTplConfiguration(PpBaseObject): self.network = self.default_network self.mac_address = self.default_mac_address 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.excluded_datastores = [] @@ -154,6 +156,7 @@ class CrTplConfiguration(PpBaseObject): res['default_network'] = self.default_network res['default_mac_address'] = self.default_mac_address res['default_max_wait_for_finish_install'] = self.default_max_wait_for_finish_install + res['default_max_nr_templates_stay'] = self.default_max_nr_templates_stay res['min_max_wait_for_finish_install'] = self.min_max_wait_for_finish_install res['max_max_wait_for_finish_install'] = self.max_max_wait_for_finish_install res['data_size_mb'] = self.data_size_mb @@ -245,6 +248,23 @@ class CrTplConfiguration(PpBaseObject): if key.lower() == 'dc': self.dc = value + if key.lower() == 'max_nr_templates_stay': + v = int(value) + if v < 1: + LOG.error(( + "Value {val} for max_nr_templates_stay is less than {minval}, " + "using {default}.").format( + val=v, minval=1, + default=self.default_max_nr_templates_stay)) + elif v >= 100: + LOG.error(( + "Value {val} for max_nr_templates_stay is greater than {maxval}, " + "using {default}.").format( + val=v, maxval=100, + default=self.default_max_nr_templates_stay)) + else: + self.max_nr_templates_stay = v + if re_excl_ds.search(key): datastores = re_split_ds.split(value.strip()) self.excluded_datastores = datastores @@ -285,13 +305,13 @@ class CrTplConfiguration(PpBaseObject): if key.lower() == 'max_wait_for_finish_install': v = float(value) if v < self.min_max_wait_for_finish_install: - LOG.err(( + LOG.error(( "Value {val} for max_wait_for_finish_install is less than {minval}, " "using {default} seconds.").format(val=v, minval=self.min_max_wait_for_finish_install, default=self.default_max_wait_for_finish_install)) elif v > self.max_max_wait_for_finish_install: - LOG.err(( + LOG.error(( "Value {val} for max_wait_for_finish_install is greater than {maxval}, " "using {default} seconds.").format(val=v, maxval=self.max_max_wait_for_finish_install, -- 2.39.5