Update for new vars.

master3.3
Mike Hiretsky 12 years ago
parent 7ff04284a1
commit 84d378dda1

@ -34,40 +34,34 @@ import traceback
class InstallInfo(ClassSerializer):
"""Parameters for method install"""
os_location_data = Array(Array(String))
os_install_disk_single = String
os_install_mbr = Array(String)
os_install_root_type = String
cl_uuid_set = Boolean
cl_image_filename = String
cl_image_linux_shortname = String
cl_image_arch_machine = String
cl_image_linux_ver = String
cl_image_linux_build = String
cl_image_filename = String
os_install_disk_single = String
os_location_data = Array(Array(String))
os_install_mbr = Array(String)
os_install_root_type = String
os_install_scratch = Boolean
cl_uuid_set = Boolean
os_install_kernel_scheduler = String
os_install_locale_lang = String
os_install_clock_timezone = String
cl_migrate_data = Array(Array(String))
cl_autologin = String
#user = Array(String)
#autologin = String
#password = Array(String)
os_install_net_fqdn = String
os_install_net_data = Array(Array(String))
os_install_net_route_data = Array(Array(String))
os_install_net_conf = String
#netconf = String
#dhcp = Array(String)
#ip = Array(String)
#route = Array(Array(String))
#dns = Array(String)
#proxy = String
os_install_ntp = String
os_install_x11_video_drv = String
os_install_x11_resolution = String
os_install_x11_composite = Boolean
os_install_fb_resolution = String
os_install_clock_timezone = String
os_install_kernel_scheduler = String
cl_autopartition_device = String
cl_autopartition_scheme = String
@ -106,37 +100,6 @@ def catchExcept():
return wrapper
class Wsdl:
def check_params (self, dv, info,allvars=False,ordered=None):
errors = []
keys = sorted(filter(lambda x:x.lower() == x,
info._type_info.keys()))
if ordered:
keys = ordered + filter(lambda x:not x in ordered,
keys)
for var in keys:
# get value of variable from info
val = info.__getattribute__(var)
# check value if value send of check allvariables
if val != None or allvars:
try:
# if value not send, then get from datavars
if val == None:
val = dv.Get(var)
else:
uncomperr = dv.Uncompatible(var)
if uncomperr:
raise VariableError(uncomperr)
if not dv.Uncompatible(var):
dv.Set(var, val)
except VariableError, e:
mess = ''
messages = e.message if type(e.message) == list else [e.message]
for error in messages:
mess += str(error) + '\n'
errors.append(ReturnedMessage(type = 'error', field = var,
message = mess))
return errors
from calculate.api.server.baseClass import Basic
from calculate.api.server.decorators import Dec
@ -147,20 +110,11 @@ class Wsdl:
try:
dv = self.get_cache(sid,methodname,"vars")
if not dv:
reload(cl_install)
dv = cl_install.DataVarsInstall()
dv.importInstall()
dv.flIniFile()
initfunc(dv)
errors = self.check_params(dv, info,
ordered=['cl_autopartition_scheme',
'cl_autopartition_device',
'cl_autopartition_root_size',
'cl_image_linux_shortname',
'cl_image_arch_machine',
'cl_image_linux_ver',
'cl_image_linux_build'],
allvars=not info.CheckOnly)
dv = initfunc()
else:
dv.processRefresh()
errors = map(lambda x:ReturnedMessage(**x),
dv.checkGroups(info,allvars=not info.CheckOnly))
if errors:
return errors
if info.CheckOnly:
@ -186,9 +140,38 @@ class Wsdl:
@Dec.console('cl-install')
@Dec.gui(_('System'),_('Install'),'drive-harddisk')
def install ( self, sid, info):
def init_func(dv):
dv.Set('cl_action','system',True)
return self.installCommon(sid,info,'install',init_func)
return self.installCommon(sid,info,'install',self.install_vars)
def install_vars(self):
reload(cl_install)
dv = cl_install.DataVarsInstall()
dv.importInstall()
dv.flIniFile()
dv.Set('cl_action','system',True)
dv.addGroup(_("Distribute"),
normal=('cl_image_filename',),
expert=('cl_image_linux_shortname', 'cl_image_arch_machine',
'cl_image_linux_ver', 'cl_image_linux_build'))
dv.addGroup(_("Autopartition"),
normal=('cl_autopartition_scheme','cl_autopartition_device'),
expert=('cl_autopartition_table','cl_autopartition_root_size'))
dv.addGroup(_("Partitioning"),
normal=('os_location_data','os_install_scratch','cl_uuid_set'),
expert=('os_install_root_type','os_install_mbr',
'os_install_kernel_scheduler'))
dv.addGroup(_("Locale"),
normal=('os_install_locale_lang','os_install_clock_timezone'))
dv.addGroup(_("Networking"),
normal=('os_install_net_conf','os_install_net_data',
'os_install_net_fqdn','os_install_ntp'),
expert=('os_install_net_route_data',))
dv.addGroup(_("Users"),
normal=('cl_migrate_data','cl_autologin'))
dv.addGroup(_("Video"),
normal=('os_install_x11_video_drv','os_install_x11_composite',
'os_install_x11_resolution','os_install_fb_resolution'),
next_label=_("Install"))
return dv
@rpc(Integer, Integer, Boolean,_returns = ViewInfo)
@catchExcept()
@ -196,45 +179,26 @@ class Wsdl:
curThread = threading.currentThread()
dv = self.get_cache(sid,"install","vars")
if not dv:
reload(cl_install)
dv = cl_install.DataVarsInstall()
dv.importInstall()
dv.flIniFile()
dv.Set('cl_action','system',True)
view = getViewForVariables (dv, [
(_("Distribute"), \
('cl_image_filename',),
('cl_image_linux_shortname','cl_image_arch_machine',
'cl_image_linux_ver','cl_image_linux_build'),
_("Next")), \
(_("Autopartition"), \
('cl_autopartition_device',
'cl_autopartition_scheme'),
('cl_autopartition_table','cl_autopartition_root_size'),
_("Next")), \
(_("Partitioning"), \
('os_location_data','os_install_scratch','cl_uuid_set'),
('os_install_root_type','os_install_mbr',
'os_install_kernel_scheduler'),
_("Next")), \
(_("Locale"), \
('os_install_locale_lang','os_install_clock_timezone'),(), \
_("Next")),
(_("Networking"), \
('os_install_net_conf','os_install_net_data','os_install_net_fqdn',
'os_install_ntp'),('os_install_net_route_data',), \
_("Next")),
(_("Users"), \
('cl_migrate_data','cl_autologin'),(), \
_("Next")),
(_("Video"), \
('os_install_x11_video_drv', 'os_install_x11_composite',
'os_install_x11_resolution', 'os_install_fb_resolution'),(), \
_("Install")),
],step,expert)
dv = self.install_vars()
else:
dv.processRefresh()
view = getViewForVariables (dv,step,expert)
self.set_cache(sid, 'install', "vars",dv,smart=False)
return view
def install_flash_vars(self):
reload(cl_install)
dv = cl_install.DataVarsInstall()
dv.importInstall()
dv.flIniFile()
dv.Set('cl_action','system',True)
dv.Set('cl_install_type','flash')
dv.addGroup(_("Flash install"),
normal=('os_install_disk_single','cl_image_filename'),
expert=('os_location_data',),
next_label=_("Install"))
return dv
@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
@Dec.check_permissions(["install"])
@Dec.gui(_('System'),_('Flash install'),
@ -243,27 +207,17 @@ class Wsdl:
"""
Install to flash
"""
def init_func(dv):
dv.Set('cl_action','system',True)
dv.Set('cl_install_type','flash')
return self.installCommon(sid,info,'install_flash',init_func)
return self.installCommon(sid,info,'install_flash',
self.install_flash_vars)
@rpc(Integer, Integer, Boolean,_returns = ViewInfo)
@catchExcept()
def install_flash_view (self, sid, step,expert):
dv = self.get_cache(sid,"install_flash","vars")
if not dv:
reload(cl_install)
dv = cl_install.DataVarsInstall()
dv.importInstall()
dv.flIniFile()
dv.Set('cl_action','system',True)
dv.Set('cl_install_type','flash')
view = getViewForVariables (dv, [
(_("Distribute"), \
('os_install_disk_single','cl_image_filename'),
('os_location_data',),
_("Install")), \
],step,expert)
dv = self.install_flash_vars()
else:
dv.processRefresh()
view = getViewForVariables (dv,step,expert)
self.set_cache(sid, 'install_flash', "vars",dv,smart=False)
return view

@ -132,10 +132,13 @@ class VariableClAutopartitionDevice(Variable):
def init(self):
self.help = _("set autopartition device")
self.label = _("Install device")
self.label = _("Autopartition device")
def choice(self):
return [""]+self.Get('os_device_dev')
deviceParentMap = dict(self.ZipVars('os_device_dev','os_device_name'))
return map(lambda x:(x,"%s (%s)"%(x,
deviceParentMap.get(x,_("Unknown")))),
self.Get('os_device_dev'))+[("","")]
def check(self,value):
if self.Get('cl_autopartition_scheme'):
@ -144,11 +147,12 @@ class VariableClAutopartitionDevice(Variable):
" device"))
useDisks = self.Select('os_disk_parent',
where='os_disk_mount',
eq=value)
ne='')
if value in useDisks:
raise VariableError(
_("Device already is used by current system"))
class VariableClAutopartitionScheme(Variable,AutoPartition):
"""
Autopartition scheme
@ -170,12 +174,11 @@ class VariableClAutopartitionRootSize(Variable):
"""
Root partition size for autopartition
"""
type = "int"
opt = ["--root-size"]
metavalue = "SIZE"
def init(self):
self.label = _("Root partition size")
self.label = _("Root partition size")+ " (MB)"
self.help = _("set root partition size for autopartition")
def get(self):
@ -198,8 +201,8 @@ class VariableClAutopartitionRootSize(Variable):
res = reSizeValue.search(value)
intValue = int(res.group(1))
if res.group(2):
intValue = intValue / sizeMap[res.group(2)]
return str(intValue)
intValue = intValue * sizeMap[res.group(2)]
return str(int(intValue))
def check(self,value):
if self.Get('cl_autopartition_device') and \
@ -390,9 +393,9 @@ class VariableClAutopartitionFreeSize(ReadonlyVariable):
return 0
sizeDevice = self.Select('os_device_size',
where='os_device_dev',
eq=device,limit=1)
eq=device,limit=1) or '0'
sizes = self.Get('cl_autopartition_disk_size')
return reduce(lambda x,y: x - int(y) if y.isdigit() else x,
return reduce(lambda x,y: (x - int(y)) if y.isdigit() else x,
sizes,int(sizeDevice))
class VariableClAutopartitionBindData(ReadonlyVariable):
@ -410,7 +413,8 @@ class VariableClAutopartitionBindPath(ReadonlyVariable):
type = "list"
def generatePath(self,scheme):
for line in scheme.split(';'):
for line in filter(lambda x:x,
scheme.split(';')):
source,mp = line.split(':')
if source.startswith('/'):
yield source
@ -427,7 +431,8 @@ class VariableClAutopartitionBindMountpoint(ReadonlyVariable):
type = "list"
def generateMountPoint(self,scheme):
for line in scheme.split(';'):
for line in filter(lambda x:x,
scheme.split(';')):
source,mp = line.split(':')
if source.startswith('/'):
yield mp

@ -17,6 +17,8 @@
import os
import sys
import re
import pty,fcntl
from subprocess import Popen
from os import path
from calculate.lib.datavars import Variable,VariableError,ReadonlyVariable
from calculate.lib.utils.device import (getUdevDeviceInfo,getDeviceType,
@ -74,6 +76,15 @@ class VariableOsDeviceDev(ReadonlyVariable,DeviceHelper):
"""
type = "list"
def init(self):
self.master,slave = pty.openpty()
self.monitor = Popen(["/sbin/udevadm","monitor","--kernel",
"--subsystem-match=block"],stdout=slave,
close_fds=True)
os.close(slave)
fl = fcntl.fcntl(self.master,fcntl.F_GETFL)
fcntl.fcntl(self.master, fcntl.F_SETFL, fl | os.O_NONBLOCK)
def get(self):
"""Get device /dev name"""
def _getDiskName(devpath):
@ -91,6 +102,20 @@ class VariableOsDeviceDev(ReadonlyVariable,DeviceHelper):
self.getDeviceFromSysPath()))),
key=self.separateDevice)
def close(self):
self.monitor.kill()
self.monitor.wait()
def refresh(self):
try:
res = os.read(self.master,65535)
if res:
while len(res) == 65535:
res = os.read(self.master,65535)
self.parent.Invalidate(self.name)
except OSError as e:
pass
class VariableOsDeviceType(ReadonlyVariable):
"""
Device type (hdd,cdrom,usb-flash)

@ -533,18 +533,24 @@ class VariableOsInstallNetConf(NetVariable):
listDirectory('/etc/runlevels/boot')+
listDirectory('/etc/runlevels/default')) \
or self.Get('os_install_root_type') == "livecd":
if isPkgInstalled("net-misc/networkmanager",
prefix=self.Get('cl_chroot_path')):
return "networkmanager"
return "openrc"
nm = "networkmanager"
if nm in map(lambda x:x[1],self.choice()):
return nm
else:
return "openrc"
def choice(self):
mapNetConf = (('networkmanager','net-misc/networkmanager',_("NetworkManager")),
('openrc','',_('OpenRC')))
return map(lambda x:(x[0],x[2]),
filter(lambda x:not x[1] or isPkgInstalled(x[1],
prefix=self.Get('cl_chroot_path')),
mapNetConf))
image = self.Get('cl_image')
if image:
with image as distr:
distrPath = image.getDirectory()
return map(lambda x:(x[0],x[2]),
filter(lambda x:not x[1] or isPkgInstalled(x[1],
prefix=distrPath),
mapNetConf))
return map(lambda x:x[0::2],mapNetConf[-1:])
class VariableOsInstallNetDnsSearch(NetVariable):
"""

Loading…
Cancel
Save