|
|
|
@ -20,19 +20,21 @@ from os import path
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
from calculate.install.distr import DistributiveError, IsoDistributive
|
|
|
|
|
from calculate.install.variables.kernel import KernelConfig
|
|
|
|
|
from calculate.install.variables.kernel import KernelConfig, VariableInterface
|
|
|
|
|
from calculate.lib.utils.dracut import Dracut
|
|
|
|
|
from calculate.lib.utils.grub import GrubCommand
|
|
|
|
|
from calculate.lib.utils.portage import getSquashList
|
|
|
|
|
from calculate.lib.utils.portage import getSquashList, isPkgInstalled
|
|
|
|
|
from calculate.lib.variables.system import RootType
|
|
|
|
|
from .action import Actions
|
|
|
|
|
import linux as vars_linux
|
|
|
|
|
import datetime
|
|
|
|
|
from calculate.install import distr
|
|
|
|
|
from calculate.lib.utils.device import getUdevDeviceInfo, humanreadableSize
|
|
|
|
|
from calculate.lib.utils.files import (isMount, process, typeFile,
|
|
|
|
|
listDirectory,
|
|
|
|
|
pathJoin, readFile, check_rw)
|
|
|
|
|
from calculate.lib.utils.kernel import InitrdFile
|
|
|
|
|
from calculate.lib.utils.text import _u8
|
|
|
|
|
from calculate.lib.utils.tools import max_default
|
|
|
|
|
from calculate.lib.utils.git import Git
|
|
|
|
|
from ..build_storage import BuildStorage, Build
|
|
|
|
@ -51,7 +53,6 @@ setLocalTranslate('cl_builder3', sys.modules[__name__])
|
|
|
|
|
|
|
|
|
|
__ = getLazyLocalTranslate(_)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_action(*available_action, **action_kwargs):
|
|
|
|
|
def decorator(func):
|
|
|
|
|
@wraps(func)
|
|
|
|
@ -66,6 +67,56 @@ def is_action(*available_action, **action_kwargs):
|
|
|
|
|
return decorator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class IsoTypeHelper(VariableInterface):
|
|
|
|
|
"""
|
|
|
|
|
Вспомогательный объект для переменных контейнера
|
|
|
|
|
"""
|
|
|
|
|
def uncompatible(self):
|
|
|
|
|
if self.GetBool("cl_builder_container_set"):
|
|
|
|
|
return _("This option is not compatible with container image")
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContainerHelper(VariableInterface):
|
|
|
|
|
"""
|
|
|
|
|
Вспомогательный объект для переменных контейнера
|
|
|
|
|
"""
|
|
|
|
|
def uncompatible(self):
|
|
|
|
|
if not self.GetBool("cl_builder_container_set"):
|
|
|
|
|
return _("This option is not compatible with ISO image")
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
class ImagePathHelper(VariableInterface):
|
|
|
|
|
"""
|
|
|
|
|
Создание временного каталога для подготовки образа
|
|
|
|
|
"""
|
|
|
|
|
@property
|
|
|
|
|
def base_dn(self):
|
|
|
|
|
return self.Get('cl_builder_iso_base_path')
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def build_id(self):
|
|
|
|
|
return self.Get('cl_builder_id')
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def build_id_path(self):
|
|
|
|
|
return self.Get('cl_builder_id_path')
|
|
|
|
|
|
|
|
|
|
prefix = ""
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.build_id:
|
|
|
|
|
dn = "%s%s" % (self.prefix, self.build_id_path)
|
|
|
|
|
directory = path.join(self.base_dn, dn)
|
|
|
|
|
new_dn = directory
|
|
|
|
|
for i in range(0, 9999):
|
|
|
|
|
if not path.exists(new_dn):
|
|
|
|
|
return new_dn
|
|
|
|
|
else:
|
|
|
|
|
new_dn = "%s.%04d" % (directory, i)
|
|
|
|
|
return new_dn
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderStorage(ReadonlyVariable):
|
|
|
|
|
type = "object"
|
|
|
|
|
|
|
|
|
@ -120,7 +171,7 @@ class VariableClBuilderVideoDriverPath(Variable):
|
|
|
|
|
'var/cache/calculate/video_drivers')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderVideodrvSet(Variable):
|
|
|
|
|
class VariableClBuilderVideodrvSet(IsoTypeHelper, Variable):
|
|
|
|
|
"""
|
|
|
|
|
Нужно ли скачивать пакеты в дистрибутив для установки проприетарных
|
|
|
|
|
драйверов во время загрузки
|
|
|
|
@ -340,7 +391,7 @@ class VariableClBuilderDiskSize(DiskFreeHelper):
|
|
|
|
|
return "0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderPrepareFreeSize(DiskFreeHelper):
|
|
|
|
|
class VariableClBuilderPrepareFreeSize(IsoTypeHelper, DiskFreeHelper):
|
|
|
|
|
"""
|
|
|
|
|
Свободное место используемое для подготовки образа
|
|
|
|
|
"""
|
|
|
|
@ -354,7 +405,7 @@ class VariableClBuilderPrepareFreeSize(DiskFreeHelper):
|
|
|
|
|
return str(self.get_free_for(dn))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderImageFreeSize(DiskFreeHelper):
|
|
|
|
|
class VariableClBuilderImageFreeSize(IsoTypeHelper, DiskFreeHelper):
|
|
|
|
|
"""
|
|
|
|
|
Свободное место на диске, где создается iso образ
|
|
|
|
|
"""
|
|
|
|
@ -368,6 +419,20 @@ class VariableClBuilderImageFreeSize(DiskFreeHelper):
|
|
|
|
|
return str(self.get_free_for(dn))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerFreeSize(ContainerHelper, DiskFreeHelper):
|
|
|
|
|
"""
|
|
|
|
|
Свободное место на диске, где создается iso образ
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Free disk space for container image")
|
|
|
|
|
|
|
|
|
|
@is_action(Actions.Image)
|
|
|
|
|
def get(self):
|
|
|
|
|
dn = self.Get('cl_builder_image_filename')
|
|
|
|
|
return str(self.get_free_for(dn))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderLayeredSet(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Сборка будет выполняться в слое
|
|
|
|
@ -551,7 +616,7 @@ class VariableClBuilderNewId(BaseBuildId):
|
|
|
|
|
if value and not re.match("^[A-Za-z][A-Za-z0-9/:_+-]+$", value):
|
|
|
|
|
raise VariableError(_("Wrong symbols in the build ID"))
|
|
|
|
|
if value in self.Get('cl_builder_storage'):
|
|
|
|
|
raise VariableError(_("Build %s already exists") % value)
|
|
|
|
|
raise VariableError(_("Build %s already exists") % _u8(value))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderPreparedId(BaseBuildId):
|
|
|
|
@ -586,6 +651,16 @@ class VariableClBuilderPreparedId(BaseBuildId):
|
|
|
|
|
else:
|
|
|
|
|
yield (x, x)
|
|
|
|
|
|
|
|
|
|
def _is_iso_compatible(self):
|
|
|
|
|
prefix = self.Get('cl_builder_path')
|
|
|
|
|
if len(self.Get('cl_builder_kernel_config')):
|
|
|
|
|
for pn in ('sys-kernel/calculate-sources', 'sys-kernel/dracut',
|
|
|
|
|
'media-gfx/gfxboot-themes-calculate', 'sys-boot/grub'):
|
|
|
|
|
if not isPkgInstalled(pn, prefix=prefix):
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
|
if not value:
|
|
|
|
|
raise VariableError(_("Please select the build ID"))
|
|
|
|
@ -597,6 +672,20 @@ class VariableClBuilderPreparedId(BaseBuildId):
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Build %s is broken, try to restore build") % value)
|
|
|
|
|
|
|
|
|
|
image_type = self.Get('cl_builder_image_type')
|
|
|
|
|
if image_type == "iso":
|
|
|
|
|
if not self._is_iso_compatible():
|
|
|
|
|
prefix = self.Get('cl_builder_path')
|
|
|
|
|
for pn in ('sys-kernel/calculate-sources', 'sys-kernel/dracut',
|
|
|
|
|
'media-gfx/gfxboot-themes-calculate',
|
|
|
|
|
'sys-boot/grub'):
|
|
|
|
|
if not isPkgInstalled(pn, prefix=prefix):
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Build without %s can be container only") % pn)
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Build without kernel can be container only"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderBrokenId(BaseBuildId):
|
|
|
|
|
"""
|
|
|
|
@ -745,13 +834,28 @@ class VariableClBuilderImagePath(Variable):
|
|
|
|
|
value = '/var/calculate/linux'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerPath(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Путь по умолчанию для образов LXC
|
|
|
|
|
"""
|
|
|
|
|
value = '/var/calculate/container'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderConainterIndexPath(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Путь по умолчанию для создания индекса контейнеров
|
|
|
|
|
"""
|
|
|
|
|
value = "{cl_builder_container_path}/meta/1.0/index-system"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderImageFilename(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Название iso образа
|
|
|
|
|
"""
|
|
|
|
|
opt = ["--iso"]
|
|
|
|
|
opt = ["--image"]
|
|
|
|
|
metavalue = "IMAGE"
|
|
|
|
|
untrusted = True
|
|
|
|
|
check_after = "cl_builder_container_set"
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Image path")
|
|
|
|
@ -761,28 +865,31 @@ class VariableClBuilderImageFilename(Variable):
|
|
|
|
|
if self.Get('cl_builder_id'):
|
|
|
|
|
if not value:
|
|
|
|
|
raise VariableError(_("You must specify image filename"))
|
|
|
|
|
if not value.endswith(".iso"):
|
|
|
|
|
raise VariableError(_("You must specify image filename with "
|
|
|
|
|
"'iso' suffix"))
|
|
|
|
|
if path.isdir(value):
|
|
|
|
|
raise VariableError(_("The image shouldn't be a directory"))
|
|
|
|
|
for line in process("/bin/losetup", "-j", value):
|
|
|
|
|
lodev, op, line = line.partition(":")
|
|
|
|
|
if lodev:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Image %s is already used") % value)
|
|
|
|
|
if not self.GetBool("cl_builder_container_set"):
|
|
|
|
|
if not value.endswith(".iso"):
|
|
|
|
|
raise VariableError(_("You must specify image filename with "
|
|
|
|
|
"'iso' suffix"))
|
|
|
|
|
if path.isdir(value):
|
|
|
|
|
raise VariableError(_("The image shouldn't be a directory"))
|
|
|
|
|
for line in process("/bin/losetup", "-j", value):
|
|
|
|
|
lodev, op, line = line.partition(":")
|
|
|
|
|
if lodev:
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Image %s is already used") % value)
|
|
|
|
|
elif path.exists(value) and not path.isdir(value):
|
|
|
|
|
raise VariableError(_("The image should be a directory"))
|
|
|
|
|
|
|
|
|
|
def _isoname(self, dn, rewrite=False, addon_dn=None):
|
|
|
|
|
def _isoname(self, dn, rewrite=False, addon_dn=None, suffix=".iso"):
|
|
|
|
|
shortname = self.Get('os_builder_linux_shortname').lower()
|
|
|
|
|
buildnumber = self.Get('os_builder_linux_build')
|
|
|
|
|
arch = self.Get('os_builder_arch_machine')
|
|
|
|
|
for i in range(0, 999):
|
|
|
|
|
if i:
|
|
|
|
|
isoname = "%s-%s-%d-%s.iso" % (shortname, buildnumber,
|
|
|
|
|
i, arch)
|
|
|
|
|
isoname = "%s-%s-%d-%s%s" % (shortname, buildnumber,
|
|
|
|
|
i, arch, suffix)
|
|
|
|
|
else:
|
|
|
|
|
isoname = "%s-%s-%s.iso" % (shortname, buildnumber,
|
|
|
|
|
arch)
|
|
|
|
|
isoname = "%s-%s-%s%s" % (shortname, buildnumber,
|
|
|
|
|
arch, suffix)
|
|
|
|
|
fullname = ""
|
|
|
|
|
for i_dn in filter(None, (addon_dn, dn)):
|
|
|
|
|
fullname = path.join(i_dn, isoname)
|
|
|
|
@ -793,7 +900,10 @@ class VariableClBuilderImageFilename(Variable):
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
build_id = self.Get('cl_builder_id')
|
|
|
|
|
base_dn = self.Get('cl_builder_image_path')
|
|
|
|
|
if self.GetBool('cl_builder_container_set'):
|
|
|
|
|
base_dn = self.Get('cl_builder_container_path')
|
|
|
|
|
else:
|
|
|
|
|
base_dn = self.Get('cl_builder_image_path')
|
|
|
|
|
|
|
|
|
|
if build_id:
|
|
|
|
|
root_type_ext = self.Get('os_root_type_ext')
|
|
|
|
@ -807,6 +917,8 @@ class VariableClBuilderImageFilename(Variable):
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Failed to determine the isoscan path"))
|
|
|
|
|
return self._isoname(base_dn, rewrite=False)
|
|
|
|
|
elif self.GetBool('cl_builder_container_set'):
|
|
|
|
|
return self._isoname(base_dn, rewrite=False, suffix='')
|
|
|
|
|
else:
|
|
|
|
|
return self._isoname(base_dn, rewrite=False)
|
|
|
|
|
return ""
|
|
|
|
@ -827,26 +939,11 @@ class VariableClBuilderIsoBasePath(Variable):
|
|
|
|
|
return self.default_value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderIsoPath(ReadonlyVariable):
|
|
|
|
|
class VariableClBuilderIsoPath(ImagePathHelper, ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Путь, где будут подготавливаться данные, которые будут запакованы в iso
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
base_dn = self.Get('cl_builder_iso_base_path')
|
|
|
|
|
build_id = self.Get('cl_builder_id')
|
|
|
|
|
build_id_path = self.Get('cl_builder_id_path')
|
|
|
|
|
if build_id:
|
|
|
|
|
dn = "iso-%s" % build_id_path
|
|
|
|
|
directory = path.join(base_dn, dn)
|
|
|
|
|
new_dn = directory
|
|
|
|
|
for i in range(0, 9999):
|
|
|
|
|
if not path.exists(new_dn):
|
|
|
|
|
return new_dn
|
|
|
|
|
else:
|
|
|
|
|
new_dn = "%s.%04d" % (directory, i)
|
|
|
|
|
return new_dn
|
|
|
|
|
return ""
|
|
|
|
|
prefix = "iso-"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderSquashPath(ReadonlyVariable):
|
|
|
|
@ -871,12 +968,19 @@ class VariableClBuilderImage(ReadonlyVariable):
|
|
|
|
|
bdn = self.Get('cl_builder_iso_path')
|
|
|
|
|
exclude_list = self.Get('cl_builder_squash_exclude')
|
|
|
|
|
include_list = self.Get('cl_builder_video_ebuilds')
|
|
|
|
|
iso = distr.IsoDistributive(image_name, bdirectory=bdn,
|
|
|
|
|
vol_id=self.Get('cl_builder_iso_label'),
|
|
|
|
|
exclude=exclude_list,
|
|
|
|
|
include=include_list,
|
|
|
|
|
compress=self.Get('cl_builder_compress'))
|
|
|
|
|
return iso
|
|
|
|
|
if self.GetBool('cl_builder_container_set'):
|
|
|
|
|
image = distr.ContainerDistributive(
|
|
|
|
|
image_name,
|
|
|
|
|
exclude=exclude_list,
|
|
|
|
|
include=include_list)
|
|
|
|
|
else:
|
|
|
|
|
image = distr.IsoDistributive(
|
|
|
|
|
image_name, bdirectory=bdn,
|
|
|
|
|
vol_id=self.Get('cl_builder_iso_label'),
|
|
|
|
|
exclude=exclude_list,
|
|
|
|
|
include=include_list,
|
|
|
|
|
compress=self.Get('cl_builder_compress'))
|
|
|
|
|
return image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderLiveSet(Variable):
|
|
|
|
@ -1211,7 +1315,7 @@ class VariableClBuilderBranchName(Variable):
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderCompress(Variable):
|
|
|
|
|
class VariableClBuilderCompress(IsoTypeHelper, Variable):
|
|
|
|
|
"""
|
|
|
|
|
Тип сжатия образа squash
|
|
|
|
|
"""
|
|
|
|
@ -1219,7 +1323,7 @@ class VariableClBuilderCompress(Variable):
|
|
|
|
|
opt = ["-c", "--compress"]
|
|
|
|
|
metavalue = "COMPRESS"
|
|
|
|
|
untrusted = True
|
|
|
|
|
check_after = ["cl_builder_id"]
|
|
|
|
|
check_after = ["cl_builder_id", "cl_builder_container_set"]
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Compressor")
|
|
|
|
@ -1244,28 +1348,42 @@ class VariableClBuilderCompress(Variable):
|
|
|
|
|
|
|
|
|
|
weight = {'xz': 2, 'gzip': 1}
|
|
|
|
|
|
|
|
|
|
return list(sorted(generator(),
|
|
|
|
|
key=lambda x: (-weight.get(x, 0), x)))
|
|
|
|
|
ret = list(sorted(generator(),
|
|
|
|
|
key=lambda x: (-weight.get(x, 0), x)))
|
|
|
|
|
if not ret:
|
|
|
|
|
return [""]
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.GetBool("cl_builder_container_set"):
|
|
|
|
|
return "xz"
|
|
|
|
|
values = self.choice()
|
|
|
|
|
if values:
|
|
|
|
|
return values[0]
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderIsohybridSet(Variable):
|
|
|
|
|
class VariableClBuilderIsohybridSet(IsoTypeHelper, Variable):
|
|
|
|
|
"""
|
|
|
|
|
Преобразовать полученный iso образ в гибридный
|
|
|
|
|
"""
|
|
|
|
|
type = "bool"
|
|
|
|
|
opt = ["--isohybrid"]
|
|
|
|
|
value = "on"
|
|
|
|
|
check_after = ["cl_builder_container_set"]
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.help = _("create the ISO image with isohybrid")
|
|
|
|
|
self.label = _("ISO hybrid feature")
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
|
if self.GetBool("cl_builder_container_set") and value != "off":
|
|
|
|
|
raise VariableError(_("Iso hybrid is uncompatible with container"))
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.GetBool("cl_builder_container_set"):
|
|
|
|
|
return "off"
|
|
|
|
|
return "on"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderKeepTreeSet(Variable):
|
|
|
|
|
"""
|
|
|
|
@ -1713,3 +1831,105 @@ class VariableClBuilderUpdateThemesSet(Variable):
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Update themes")
|
|
|
|
|
self.help = _("update themes")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderImageType(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Тип собираемого образа
|
|
|
|
|
"""
|
|
|
|
|
type = "choice"
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Image type")
|
|
|
|
|
self.help = _("set image type")
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
return (("container", _("Container")),
|
|
|
|
|
("iso", _("ISO")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerSet(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Запаковать образ как LXC контейнер
|
|
|
|
|
"""
|
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.Get('cl_builder_image_type') == 'container':
|
|
|
|
|
return 'on'
|
|
|
|
|
return 'off'
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerDist(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Название операционной системы
|
|
|
|
|
"""
|
|
|
|
|
value = "calculate"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerRelease(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Версия ОС контейнера
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return self.Get('os_builder_linux_ver')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerArch(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Архитектура ОС в контейнере
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return self.Get('os_builder_arch_machine_gentoo')
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerVariant(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Variant of image
|
|
|
|
|
"""
|
|
|
|
|
value = "default"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerExpiryTimestamp(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Expire date
|
|
|
|
|
"""
|
|
|
|
|
month = 60 * 60 * 24 * 30
|
|
|
|
|
type = "int"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return str(int(self.Get('cl_builder_container_create_timestamp')) +
|
|
|
|
|
self.month)
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerCreateTimestamp(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Expire date
|
|
|
|
|
"""
|
|
|
|
|
type = "int"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return datetime.datetime.now().strftime("%s")
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerDate(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Creation date of image
|
|
|
|
|
"""
|
|
|
|
|
def get(self):
|
|
|
|
|
ts = int(self.Get('cl_builder_container_create_timestamp'))
|
|
|
|
|
return datetime.datetime.fromtimestamp(ts).strftime("%Y%m%d_%H:%M")
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerBasePath(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Базовый путь для подготовки архивов meta.tar.xz lxd.tar.xz
|
|
|
|
|
"""
|
|
|
|
|
value = "/var/calculate/tmp"
|
|
|
|
|
|
|
|
|
|
class VariableClBuilderContainerDataPath(ImagePathHelper, Variable):
|
|
|
|
|
"""
|
|
|
|
|
Путь где будут подготавливаться данные для контейнера
|
|
|
|
|
"""
|
|
|
|
|
@property
|
|
|
|
|
def base_dn(self):
|
|
|
|
|
return self.Get('cl_builder_container_base_path')
|
|
|
|
|
|
|
|
|
|
prefix = "lxc-"
|
|
|
|
|