from .obj import PpBaseObject
-__version__ = '0.3.1'
+__version__ = '0.4.1'
LOG = logging.getLogger(__name__)
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__(
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'
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):
"""
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
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
# =============================================================================