Fix variables. Add proxy of installSystem.

master3.3
Mike Hiretsky 12 years ago
parent 3da4185a94
commit 22a33d3847

@ -475,7 +475,7 @@ class Distributive(object, SignalInterrupt):
d['ext'] = extname d['ext'] = extname
if distr: if distr:
distr.close() distr.close()
if not path.isdir(keyCache): if keyCache and not path.isdir(keyCache):
Distributive.contentCache[keyCache] = d Distributive.contentCache[keyCache] = d
return d.copy() return d.copy()
finally: finally:

@ -20,6 +20,7 @@ __app__ = "calculate-install"
import os import os
import re import re
import sys import sys
import time
import traceback import traceback
from os import path from os import path
from StringIO import StringIO from StringIO import StringIO
@ -38,6 +39,7 @@ from calculate.lib.utils.device import (detectDeviceForPartition,
from calculate.lib.cl_vars_share import varsShare from calculate.lib.cl_vars_share import varsShare
from calculate.lib import cl_overriding from calculate.lib import cl_overriding
from calculate.lib.utils import ip from calculate.lib.utils import ip
from datavars import DataVarsInstall
from cl_kernel_utils import KernelConfig,InitRamFs from cl_kernel_utils import KernelConfig,InitRamFs
@ -85,14 +87,6 @@ class printNoColor:
def colorPrint(self,attr,fg,bg,string): def colorPrint(self,attr,fg,bg,string):
sys.stdout.write(string) sys.stdout.write(string)
class DataVarsInstall(ClDataVars):
"""Variable class for installation"""
def importInstall(self, **args):
"""Import install variables"""
self.importData('calculate.install.cl_vars_install')
class FileSystemManager: class FileSystemManager:
"""Convert dict install option""" """Convert dict install option"""
@ -286,11 +280,14 @@ class Install(color_print, SignalInterrupt):
def setNoColor(self): def setNoColor(self):
self.color = False self.color = False
def initVars(self): def initVars(self,datavars=None):
"""Primary initialization of variables""" """Primary initialization of variables"""
self.clVars = DataVarsInstall() if not datavars:
self.clVars.importInstall() self.clVars = DataVarsInstall()
self.clVars.flIniFile() self.clVars.importInstall()
self.clVars.flIniFile()
else:
self.clVars = datavars
def cmpInstallVersion(self): def cmpInstallVersion(self):
"""Compare current and install version(build) """Compare current and install version(build)
@ -1759,28 +1756,42 @@ class Install(color_print, SignalInterrupt):
return table return table
def installSystem(self,disks=None,mbr=None,builder=None, def installSystem(self,variables):
typeDisk=None):
"""install System by current variable enviroment""" """install System by current variable enviroment"""
sourceDistr = None if variables:
targetDistr = None self.clVars = variables
error = None else:
distrCopy = False self.initVars()
try:
self.clVars.printVars()
results = []
self.writeFile()
# Помещение данных в словарь процессов
self.briefParams('install_view')
#self.beginFrame()
self.startTask("Installation", True)
# Учёт процесса выполнения
perc = 0
while self.getProgress() < 100:
time.sleep(2)
perc += 10
# Увеличение процента выполнения процесса
self.setProgress (perc)
#question = self.askQuestion('enter name: ', None)
#print question
#print self.askPassword ('Please, your enter pass: ')
self.endTask("Installation complete!")
self.endFrame()
# necessary for correct complete the process
return True
# Обработка сигнала прерывания работы процесса
except KeyboardInterrupt:
# Необходимо передать Fasle для сохранения данных о процессе
return False
except:
return False
return True
try: try:
self.createListOptions()
rootPartdev = self.clVars.Get('os_install_root_dev')
rootPartCmdList = filter(lambda x: x['dev']==rootPartdev,
self.listDisksOptions)
rootPartCmdDict = rootPartCmdList[0]
rootPartFileSystem = self.getFieldByField("format","dev",
rootPartdev,
firstPrefix="os_install_disk")
rootPartIsFormat=rootPartCmdDict['isFormat']
rootPartSystemId=rootPartCmdDict['systemId']
self.printInfo(update=update)
return []
targetDistr = self.getTargetDistributive(rootPartdev, targetDistr = self.getTargetDistributive(rootPartdev,
buildermode=builder, buildermode=builder,
fileSystem=rootPartFileSystem, fileSystem=rootPartFileSystem,

@ -39,14 +39,15 @@ class InstallInfo(ClassSerializer):
cl_uuid_set = Boolean cl_uuid_set = Boolean
cl_image_linux_shortname = String cl_image_linux_shortname = String
cl_image_arch_machine = String cl_image_arch_machine = String
cl_image_filename = String cl_image_linux_ver = String
cl_image_linux_build = String cl_image_linux_build = String
cl_image_filename = String
os_install_scratch = Boolean os_install_scratch = Boolean
os_install_locale_lang = String os_install_locale_lang = String
#user = Array(String) #user = Array(String)
#autologin = String #autologin = String
#password = Array(String) #password = Array(String)
os_install_net_hostname = String os_install_net_fqdn = String
#netconf = String #netconf = String
#dhcp = Array(String) #dhcp = Array(String)
#ip = Array(String) #ip = Array(String)
@ -62,13 +63,20 @@ class InstallInfo(ClassSerializer):
CheckOnly = Boolean CheckOnly = Boolean
class Wsdl: class Wsdl:
def check_params (self, dv, info): def check_params (self, dv, info,allvars=False,ordered=None):
errors = [] errors = []
for var in filter(lambda x:x.lower() == x, keys = filter(lambda x:x.lower() == x,
info._type_info.keys()): info._type_info.keys())
if info.__getattribute__(var) != None: if ordered:
keys = ordered + filter(lambda x:not x in ordered,
keys)
for var in keys:
val = info.__getattribute__(var)
if val != None or allvars:
try: try:
dv.Set(var, info.__getattribute__(var)) if val == None:
val = dv.Get(var)
dv.Set(var, val)
except VariableError, e: except VariableError, e:
mess = '' mess = ''
messages = e.message if type(e.message) == list else [e.message] messages = e.message if type(e.message) == list else [e.message]
@ -94,22 +102,27 @@ class Wsdl:
dv.importInstall() dv.importInstall()
dv.Set('cl_action','system',True) dv.Set('cl_action','system',True)
dv.Set('cl_image_arch_machine','i686',True) dv.Set('cl_image_arch_machine','i686',True)
errors = self.check_params(dv, info) errors = self.check_params(dv, info,
ordered=['cl_image_linux_shortname',
'cl_image_arch_machine',
'cl_image_linux_ver',
'cl_image_linux_build'],
allvars=not info.CheckOnly)
if errors: if errors:
return errors return errors
import ipdb
ipdb.set_trace()
if info.CheckOnly: if info.CheckOnly:
returnmess = ReturnedMessage(type = '', message = None) returnmess = ReturnedMessage(type = '', message = None)
return [returnmess] return [returnmess]
test2_meth = type("CommonInstall",(self.Common, ApiWsdl, object), {})
name = sh.name
pid = self.startprocess(sid, target=test2_meth, method="test2_meth",\ install_meth = type("CommonInstall",(self.Common, Install, object), {})
args_proc = (name[0], times, town)) #name = sh.name
pid = self.startprocess(sid, target=install_meth, method="installSystem",\
args_proc = (dv,))
returnmess = ReturnedMessage(type = 'pid', message = pid) returnmess = ReturnedMessage(type = 'pid', message = pid)
#returnmess.type = "pid" returnmess.type = "pid"
#returnmess.message = pid returnmess.message = pid
dv = self.clear_cache(sid,"install")
return [returnmess] return [returnmess]
finally: finally:
self.set_cache(sid,"install","vars",dv) self.set_cache(sid,"install","vars",dv)
@ -125,7 +138,7 @@ class Wsdl:
view = getViewForVariables (dv, [ view = getViewForVariables (dv, [
(_("Distribute"), \ (_("Distribute"), \
('cl_image_linux_shortname','cl_image_arch_machine', ('cl_image_linux_shortname','cl_image_arch_machine',
'cl_image_linux_build'), 'cl_image_linux_ver','cl_image_linux_build'),
('cl_image_filename',), ('cl_image_filename',),
_("Next")), \ _("Next")), \
(_("Partitioning"), \ (_("Partitioning"), \
@ -136,7 +149,7 @@ class Wsdl:
('os_install_locale_lang','os_install_clock_timezone'),(), \ ('os_install_locale_lang','os_install_clock_timezone'),(), \
_("Next")), _("Next")),
(_("Networking"), \ (_("Networking"), \
('os_install_net_hostname','os_install_ntp'),(), \ ('os_install_net_fqdn','os_install_ntp'),(), \
_("Next")), _("Next")),
(_("Video"), \ (_("Video"), \
('os_install_x11_video_drv','os_install_x11_resolution', ('os_install_x11_video_drv','os_install_x11_resolution',

@ -0,0 +1,29 @@
#-*- coding: utf-8 -*-
# Copyright 2010 Calculate Ltd. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
from calculate.lib.cl_datavars import ClDataVars
from calculate.lib.cl_lang import setLocalTranslate
setLocalTranslate('cl_install',sys.modules[__name__])
class DataVarsInstall(ClDataVars):
"""Variable class for installation"""
def importInstall(self, **args):
"""Import install variables"""
self.importData('calculate.install.cl_vars_install')

@ -16,6 +16,7 @@
import os import os
import sys import sys
import re
from os import path from os import path
from calculate.lib.cl_datavars import Variables,VariableError from calculate.lib.cl_datavars import Variables,VariableError
from calculate.lib.variables import X11 from calculate.lib.variables import X11
@ -35,19 +36,34 @@ class InstallX11(X11):
"os_install_x11_composite","os_install_fb_resolution","hr_video_id"] "os_install_x11_composite","os_install_fb_resolution","hr_video_id"]
# xorg resolution # xorg resolution
os_install_x11_resolution = {'mode':'w', os_install_x11_resolution = {'mode':'w',
'type':'choiceedit'} 'type':'choiceedit',
'opt':['-X'],
'metavalue':"<width>x<height>",
'help':_("set Xorg resolution"),
'label':_("Screen resolution")}
# Video driver used by xorg # Video driver used by xorg
os_install_x11_video_drv = {'mode':'w', os_install_x11_video_drv = {'mode':'w',
'type':'choice'} 'type':'choice',
'opt':['--video'],
'metavalue':"VIDEODRV",
'help':_("set the video driver"),
'label':_("{0} video driver").format("Xorg")}
# on/off composite # on/off composite
os_install_x11_composite = {'mode':'w', os_install_x11_composite = {'mode':'w',
'type':'bool'} 'type':'bool',
'opt':['--composite'],
'help':_("set composite"),
'label':_("Composite")}
# fb resolution # fb resolution
os_install_fb_resolution = {'mode':'w', os_install_fb_resolution = {'mode':'w',
'type':'choiceedit'} 'type':'choiceedit',
'opt':['--fb'],
'metavalue':"<width>x<height>",
'help':_("set framebuffer resolution"),
'label':_("Framebuffer resolution")}
# busid of video card # busid of video card
hr_video_id = {'value':""} hr_video_id = {'value':""}
@ -56,9 +72,10 @@ class InstallX11(X11):
"""Get available (already installed or installable drivers""" """Get available (already installed or installable drivers"""
image = self.Get('cl_image') image = self.Get('cl_image')
if image: if image:
distrPath = image.getDirectory() with image as distr:
if isPkgInstalled('xorg-server',prefix=distrPath): distrPath = image.getDirectory()
return getAvailableVideo(prefix=distrPath)+['other'] if isPkgInstalled('xorg-server',prefix=distrPath):
return getAvailableVideo(prefix=distrPath)+['other']
return [] return []
def get_os_install_x11_video_drv(self): def get_os_install_x11_video_drv(self):
@ -98,7 +115,7 @@ class InstallX11(X11):
"""Check resolution""" """Check resolution"""
if not re.match('^\d+x\d+$',value): if not re.match('^\d+x\d+$',value):
raise VariableError( raise VariableError(
_("Wrong resolution %{resolution} %{example}").format( _("Wrong resolution {resolution} {example}").format(
resolution=value, resolution=value,
example="(%s:%s)"%(_("Example"),"1024x768"))) example="(%s:%s)"%(_("Example"),"1024x768")))

@ -141,6 +141,9 @@ class InstallDisk(Variables):
cl_uuid_set = {'value':'on', cl_uuid_set = {'value':'on',
'type':'bool', 'type':'bool',
'label':_("Use UUID"),
'opt':["--uuid"],
'help':_("use UUID"),
'mode':'w'} 'mode':'w'}
os_install_disk_data = {'type':"table", os_install_disk_data = {'type':"table",
@ -958,9 +961,9 @@ class InstallDisk(Variables):
device = filter(lambda x:x in rootdev, device = filter(lambda x:x in rootdev,
self.Get('os_device_dev')) self.Get('os_device_dev'))
if device: if device:
return device[0] return [device[0]]
else: else:
return "" return []
# if loaded system livecd # if loaded system livecd
if self.Get('os_root_type') == "livecd": if self.Get('os_root_type') == "livecd":
# search /boot device or / device, by priority /boot,/ # search /boot device or / device, by priority /boot,/
@ -976,10 +979,10 @@ class InstallDisk(Variables):
self.Get('os_device_dev')) self.Get('os_device_dev'))
# set it by default # set it by default
if device: if device:
return device[0] return [device[0]]
if self.Get('os_device_dev'): if self.Get('os_device_dev'):
return self.Get('os_device_dev')[0] return [self.Get('os_device_dev')[0]]
return "" return []
def _commentFstab(self,s,mp,dev): def _commentFstab(self,s,mp,dev):
"""Generate comment for /etc/fstab each line""" """Generate comment for /etc/fstab each line"""

@ -50,7 +50,7 @@ class Distro(Variables):
# filter by shortname # filter by shortname
cl_image_linux_shortname = {'mode':'w', cl_image_linux_shortname = {'mode':'w',
'type':'string', 'type':'choice',
'opt':['--os','-s'], 'opt':['--os','-s'],
'label':_("Distributive"), 'label':_("Distributive"),
'help':_("select the operation system")} 'help':_("select the operation system")}
@ -118,8 +118,8 @@ class Distro(Variables):
['/var/calculate/remote/linux', ['/var/calculate/remote/linux',
'/var/calculate/linux'] + livedistr) '/var/calculate/linux'] + livedistr)
def getImage(self,scratch,rootType,imagePath,archMachine, def getImage(self,scratch,rootType,imagePath,march=None,
shortName,linuxVer=None,linuxBuild=None): shortName=None,linuxVer=None,linuxBuild=None):
"""Get image by parameters""" """Get image by parameters"""
# exclude directory distributive for flash and scratch install # exclude directory distributive for flash and scratch install
if scratch == "on" or rootType == "flash": if scratch == "on" or rootType == "flash":
@ -127,8 +127,8 @@ class Distro(Variables):
else: else:
discardType = [] discardType = []
return self.getBestDistributive(imagePath, return self.getBestDistributive(imagePath,
march=archMachine, march=march,
shortname=shortName.lower(), shortname=shortName,
discardType=discardType, discardType=discardType,
version=linuxVer, version=linuxVer,
build=linuxBuild) build=linuxBuild)
@ -300,6 +300,8 @@ class Distro(Variables):
def getBestDistributive(self,dirs,system=None,shortname=None,march=None, def getBestDistributive(self,dirs,system=None,shortname=None,march=None,
version=None, build=None,discardType=[]): version=None, build=None,discardType=[]):
"""Get the actualest distributive""" """Get the actualest distributive"""
if shortname:
shortname = shortname.lower()
availDistrs = self._getAvailableDistributives(dirs,system,shortname, availDistrs = self._getAvailableDistributives(dirs,system,shortname,
march,version, march,version,
build) build)
@ -346,3 +348,51 @@ class Distro(Variables):
def choice_cl_image_arch_machine(self): def choice_cl_image_arch_machine(self):
"""Get image arch""" """Get image arch"""
return ["i686","x86_64"] return ["i686","x86_64"]
def check_cl_image_linux_shortname(self,value):
if self.Get('cl_action') == 'system':
if not self.Get('cl_image'):
if not self.getImage(self.Get('os_install_scratch'),
self.Get('os_install_root_type'),
self.Get('cl_image_path'),
shortName=value):
raise VariableError(
_('Installation image of {0} not found').format(value))
def check_cl_image_arch_machine(self,value):
if self.Get('cl_action') == 'system':
if not self.Get('cl_image'):
if not self.getImage(self.Get('os_install_scratch'),
self.Get('os_install_root_type'),
self.Get('cl_image_path'),
march=value,
shortName=self.Get('cl_image_linux_shortname')):
raise VariableError(
_('Installation image of {distro} with '
"architecture '{arch}' not found").format(
distro=self.Get('cl_image_linux_shortname'),
arch=value))
def check_cl_image_linux_ver(self,value):
if self.Get('cl_action') == 'system':
if value and not self.Get('cl_image'):
if not self.getImage(self.Get('os_install_scratch'),
self.Get('os_install_root_type'),
self.Get('cl_image_path'),
march=self.Get('cl_image_arch_machine'),
shortName=self.Get('cl_image_linux_shortname'),
linuxVer=value):
raise VariableError(
_('Installation image of {distro} with '
"version '{ver}' not found").format(
distro="%s-%s"%
(self.Get('cl_image_linux_shortname'),
self.Get('cl_image_arch_machine')),
ver=value))
def check_cl_image_linux_build(self,value):
if self.Get('cl_action') == 'system':
if value and not self.Get('cl_image'):
raise VariableError(
_('Installation image with build {build} not found').format(
build=value))

@ -17,7 +17,7 @@
import os import os
import sys import sys
from os import path from os import path
from calculate.lib.cl_datavars import Variables from calculate.lib.cl_datavars import Variables, VariableError
from calculate.lib.variables import Locale from calculate.lib.variables import Locale
from calculate.lib.utils.files import readLinesFile, process from calculate.lib.utils.files import readLinesFile, process
from calculate.lib.utils.common import getValueFromCmdLine, getValueFromConfig from calculate.lib.utils.common import getValueFromCmdLine, getValueFromConfig
@ -49,7 +49,10 @@ class InstallLocale(Locale):
os_install_locale_locale = {} os_install_locale_locale = {}
# full language (at example: ru_RU) # full language (at example: ru_RU)
os_install_locale_lang = {} os_install_locale_lang = {'mode':'w',
'type':'choice',
'label':_("Language"),
'opt':["--lang","-l"]}
# short language (at example ru) # short language (at example ru)
os_install_locale_language = {} os_install_locale_language = {}
@ -61,7 +64,11 @@ class InstallLocale(Locale):
os_install_locale_xkbname = {} os_install_locale_xkbname = {}
# timezone for clock # timezone for clock
os_install_clock_timezone = {'mode':'w'} os_install_clock_timezone = {'mode':'w',
'type':'choiceedit',
'label':_("Timezone"),
'metavalue':"TIMEZONE",
'opt':["--timezone"]}
# type of clock (UTC or local) # type of clock (UTC or local)
os_install_clock_type = {'mode':'w'} os_install_clock_type = {'mode':'w'}
@ -90,7 +97,7 @@ class InstallLocale(Locale):
def check_os_install_clock_timezone(self,value): def check_os_install_clock_timezone(self,value):
"""Check timezone""" """Check timezone"""
if not path.isfile(path.join( if not value or not path.isfile(path.join(
"/usr/share/zoneinfo",value)): "/usr/share/zoneinfo",value)):
raise VariableError(_("%s timezone is wrong")%value) raise VariableError(_("%s timezone is wrong")%value)
@ -164,3 +171,38 @@ class InstallLocale(Locale):
if localeXkb: if localeXkb:
return localeXkb.split("(")[0] return localeXkb.split("(")[0]
return "" return ""
def choice_os_install_locale_lang(self):
"""Choice of language"""
return self.Get('os_lang')
def choice_os_install_clock_timezone(self):
return ["Etc/GMT-12", "Pacific/Midway", "Pacific/Honolulu",
"America/Anchorage", "Canada/Pacific", "America/Tijuana",
"America/Phoenix", "America/Denver", "America/Mazatlan",
"America/Mazatlan", "America/Monterrey", "America/Monterrey",
"America/Regina", "America/Mexico_City", "Canada/Central",
"America/Bogota", "America/New_York",
"America/Indiana/Indianapolis", "America/Halifax",
"America/Caracas", "America/Manaus", "America/Santiago",
"America/St_Johns", "America/Sao_Paulo",
"America/Argentina/Buenos_Aires", "Etc/GMT+3",
"America/Montevideo", "Atlantic/South_Georgia",
"Atlantic/Azores", "Atlantic/Cape_Verde", "UTC",
"Africa/Casablanca", "Europe/Amsterdam", "Europe/Belgrade",
"Europe/Brussels", "Europe/Zagreb", "Africa/Tunis",
"Asia/Amman", "Europe/Istanbul", "Asia/Beirut", "Europe/Kiev",
"Africa/Windhoek", "Asia/Jerusalem", "Africa/Cairo",
"Europe/Minsk", "Africa/Harare", "Asia/Baghdad", "Asia/Kuwait",
"Europe/Moscow", "Africa/Nairobi", "Asia/Tbilisi",
"Asia/Tehran", "Asia/Muscat", "Asia/Baku", "Asia/Yerevan",
"Asia/Kabul", "Asia/Yekaterinburg", "Asia/Karachi",
"Asia/Calcutta", "Asia/Jayapura", "Asia/Katmandu",
"Asia/Almaty", "Asia/Dhaka", "Asia/Omsk", "Asia/Rangoon",
"Asia/Bangkok", "Asia/Krasnoyarsk", "Asia/Hong_Kong",
"Asia/Irkutsk", "Asia/Singapore", "Australia/Perth",
"Asia/Taipei", "Asia/Tokyo", "Asia/Seoul", "Asia/Yakutsk",
"Australia/Adelaide", "Australia/Darwin", "Australia/Brisbane",
"Asia/Vladivostok", "Pacific/Guam", "Australia/Melbourne",
"Australia/Hobart", "Asia/Magadan", "Asia/Kamchatka",
"Pacific/Auckland", "Etc/GMT-13"]

@ -34,7 +34,8 @@ class InstallNet(Net):
"os_install_net_route","os_install_net_nmroute", "os_install_net_route","os_install_net_nmroute",
"os_install_net_dns","os_install_net_conf", "os_install_net_dns","os_install_net_conf",
"os_install_net_settings","os_install_net_dhcp_set", "os_install_net_settings","os_install_net_dhcp_set",
"os_install_net_dns_search","os_install_net_domain"] "os_install_net_dns_search","os_install_net_domain",
"os_install_net_fqdn"]
# inforamation about net interfaces # inforamation about net interfaces
os_net_interfaces_info = {} os_net_interfaces_info = {}
@ -105,3 +106,28 @@ class InstallNet(Net):
# domain # domain
os_install_net_domain = {'mode':"w"} os_install_net_domain = {'mode':"w"}
os_install_net_fqdn = {'mode':"w",
'opt':['--hostname'],
'label':_("Hostname"),
'help':_("set the short hostname or full hostname")}
def set_os_install_net_fqdn(self,value):
if "." in value:
return value
else:
return "%s.%s"%(value,self.Get('os_install_net_domain'))
def check_os_install_net_fqdn(self,value):
maxfqdn = 254
if len(value) > maxfqdn:
raise VariableError(
_("Hostname length should be less that %d")%maxfqdn)
def get_os_install_net_fqdn(self):
return self.Get('os_net_fqdn')
def get_os_install_net_hostname(self):
return self.Get('os_install_net_fqdn').partition('.')[0]
def get_os_install_net_domain(self):
return self.Get('os_install_net_fqdn').partition('.')[2]

@ -67,6 +67,10 @@ class InstallSystem(System):
# nt server for system # nt server for system
os_install_ntp = {'mode':'w', os_install_ntp = {'mode':'w',
'label':_("NTP server"),
'opt':['--ntp'],
'help':_("set the ntp server for the system"),
'metavalue':"NTP",
'value':'ntp0.zenon.net'} 'value':'ntp0.zenon.net'}
# type of device for install # type of device for install

Loading…
Cancel
Save