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
if distr:
distr.close()
if not path.isdir(keyCache):
if keyCache and not path.isdir(keyCache):
Distributive.contentCache[keyCache] = d
return d.copy()
finally:

@ -20,6 +20,7 @@ __app__ = "calculate-install"
import os
import re
import sys
import time
import traceback
from os import path
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 import cl_overriding
from calculate.lib.utils import ip
from datavars import DataVarsInstall
from cl_kernel_utils import KernelConfig,InitRamFs
@ -85,14 +87,6 @@ class printNoColor:
def colorPrint(self,attr,fg,bg,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:
"""Convert dict install option"""
@ -286,11 +280,14 @@ class Install(color_print, SignalInterrupt):
def setNoColor(self):
self.color = False
def initVars(self):
def initVars(self,datavars=None):
"""Primary initialization of variables"""
self.clVars = DataVarsInstall()
self.clVars.importInstall()
self.clVars.flIniFile()
if not datavars:
self.clVars = DataVarsInstall()
self.clVars.importInstall()
self.clVars.flIniFile()
else:
self.clVars = datavars
def cmpInstallVersion(self):
"""Compare current and install version(build)
@ -1759,28 +1756,42 @@ class Install(color_print, SignalInterrupt):
return table
def installSystem(self,disks=None,mbr=None,builder=None,
typeDisk=None):
def installSystem(self,variables):
"""install System by current variable enviroment"""
sourceDistr = None
targetDistr = None
error = None
distrCopy = False
if variables:
self.clVars = variables
else:
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:
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,
buildermode=builder,
fileSystem=rootPartFileSystem,

@ -39,14 +39,15 @@ class InstallInfo(ClassSerializer):
cl_uuid_set = Boolean
cl_image_linux_shortname = String
cl_image_arch_machine = String
cl_image_filename = String
cl_image_linux_ver = String
cl_image_linux_build = String
cl_image_filename = String
os_install_scratch = Boolean
os_install_locale_lang = String
#user = Array(String)
#autologin = String
#password = Array(String)
os_install_net_hostname = String
os_install_net_fqdn = String
#netconf = String
#dhcp = Array(String)
#ip = Array(String)
@ -62,13 +63,20 @@ class InstallInfo(ClassSerializer):
CheckOnly = Boolean
class Wsdl:
def check_params (self, dv, info):
def check_params (self, dv, info,allvars=False,ordered=None):
errors = []
for var in filter(lambda x:x.lower() == x,
info._type_info.keys()):
if info.__getattribute__(var) != None:
keys = 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:
val = info.__getattribute__(var)
if val != None or allvars:
try:
dv.Set(var, info.__getattribute__(var))
if val == None:
val = dv.Get(var)
dv.Set(var, val)
except VariableError, e:
mess = ''
messages = e.message if type(e.message) == list else [e.message]
@ -94,22 +102,27 @@ class Wsdl:
dv.importInstall()
dv.Set('cl_action','system',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:
return errors
import ipdb
ipdb.set_trace()
if info.CheckOnly:
returnmess = ReturnedMessage(type = '', message = None)
return [returnmess]
test2_meth = type("CommonInstall",(self.Common, ApiWsdl, object), {})
name = sh.name
pid = self.startprocess(sid, target=test2_meth, method="test2_meth",\
args_proc = (name[0], times, town))
install_meth = type("CommonInstall",(self.Common, Install, object), {})
#name = sh.name
pid = self.startprocess(sid, target=install_meth, method="installSystem",\
args_proc = (dv,))
returnmess = ReturnedMessage(type = 'pid', message = pid)
#returnmess.type = "pid"
#returnmess.message = pid
returnmess.type = "pid"
returnmess.message = pid
dv = self.clear_cache(sid,"install")
return [returnmess]
finally:
self.set_cache(sid,"install","vars",dv)
@ -125,7 +138,7 @@ class Wsdl:
view = getViewForVariables (dv, [
(_("Distribute"), \
('cl_image_linux_shortname','cl_image_arch_machine',
'cl_image_linux_build'),
'cl_image_linux_ver','cl_image_linux_build'),
('cl_image_filename',),
_("Next")), \
(_("Partitioning"), \
@ -136,7 +149,7 @@ class Wsdl:
('os_install_locale_lang','os_install_clock_timezone'),(), \
_("Next")),
(_("Networking"), \
('os_install_net_hostname','os_install_ntp'),(), \
('os_install_net_fqdn','os_install_ntp'),(), \
_("Next")),
(_("Video"), \
('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 sys
import re
from os import path
from calculate.lib.cl_datavars import Variables,VariableError
from calculate.lib.variables import X11
@ -35,19 +36,34 @@ class InstallX11(X11):
"os_install_x11_composite","os_install_fb_resolution","hr_video_id"]
# xorg resolution
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
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
os_install_x11_composite = {'mode':'w',
'type':'bool'}
'type':'bool',
'opt':['--composite'],
'help':_("set composite"),
'label':_("Composite")}
# fb resolution
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
hr_video_id = {'value':""}
@ -56,9 +72,10 @@ class InstallX11(X11):
"""Get available (already installed or installable drivers"""
image = self.Get('cl_image')
if image:
distrPath = image.getDirectory()
if isPkgInstalled('xorg-server',prefix=distrPath):
return getAvailableVideo(prefix=distrPath)+['other']
with image as distr:
distrPath = image.getDirectory()
if isPkgInstalled('xorg-server',prefix=distrPath):
return getAvailableVideo(prefix=distrPath)+['other']
return []
def get_os_install_x11_video_drv(self):
@ -98,7 +115,7 @@ class InstallX11(X11):
"""Check resolution"""
if not re.match('^\d+x\d+$',value):
raise VariableError(
_("Wrong resolution %{resolution} %{example}").format(
_("Wrong resolution {resolution} {example}").format(
resolution=value,
example="(%s:%s)"%(_("Example"),"1024x768")))

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

@ -50,7 +50,7 @@ class Distro(Variables):
# filter by shortname
cl_image_linux_shortname = {'mode':'w',
'type':'string',
'type':'choice',
'opt':['--os','-s'],
'label':_("Distributive"),
'help':_("select the operation system")}
@ -118,8 +118,8 @@ class Distro(Variables):
['/var/calculate/remote/linux',
'/var/calculate/linux'] + livedistr)
def getImage(self,scratch,rootType,imagePath,archMachine,
shortName,linuxVer=None,linuxBuild=None):
def getImage(self,scratch,rootType,imagePath,march=None,
shortName=None,linuxVer=None,linuxBuild=None):
"""Get image by parameters"""
# exclude directory distributive for flash and scratch install
if scratch == "on" or rootType == "flash":
@ -127,8 +127,8 @@ class Distro(Variables):
else:
discardType = []
return self.getBestDistributive(imagePath,
march=archMachine,
shortname=shortName.lower(),
march=march,
shortname=shortName,
discardType=discardType,
version=linuxVer,
build=linuxBuild)
@ -300,6 +300,8 @@ class Distro(Variables):
def getBestDistributive(self,dirs,system=None,shortname=None,march=None,
version=None, build=None,discardType=[]):
"""Get the actualest distributive"""
if shortname:
shortname = shortname.lower()
availDistrs = self._getAvailableDistributives(dirs,system,shortname,
march,version,
build)
@ -346,3 +348,51 @@ class Distro(Variables):
def choice_cl_image_arch_machine(self):
"""Get image arch"""
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 sys
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.utils.files import readLinesFile, process
from calculate.lib.utils.common import getValueFromCmdLine, getValueFromConfig
@ -49,7 +49,10 @@ class InstallLocale(Locale):
os_install_locale_locale = {}
# 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)
os_install_locale_language = {}
@ -61,7 +64,11 @@ class InstallLocale(Locale):
os_install_locale_xkbname = {}
# 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)
os_install_clock_type = {'mode':'w'}
@ -90,7 +97,7 @@ class InstallLocale(Locale):
def check_os_install_clock_timezone(self,value):
"""Check timezone"""
if not path.isfile(path.join(
if not value or not path.isfile(path.join(
"/usr/share/zoneinfo",value)):
raise VariableError(_("%s timezone is wrong")%value)
@ -164,3 +171,38 @@ class InstallLocale(Locale):
if localeXkb:
return localeXkb.split("(")[0]
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_dns","os_install_net_conf",
"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
os_net_interfaces_info = {}
@ -105,3 +106,28 @@ class InstallNet(Net):
# domain
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
os_install_ntp = {'mode':'w',
'label':_("NTP server"),
'opt':['--ntp'],
'help':_("set the ntp server for the system"),
'metavalue':"NTP",
'value':'ntp0.zenon.net'}
# type of device for install

Loading…
Cancel
Save