]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding config parameter max_nr_templates_stay
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 13 Apr 2018 11:32:31 +0000 (13:32 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 13 Apr 2018 11:32:31 +0000 (13:32 +0200)
lib/cr_vmware_tpl/config.py

index 35619ba6359d8bde6a6b795cfecca3f6a267aa71..fed07517c3f7a5940e830f5314b9c292049e6efc 100644 (file)
@@ -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,