|
|
|
@ -16,19 +16,16 @@
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
import re
|
|
|
|
|
from os import path
|
|
|
|
|
from time import sleep
|
|
|
|
|
from calculate.lib.datavars import (Variable, VariableError, FieldValue,
|
|
|
|
|
VariableInterface, HumanReadable,
|
|
|
|
|
ReadonlyVariable, ReadonlyTableVariable)
|
|
|
|
|
import calculate.lib.utils.device as device
|
|
|
|
|
from calculate.lib.utils.device import humanreadableSize
|
|
|
|
|
from calculate.lib.utils import partition
|
|
|
|
|
from calculate.lib.utils.files import (readLinesFile, process, getProgPath)
|
|
|
|
|
from calculate.lib.utils.files import (readLinesFile)
|
|
|
|
|
from calculate.install.fs_manager import FileSystemManager
|
|
|
|
|
from calculate.lib.utils.tools import Sizes, traverse
|
|
|
|
|
from itertools import *
|
|
|
|
|
import operator
|
|
|
|
|
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate, _
|
|
|
|
|
from calculate.lib.variables.system import RootType
|
|
|
|
@ -37,6 +34,10 @@ setLocalTranslate('cl_install3', sys.modules[__name__])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SizeHelper(VariableInterface):
|
|
|
|
|
"""
|
|
|
|
|
Объект помогает переменной преобразовывать размер с суффиксами,
|
|
|
|
|
ведённый пользователями к "числовому" необходимому размеру
|
|
|
|
|
"""
|
|
|
|
|
default_size = Sizes.M
|
|
|
|
|
|
|
|
|
|
def set(self, value):
|
|
|
|
@ -77,62 +78,6 @@ class SchemeOpt(object):
|
|
|
|
|
Calculate = "calculate"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SchemeDevices(object):
|
|
|
|
|
Swap = "swap"
|
|
|
|
|
Root1 = "system1"
|
|
|
|
|
Root2 = "system2"
|
|
|
|
|
UEFI = "uefi"
|
|
|
|
|
Data = "calculate"
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def get_by_opt(cls, opt):
|
|
|
|
|
opt_map = {SchemeOpt.Swap: cls.Swap,
|
|
|
|
|
SchemeOpt.UEFI: cls.UEFI,
|
|
|
|
|
SchemeOpt.Calculate: cls.Data}
|
|
|
|
|
return opt_map.get(opt, opt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AutoPartition(object):
|
|
|
|
|
"""
|
|
|
|
|
Autopartition maker
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def _waitDevice(self, *devices):
|
|
|
|
|
"""
|
|
|
|
|
Ожидание одного из указанных устройств
|
|
|
|
|
"""
|
|
|
|
|
for waittime in (0.1, 0.2, 0.5, 1, 2, 4):
|
|
|
|
|
if any(path.exists(x) for x in devices):
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
sleep(waittime)
|
|
|
|
|
raise AutopartitionError(
|
|
|
|
|
_("Failed to found partition %s after creating the partition table")
|
|
|
|
|
% ",".join(devices))
|
|
|
|
|
|
|
|
|
|
def clearRaid(self, devices, dv):
|
|
|
|
|
"""
|
|
|
|
|
Remove raid from devices
|
|
|
|
|
"""
|
|
|
|
|
# TODO: работает не с теми данными
|
|
|
|
|
mdAdmProg = getProgPath('/sbin/mdadm')
|
|
|
|
|
failed = False
|
|
|
|
|
for disktype, grouped in groupby(
|
|
|
|
|
dv.Select(['os_disk_type', 'os_disk_dev'],
|
|
|
|
|
where='os_disk_parent',
|
|
|
|
|
_in=['/dev/sda', '/dev/sdb'],
|
|
|
|
|
sort="ASC/1"),
|
|
|
|
|
operator.itemgetter(0)):
|
|
|
|
|
if disktype.endswith('-raid'):
|
|
|
|
|
for disk_type, disk_dev in grouped:
|
|
|
|
|
failed |= self.doubleExec(mdAdmProg, '-S', disk_dev)
|
|
|
|
|
if "raidmember" in disktype:
|
|
|
|
|
for disk_type, disk_dev in grouped:
|
|
|
|
|
failed |= self.doubleExec(mdAdmProg,
|
|
|
|
|
'--zero-superblock', disk_dev)
|
|
|
|
|
return not failed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AutopartitionHelper(VariableInterface):
|
|
|
|
|
"""
|
|
|
|
|
Helper for autopartiton device and mount point creating
|
|
|
|
@ -479,8 +424,7 @@ class VariableClAutopartitionBriefSet(VariableClAutopartitionSet):
|
|
|
|
|
return _("This option not used for Flash install")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClAutopartitionScheme(AutopartitionHelper, AutoPartition,
|
|
|
|
|
Variable):
|
|
|
|
|
class VariableClAutopartitionScheme(AutopartitionHelper, Variable):
|
|
|
|
|
"""
|
|
|
|
|
Autopartition scheme
|
|
|
|
|
"""
|
|
|
|
|