Исправления для соответствия с новым API.

master3.3
Mike khiretskiy 11 years ago
parent 0f05431628
commit 22a31cabbd

@ -28,7 +28,7 @@ from shutil import copy2
from calculate.core.server.func import safetyWrapper
from calculate.lib.utils.files import (runOsCommand,pathJoin,
isMount,process,listDirectory,STDOUT,
checkUtils,Find,readFile)
checkUtils,readFile,find,copyWithPath)
from calculate.lib.utils.common import (appendProgramToEnvFile,
removeProgramToEnvFile, getTupleVersion,
cmpVersion,getUserPassword,
@ -72,7 +72,6 @@ class Install:
def __init__(self):
self.clVars = None
self.clTempl = None
# refresh information about LVM
refreshLVM()
# refresh information about device in udevadm info
@ -107,52 +106,6 @@ class Install:
self.installLegacyGrubBootloader(targetDistr)
return True
def closeClTemplate(self,error=None):
if self.clTempl:
if self.clTempl.cltObj:
self.clTempl.cltObj.closeFiles()
self.clTempl.closeFiles()
self.clTempl = None
def applyTemplates(self,target=None,useClt=None,cltFilter=False,root=None):
"""
Применить шаблоны. Если указан target, то директория, где развернут
образ устанавливается как cl_chroot_path. Если указан root, то как
cl_root_path
"""
if target is None:
chroot = '/'
grubdir = '/'
else:
chroot = target.getDirectory()
grubdir = target.getBootDirectory()[:-4]
if root is None:
root = '/'
else:
root = root.getDirectory()
cltFilter=True if cltFilter in (True,"on") else False,
self.clVars.Set("cl_chroot_path",chroot, True)
self.clVars.Set("cl_chroot_grub",grubdir, True)
self.clVars.Set("cl_root_path",root, True)
# определение каталогов содержащих шаблоны
dirs_list, files_list = ([],[])
useClt = useClt in ("on",True)
self.clTempl = ProgressTemplate(self.setProgress,self.clVars,
cltObj=useClt,
cltFilter=cltFilter,
printSUCCESS=self.printSUCCESS,
printWARNING=self.printWARNING,
askConfirm=self.askConfirm,
dispatchConf=self.dispatchConf,
printERROR=self.printERROR)
try:
dirsFiles = self.clTempl.applyTemplates()
if self.clTempl.getError():
raise InstallError(self.clTempl.getError())
finally:
self.closeClTemplate()
return True
def setActivePartition(self,partition):
"""
Установка активного раздела для dos и gpt таблицы разделов
@ -478,10 +431,12 @@ class Install:
Скопировать clt шаблоны из 'cltpath' в 'target' дистрибутив из
'source' дистрибутива
"""
f = Find()
f.search(source.getDirectory(),'/etc',
f.filter(lambda x:x.endswith('.clt'),
f.copypath(target.getDirectory())))
targetdir = target.getDirectory()
sourcedir = source.getDirectory()
for f in filter(lambda x:x.endswith('.clt'),
chain(*map(lambda x:find(pathJoin(sourcedir,x),filetype="f"),
cltpath))):
copyWithPath(f,targetdir,prefix=sourcedir)
return True
def copyOther(self,source,target):
@ -490,10 +445,12 @@ class Install:
"""
fileMask = re.compile("(/etc/ssh/ssh_host_.*|"
"/root/.ssh/(id_.*|known_hosts))")
f = Find()
f.search(source.getDirectory(),['/etc','/root/.ssh'],
f.filter(fileMask.search,
f.copypath(target.getDirectory())))
targetdir = target.getDirectory()
sourcedir = source.getDirectory()
for f in filter(fileMask.search,
chain(*map(lambda x:find(pathJoin(sourcedir,x),filetype="f"),
["/etc","/root/.ssh"]))):
copyWithPath(f,targetdir,prefix=sourcedir)
return True
@ -564,3 +521,6 @@ class Install:
"""
distr.close()
return True
def mytest(self):
return False

@ -15,7 +15,7 @@
# limitations under the License.
import sys
from calculate.core.server.func import Action
from calculate.core.server.func import Action,Tasks
from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate
from calculate.lib.utils.files import FilesError
from calculate.install.install import (MigrationError, TemplatesError,
@ -61,30 +61,28 @@ class ClInstallAction(Action):
'condition':lambda dv:dv.Get('os_install_root_type') != 'flash' and \
dv.Get('os_install_pxe') == 'off'},
# копирование clt шаблонов
{'name':'copy_clt',
{'name':'hdd:copy_clt',
'message':__("Copying clt templates to the new system"),
'method':'Install.copyClt(cl_source,cl_target,cl_template_clt_path)',
'depend':(Action.has('hdd'),Action.success())},
'method':'Install.copyClt(cl_source,cl_target,cl_template_clt_path)'
},
# копирование прочих файлов
{'name':'copy_other',
{'name':'hdd:copy_other',
'message':__("Copying other settings to the new system"),
'method':'Install.copyOther(cl_source,cl_target)',
'condition':lambda dv:dv.Get('os_root_type') != "livecd",
'depend':(Action.has('hdd'),Action.success())},
},
# перемонтирование ntfs для определения windows
{'name':'remount_ntfs',
{'name':'hdd:remount_ntfs',
'method':'Install.remountNTFS()',
'essential':False,
'depend':(Action.has('hdd'),Action.success())
},
},
# наложение шаблонов при установке на жесткий диск
{'name':'apply_templates',
{'name':'hdd:apply_templates',
'message':__("Updating the configuration"),
# наложить шаблоны в установленный дистрибутив, включая clt шаблоны
# без использования фильтров по clt шаблонам
'method':'Install.applyTemplates(cl_target,True,False,None)',
'depend':(Action.has('hdd'),Action.success()),
},
},
# наложение шаблонов при PXE установке
{'name':'apply_templates_pxe',
'message':__("Configuring PXE install"),
@ -102,17 +100,15 @@ class ClInstallAction(Action):
'condition':lambda dv:dv.Get('os_install_root_type') == "flash"
},
# подключить точки монтирования bind
{'name':'mount_bind',
{'name':'hdd:mount_bind',
'message':__("Post-install configuration"),
'method':"Install.mountBind(cl_target)",
'depend':(Action.has('hdd'),Action.success())
},
# перенос пользователей
{'name':'user_migrate',
{'name':'hdd:user_migrate',
'message':__("Migrating users"),
'method':'Install.userMigrate(cl_target,cl_migrate_data,'
'cl_migrate_root_pwd)',
'depend':(Action.has('hdd'),Action.success())
},
# подготовка загрузчика
{'name':'prepare_boot',
@ -126,24 +122,24 @@ class ClInstallAction(Action):
'message':__("Letting go the source distribution"),
'method':'Install.umount(cl_image)',
'condition':lambda dv:dv.Get('cl_image') and dv.Get('cl_image').childs,
'depend': Action.has("unpack")},
'depend': Tasks.has("unpack")},
# отключение установленного дистрибутива
{'name':'umount_target',
'message':__("Unmounting the target system volume"),
'method':'Install.umount(cl_target)',
'condition':lambda dv:dv.Get('cl_target') and dv.Get('cl_target').childs,
'depend': Action.has("unpack")},
'depend': Tasks.has("unpack")},
# вывести сообщение в случае успеха
{'name':'success',
'message':__("System successfully installed!")},
# вывести сообщение в случае ошибки
{'name':'failed',
'message':__("Failed to install the system!"),
'depend': (Action.failed(),Action.hasnot("interrupt"))},
'depend': (Tasks.failed() & Tasks.hasnot("interrupt"))},
# вывести сообщение о том, что установка прервана пользователем
{'name':'intmessage',
'message':__("Installation manually interrupted"),
'depend': (Action.has("interrupt"))},
'depend': Tasks.has("interrupt")},
# подтверждение на перезагрузку
{'name':'ask_reboot',
'message':__("Would you like to reboot your computer "
@ -154,5 +150,6 @@ class ClInstallAction(Action):
{'name':'reboot',
'message':__("System reboot"),
'command':'/sbin/reboot',
'depend':Action.result("ask_reboot",eq='yes')}
]
'depend':Tasks.result("ask_reboot",eq='yes')
}
]

@ -15,7 +15,7 @@
# limitations under the License.
import sys
from calculate.core.server.func import Action
from calculate.core.server.func import Action,Tasks
from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate
from calculate.lib.utils.files import FilesError
from calculate.install.install import (MigrationError, TemplatesError,

@ -613,7 +613,8 @@ class VariableClAutopartitionDiskData(ReadonlyTableVariable):
'cl_autopartition_disk_mount',
'cl_autopartition_disk_format',
'cl_autopartition_disk_size',
'cl_autopartition_disk_part']
'cl_autopartition_disk_part',
'cl_autopartition_disk_scheme']
class VariableClAutopartitionBiosGrubSet(ReadonlyVariable):
"""
@ -715,6 +716,27 @@ class VariableClAutopartitionDiskDev(ReadonlyVariable,AutopartitionHelper):
return res
return []
class VariableClAutopartitionDiskScheme(ReadonlyVariable,AutopartitionHelper):
"""
Назначение раздела относительно схемы авторазметки
"""
type = "list"
def generateScheme(self,scheme):
"""
Generate mount points for automount scheme
"""
for line in self.deviceOpts(scheme):
yield line
def get(self):
if self.Get('cl_autopartition_set') == "on":
scheme = self.getAutopartitionScheme()
device = self.Get('cl_autopartition_device')
if device:
return list(self.generateScheme(scheme))
return []
class VariableClAutopartitionDiskMount(ReadonlyVariable,AutopartitionHelper):
"""
Autopartition mount points

@ -292,6 +292,8 @@ class VariableClImageFilename(Variable,DistroRepository):
def check(self,isoimage):
"""Set image file"""
if self.Get('cl_action') == 'system' and not isoimage:
raise VariableError(_("Need to choice distribute image"))
imageData = Distributive().getInfo(isoimage)
if not("os_linux_shortname" in imageData and \
imageData.get('os_linux_build','') and \

@ -392,8 +392,6 @@ class VariableOsInstallDevFrom(Variable):
"""
Root device of previous installed os
"""
value = ""
def set(self,value):
"""
If device in calculate3.env dev_from not exists set ''
@ -405,6 +403,13 @@ class VariableOsInstallDevFrom(Variable):
else:
return ""
def get(self):
if (self.Get('cl_autopartition_set') == 'on' and
"root" in self.Get('cl_autopartition_scheme')):
return self.Select('cl_autopartition_disk_dev',
where='cl_autopartition_disk_scheme',eq='root',limit=1)
return ""
class VariableClInstallAutoupdateSet(Variable):
"""
Autoupdate for install or configure system

@ -18,6 +18,7 @@ import sys, time, os
from calculate.lib.datavars import VariableError,DataVarsError,DataVars
from calculate.install.install import InstallError
from calculate.install.distr import DistributiveError
import install
from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate
@ -53,7 +54,8 @@ class Wsdl(WsdlBase):
'action':ClInstallAction,
# объект переменных
'datavars':"install",
'native_error':(VariableError,DataVarsError, install.InstallError),
'native_error':(VariableError,DistributiveError,
DataVarsError,install.InstallError),
# значения по умолчанию для переменных этого метода
'setvars':{'cl_action!':'system','cl_dispatch_conf':'usenew'},
# описание груп (список лямбда функций)
@ -112,8 +114,10 @@ class Wsdl(WsdlBase):
'logic':{'Install':install.Install},
'action':ClInstallAction,
'datavars':"install",
'native_error':(VariableError,DataVarsError,install.InstallError),
'native_error':(VariableError,DistributiveError,
DataVarsError,install.InstallError),
'setvars':{'cl_action!':'system','cl_install_type':'flash',
'cl_protect_use_set!':'off',
'cl_dispatch_conf':'usenew'},
'groups':[
lambda group:group(_("Flash install"),
@ -132,8 +136,10 @@ class Wsdl(WsdlBase):
'logic':{'Install':install.Install},
'action':ClInstallAction,
'datavars':"install",
'native_error':(VariableError,DataVarsError,install.InstallError),
'native_error':(VariableError,DistributiveError,
DataVarsError,install.InstallError),
'setvars':{'cl_action!':'system','os_install_pxe!':'on',
'cl_protect_use_set!':'off',
'cl_dispatch_conf':'usenew'},
'groups':[
lambda group:group(_("PXE install"),

Loading…
Cancel
Save