]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding configuration of size of data store volume
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 22 Mar 2018 15:41:34 +0000 (16:41 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 22 Mar 2018 15:41:34 +0000 (16:41 +0100)
etc/create-vmware-template.ini.default
lib/cr_vmware_tpl/config.py

index 2cac709d2f705902b34ca6c31443af4fdfd7db9f..9975532a8709840c2faec85a192f0320f8cf3596 100644 (file)
@@ -18,5 +18,6 @@
 
 ;name = oracle-linux-7.4-template
 
+;data_size_gb = 30
 
 ; vim: filetype=dosini
index 0b9f83f6466fb4ed8404fd6ca8a4f3934f29b12c..22d71d99faf35728181e5936ae0117fbf3e432f3 100644 (file)
@@ -26,7 +26,7 @@ from .errors import FunctionNotImplementedError, PpError
 
 from .obj import PpBaseObject
 
-__version__ = '0.3.1'
+__version__ = '0.4.1'
 LOG = logging.getLogger(__name__)
 
 
@@ -52,6 +52,7 @@ class CrTplConfiguration(PpBaseObject):
     default_folder = 'templates'
     default_template_vm = 'template.pixelpark.com'
     default_template_name = 'oracle-linux-7.4-template'
+    default_data_size_gb = 30.0
 
     # -------------------------------------------------------------------------
     def __init__(
@@ -66,6 +67,7 @@ class CrTplConfiguration(PpBaseObject):
         self.folder = self.default_folder
         self.template_vm = self.default_template_vm
         self.template_name = self.default_template_name
+        self.data_size_gb = self.default_data_size_gb
 
         self.encoding = 'utf-8'
 
@@ -87,6 +89,24 @@ class CrTplConfiguration(PpBaseObject):
         if initialized:
             self.initialized = True
 
+    # -------------------------------------------------------------------------
+    @property
+    def data_size_mb(self):
+        """Size of template volume in MiB."""
+        return int(self.data_size_gb) * 1024
+
+    # -------------------------------------------------------------------------
+    @property
+    def data_size_kb(self):
+        """Size of template volume in KiB."""
+        return int(self.data_size_gb) * 1024 * 1024
+
+    # -------------------------------------------------------------------------
+    @property
+    def data_size(self):
+        """Size of template volume in Bytes."""
+        return int(self.data_size_gb) * 1024 * 1024 * 1024
+
     # -------------------------------------------------------------------------
     def as_dict(self, short=True):
         """
@@ -107,6 +127,10 @@ class CrTplConfiguration(PpBaseObject):
         res['default_folder'] = self.default_folder
         res['default_template_vm'] = self.default_template_vm
         res['default_template_name'] = self.default_template_name
+        res['default_data_size_gb'] = self.default_data_size_gb
+        res['data_size_mb'] = self.data_size_mb
+        res['data_size_kb'] = self.data_size_kb
+        res['data_size'] = self.data_size
 
         return res
 
@@ -203,6 +227,14 @@ class CrTplConfiguration(PpBaseObject):
                         continue
                     if key.lower() == 'name':
                         self.template_name = value
+                    if key.lower() == 'data_size_gb':
+                        self.data_size_gb = float(value)
+                    if key.lower() == 'data_size_mb':
+                        self.data_size_gb = float(value) / 1024.0
+                    if key.lower() == 'data_size_kb':
+                        self.data_size_gb = float(value) / 1024.0 / 1024.0
+                    if key.lower() == 'data_size':
+                        self.data_size_gb = float(value) / 1024.0 / 1024.0 / 1024.0
 
 
 # =============================================================================