parent
c9ccf59fff
commit
4e87ca2f5e
@ -1,191 +0,0 @@
|
||||
#-*- 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 re
|
||||
import os
|
||||
from os import path
|
||||
from os import access,R_OK
|
||||
from shutil import copy2
|
||||
import gzip
|
||||
|
||||
from calculate.lib.utils.files import typeFile, process, listDirectory
|
||||
|
||||
class KernelConfig:
|
||||
"""Object for work with kernel config
|
||||
|
||||
Example:
|
||||
# get current config
|
||||
kc = KernelConfig()
|
||||
# get specified config
|
||||
kc = KernelConfig(configFile="/boot/config-2.6.34.1-i686-CLD")
|
||||
"""
|
||||
def __init__(self,configFile=None):
|
||||
if configFile == None:
|
||||
configFile = '/proc/config.gz'
|
||||
self.config = self._processConfig(configFile)
|
||||
|
||||
def _processConfig(self,configFile):
|
||||
fileType = typeFile().getMType(configFile).partition(';')[0].strip()
|
||||
if fileType == "application/x-gzip":
|
||||
config = gzip.open(configFile)
|
||||
else:
|
||||
config = open(configFile,'r')
|
||||
reEmptyString = re.compile("^(#\s*|\s*)$")
|
||||
# discard empty strings
|
||||
data = filter(lambda x:not reEmptyString.match(x),config.readlines())
|
||||
# convert param names
|
||||
data = map(lambda x:x.strip().replace("=y","=Y"
|
||||
).replace("=m","=M"
|
||||
).replace(" is not set","=N"), data)
|
||||
# fix data
|
||||
data = ["# Root"]+map(lambda x: x[2:] if "=N" in x else x,data)[3:]
|
||||
|
||||
config = []
|
||||
curSect = None
|
||||
for line in data:
|
||||
if line.startswith('#'):
|
||||
curSect = line[2:]
|
||||
else:
|
||||
config.append([curSect]+line.split('='))
|
||||
return config
|
||||
|
||||
def getSectionParams(self,*regs):
|
||||
"""Get params from sections specified by regular
|
||||
|
||||
Example:
|
||||
params = kernelconfig.getSectionParams("SCSI Transport","File Sys.*")
|
||||
"""
|
||||
params = []
|
||||
for reg in regs:
|
||||
reMatch = re.compile(reg,re.M)
|
||||
params += filter(lambda x:reMatch.search(x[0]),self.config)
|
||||
return map(lambda x: (x[1],x[2]), params)
|
||||
|
||||
def getSections(self):
|
||||
return list(set(map(lambda x:x[0],self.config)))
|
||||
|
||||
|
||||
class KernelModules:
|
||||
"""Object for work with current kernel modules"""
|
||||
def __init__(self):
|
||||
self._initModulesData()
|
||||
|
||||
def _initModulesData(self):
|
||||
def holderlistdir(dirpath):
|
||||
dirs = listDirectory(path.join(sysModules,dirpath,"holders"))
|
||||
return reduce(lambda x,y:x+[y]+holderlistdir(path.join(dirpath,
|
||||
"holders",y)),
|
||||
dirs, [])
|
||||
sysModules = '/sys/module'
|
||||
holderPath = lambda x: path.join(sysModules,x,"holders")
|
||||
refPath = lambda x: path.join(sysModules,x,"refcnt")
|
||||
self.loadModules = filter(lambda x: access(holderPath(x),R_OK) and
|
||||
access(refPath(x),R_OK),
|
||||
listDirectory(sysModules))
|
||||
self.useModules = map(lambda x:int(open(refPath(x),'r').read().strip()),
|
||||
self.loadModules)
|
||||
self.depModules = map(lambda x: holderlistdir(x),
|
||||
self.loadModules)
|
||||
|
||||
def getWorkModules(self,forceRemove=[],forceKeep=[]):
|
||||
"""Get work modules"""
|
||||
needModules = filter(lambda x:x[1] > len(x[2]),
|
||||
zip(self.loadModules,
|
||||
self.useModules,
|
||||
self.depModules))
|
||||
needModulesName = set(map(lambda x:x[0],needModules)+forceKeep)
|
||||
allModules = map(lambda x:x[0],
|
||||
filter(lambda x:set(x[1])&needModulesName,
|
||||
zip(self.loadModules,
|
||||
self.depModules)))
|
||||
reRemove = re.compile("|".join(forceRemove))
|
||||
return filter(lambda x: not reRemove.search(x),
|
||||
map(lambda x:x.replace("-","_"),
|
||||
allModules+list(needModulesName)))
|
||||
class InitRamFs:
|
||||
def __init__(self,initRamFsFile):
|
||||
self.initrdFile = initRamFsFile
|
||||
self.tmpPath = path.join('/tmp',path.basename(self.initrdFile))
|
||||
|
||||
def _unpackInitRamfs(self):
|
||||
"""Unpack initramfs"""
|
||||
self.prevDir = os.getcwd()
|
||||
if not path.exists(self.tmpPath):
|
||||
os.mkdir(self.tmpPath)
|
||||
os.chdir(self.tmpPath)
|
||||
cpioProcess = process("cpio", "-di")
|
||||
gzipInitrd = gzip.open(self.initrdFile,'r')
|
||||
cpioProcess.write(gzipInitrd.read())
|
||||
res = cpioProcess.success()
|
||||
os.chdir(self.prevDir)
|
||||
return res
|
||||
|
||||
def searchInside(self,searchFunc):
|
||||
"""Search data in file list of initramfs"""
|
||||
cpioProcess = process("cpio", "-tf",
|
||||
stdin=process("gzip", "-dc", self.initrdFile))
|
||||
return filter(searchFunc,cpioProcess)
|
||||
|
||||
def isModuleInside(self,moduleName):
|
||||
"""Search module in initramfs"""
|
||||
return bool(self.searchInside(lambda x: "%s.ko"%moduleName in x))
|
||||
|
||||
def _packInitRamfs(self,newInitramfsFile=None):
|
||||
"""Pack initramfs"""
|
||||
self.prevDir = os.getcwd()
|
||||
try:
|
||||
# get file list for pack
|
||||
fileList = reduce(lambda x,y: x
|
||||
+map(lambda z:path.join(y[0],z),y[1])
|
||||
+map(lambda z:path.join(y[0],z),y[2]),
|
||||
os.walk(self.tmpPath),
|
||||
[])
|
||||
fileList = map(lambda x:x[len(self.tmpPath)+1:],fileList)
|
||||
# change dir for cpio
|
||||
os.chdir(self.tmpPath)
|
||||
# create cpio process
|
||||
cpioProcess = process("cpio", "-o", "--quiet", "-H","newc")
|
||||
# send file list to cpio process
|
||||
cpioProcess.write("\n".join(fileList))
|
||||
cpioProcess.write("\n")
|
||||
# get result of cpio
|
||||
cpioData = cpioProcess.read()
|
||||
cpioRes = cpioProcess.returncode()
|
||||
except KeyboardInterrupt:
|
||||
os.chdir(self.prevDir)
|
||||
raise KeyboardInterrupt
|
||||
except Exception,e:
|
||||
print e.__repr__()
|
||||
cpioRes = 255
|
||||
finally:
|
||||
os.chdir(self.prevDir)
|
||||
if cpioRes != 0:
|
||||
return False
|
||||
# remove old initrd file
|
||||
if not newInitramfsFile:
|
||||
newInitramfsFile = self.initrdFile
|
||||
if path.exists(newInitramfsFile):
|
||||
os.unlink(newInitramfsFile)
|
||||
# pack and write new initrd file
|
||||
initrd = gzip.open(newInitramfsFile,'w')
|
||||
initrd.write(cpioData)
|
||||
initrd.close()
|
||||
return True
|
||||
|
||||
def cleanInitRamFs(self,newinitrd=None,video=None):
|
||||
"""Unpack initramfs clean and pack"""
|
||||
copy2(self.initrdFile,newinitrd)
|
||||
return True
|
@ -1,434 +0,0 @@
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2010-2012 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 soaplib, sys, time, os
|
||||
import threading
|
||||
|
||||
from soaplib.serializers.primitive import String, Integer, Any, Boolean
|
||||
from soaplib.serializers.clazz import Array
|
||||
from soaplib.service import rpc, DefinitionBase
|
||||
from calculate.core.server.api_types import ReturnedMessage,CommonInfo
|
||||
from calculate.core.server.api_types import ChoiceValue, Table, Option, Field, \
|
||||
GroupField, ViewInfo, ViewParams
|
||||
from calculate.lib.datavars import VariableError,DataVarsError
|
||||
from calculate.install.cl_install import InstallError
|
||||
|
||||
#from cl_install import Install,DataVarsInstall
|
||||
import cl_install
|
||||
from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate
|
||||
from calculate.core.server.decorators import Dec
|
||||
from calculate.core.server.func import catchExcept,commonView
|
||||
core_method = Dec.core_method
|
||||
setLocalTranslate('cl_install3',sys.modules[__name__])
|
||||
import traceback
|
||||
from functools import wraps,WRAPPER_ASSIGNMENTS
|
||||
|
||||
__ = getLazyLocalTranslate(_)
|
||||
|
||||
|
||||
class InstallInfo(CommonInfo):
|
||||
"""Parameters for method install"""
|
||||
cl_image_filename = String
|
||||
cl_image_new_only = Boolean
|
||||
cl_image_linux_shortname = String
|
||||
cl_image_arch_machine = String
|
||||
cl_image_linux_ver = String
|
||||
cl_image_linux_build = String
|
||||
|
||||
os_install_disk_single = String
|
||||
os_location_data = Array(Array(String))
|
||||
os_install_uefi_set = Boolean
|
||||
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_root_pwd = String
|
||||
cl_migrate_data = Array(Array(String))
|
||||
cl_autologin = 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
|
||||
os_install_net_dns = String
|
||||
os_install_net_dns_search = 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_grub_terminal = String
|
||||
os_audio_default = String
|
||||
|
||||
cl_autopartition_device = Array(String)
|
||||
cl_autopartition_scheme = Array(String)
|
||||
cl_autopartition_set = Boolean
|
||||
cl_autopartition_table = String
|
||||
cl_autopartition_root_size = String
|
||||
|
||||
cl_live = Boolean
|
||||
os_install_pxe = Boolean
|
||||
os_install_pxe_path = String
|
||||
|
||||
installCatchExcept = catchExcept(VariableError,DataVarsError,
|
||||
cl_install.InstallError)
|
||||
|
||||
class Wsdl:
|
||||
from calculate.core.server.baseClass import Basic
|
||||
from calculate.core.server.decorators import Dec
|
||||
|
||||
@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
@core_method(category=__('Installation'),title=__("System install"),
|
||||
image='calculate-install,system-installer,applications-other,'
|
||||
'drive-harddisk',
|
||||
gui=True,command='cl-install',
|
||||
rights=['install'])
|
||||
def install ( self, sid, info):
|
||||
return self.callMethod(sid,info,logicClass=cl_install.Install,
|
||||
method="installSystem",method_name="install",
|
||||
callbackRefresh=self.fixInstallLocalization)
|
||||
|
||||
def install_vars(self,dv=None):
|
||||
if not dv:
|
||||
dv = cl_install.DataVarsInstall()
|
||||
dv.importInstall()
|
||||
dv.flIniFile()
|
||||
dv.Set('cl_action','system',True)
|
||||
dv.Set('cl_dispatch_conf','usenew',True)
|
||||
dv.addGroup(_("Language and locale"),
|
||||
image="welcome",
|
||||
normal=('os_install_locale_lang','os_install_clock_timezone'))
|
||||
dv.addGroup(_("Distribution"),
|
||||
normal=('cl_image_filename',),
|
||||
expert=('cl_image_linux_shortname', 'cl_image_arch_machine','cl_image_new_only'))
|
||||
dv.addGroup(_("Allocate drive space"),
|
||||
normal=('cl_autopartition_set',),
|
||||
expert=('cl_autopartition_scheme','cl_autopartition_device',
|
||||
'cl_autopartition_table','cl_autopartition_root_size'),
|
||||
expert_label=_("Click to set up autopartition options"))
|
||||
dv.addGroup(_("Mount points"),
|
||||
normal=('os_location_data',),
|
||||
hide=('os_location_data','os_install_mbr','os_install_uefi_set'),
|
||||
brief_force=('os_location_brief_data','os_install_bootloader',
|
||||
'os_install_uefi_set'),
|
||||
expert=('os_install_scratch','cl_uuid_set',
|
||||
'os_install_root_type',
|
||||
'os_install_mbr',
|
||||
'os_install_uefi_set',
|
||||
'os_install_kernel_scheduler'))
|
||||
dv.addGroup(_("Network settings"),
|
||||
normal=('os_install_net_conf','os_install_net_data',
|
||||
'os_install_net_fqdn','os_install_ntp'),
|
||||
expert=('os_install_net_dns','os_install_net_dns_search',
|
||||
'os_install_net_route_data',))
|
||||
dv.addGroup(_("Users"),
|
||||
normal=('cl_migrate_root_pwd','cl_migrate_data','cl_autologin'),
|
||||
hide=('cl_migrate_data',),
|
||||
brief=('cl_migrate_user',))
|
||||
dv.addGroup(_("Audio"),
|
||||
normal=('os_audio_default',))
|
||||
dv.addGroup(_("Video"),
|
||||
normal=('os_install_x11_video_drv','os_install_x11_composite',
|
||||
'os_install_x11_resolution','os_install_fb_resolution',
|
||||
'os_install_grub_terminal'))
|
||||
dv.addBrief(next_label=_("Installation"),image="finish")
|
||||
return dv
|
||||
|
||||
def fixInstallLocalization(self,sid,dv):
|
||||
"""
|
||||
Fix localization on change lang in install method
|
||||
"""
|
||||
curThread = threading.currentThread()
|
||||
curThread.lang = dv.Get('os_install_locale_lang')
|
||||
currentLang = self.get_cache(sid,"install","lang")
|
||||
if currentLang != curThread.lang:
|
||||
dv.clearGroups()
|
||||
self.install_vars(dv)
|
||||
dv.reinit()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@rpc(Integer, ViewParams, _returns = ViewInfo)
|
||||
@installCatchExcept
|
||||
def install_view (self, sid, params):
|
||||
dv = self.get_cache(sid,"install","vars")
|
||||
if not dv:
|
||||
dv = self.install_vars()
|
||||
langChanged = False
|
||||
else:
|
||||
langChanged = self.fixInstallLocalization(sid,dv)
|
||||
lang = dv.Get('os_install_locale_lang')
|
||||
self.set_cache(sid,"install","lang",lang,smart=False)
|
||||
dv.processRefresh()
|
||||
self.set_cache(sid, 'install', "vars",dv,smart=False)
|
||||
view = ViewInfo(dv,viewparams=params,
|
||||
has_brief=True,
|
||||
allsteps=langChanged,
|
||||
brief_label=_("Start installing"))
|
||||
return view
|
||||
|
||||
def install_flash_vars(self):
|
||||
dv = cl_install.DataVarsInstall()
|
||||
dv.importInstall()
|
||||
dv.flIniFile()
|
||||
dv.Set('cl_action','system',True)
|
||||
dv.Set('cl_install_type','flash')
|
||||
dv.Set('cl_dispatch_conf','usenew',True)
|
||||
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))
|
||||
@core_method(category=__('Installation'),title=__('Flash install'),
|
||||
image='drive-removable-media-usb-pendrive,'
|
||||
'drive-removable-media-usb,media-flash',
|
||||
gui=True, rights=['install'])
|
||||
def install_flash ( self, sid, info):
|
||||
"""
|
||||
Install to flash
|
||||
"""
|
||||
return self.callMethod(sid,info,logicClass=cl_install.Install,
|
||||
method="installSystem",method_name="install_flash")
|
||||
|
||||
@rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
@installCatchExcept
|
||||
def install_flash_view (self, sid, params):
|
||||
return commonView(self,sid,params,"install_flash")
|
||||
|
||||
def install_pxe_vars(self):
|
||||
dv = cl_install.DataVarsInstall()
|
||||
dv.importInstall()
|
||||
dv.flIniFile()
|
||||
dv.Set('cl_action','system',True)
|
||||
dv.Set('os_install_pxe','on',True)
|
||||
dv.Set('cl_dispatch_conf','usenew',True)
|
||||
dv.addGroup(None,
|
||||
normal=('cl_image_filename',),
|
||||
expert=('os_install_pxe_path',),
|
||||
next_label=_("Install"))
|
||||
return dv
|
||||
|
||||
@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
@core_method(category=__('Installation'),title=__('PXE install'),
|
||||
image='network-server,preferences-desktop-remote-desktop',
|
||||
command='cl-install-pxe',
|
||||
gui=True, rights=['installpxe'])
|
||||
def install_pxe ( self, sid, info):
|
||||
"""
|
||||
Install to flash
|
||||
"""
|
||||
return self.callMethod(sid,info,logicClass=cl_install.Install,
|
||||
method="installSystem",method_name="install_pxe")
|
||||
|
||||
@rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
@installCatchExcept
|
||||
def install_pxe_view (self, sid, params):
|
||||
return commonView(self,sid,params,"install_pxe")
|
||||
|
||||
def setup_network_vars(self):
|
||||
dv = cl_install.DataVarsInstall()
|
||||
dv.importInstall()
|
||||
dv.flIniFile()
|
||||
dv.Set('cl_action','merge',True)
|
||||
dv.Set('cl_merge_pkg',[None],True)
|
||||
dv.Set('cl_merge_set',"on",True)
|
||||
dv.Set('cl_setup','network',True)
|
||||
dv.addGroup(None,
|
||||
normal=('os_install_net_conf','os_install_net_data',
|
||||
'os_install_net_fqdn','os_install_ntp'),
|
||||
expert=('os_install_net_dns','os_install_net_dns_search',
|
||||
'os_install_net_route_data',
|
||||
'cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
next_label=_("Save"))
|
||||
return dv
|
||||
|
||||
@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
@core_method(category=__('Configuration'),title=__('Network'),
|
||||
image='gnome-network-properties,'
|
||||
'network-idle,preferences-system-network',
|
||||
command="cl-setup-network",
|
||||
gui=True, rights=['setup'])
|
||||
def setup_network ( self, sid, info):
|
||||
"""
|
||||
Setup network
|
||||
"""
|
||||
return self.callMethod(sid,info,logicClass=cl_install.Install,
|
||||
method="setupSystem",method_name="setup_network")
|
||||
|
||||
@rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
@installCatchExcept
|
||||
def setup_network_view (self, sid, params):
|
||||
return commonView(self,sid,params,"setup_network")
|
||||
|
||||
def setup_video_vars(self):
|
||||
dv = cl_install.DataVarsInstall()
|
||||
dv.importInstall()
|
||||
dv.flIniFile()
|
||||
dv.Set('cl_action','merge',True)
|
||||
dv.Set('cl_merge_pkg',[None],True)
|
||||
dv.Set('cl_merge_set',"on",True)
|
||||
dv.Set('cl_setup','video',True)
|
||||
dv.addGroup(None,
|
||||
normal=('os_install_x11_video_drv', 'os_install_x11_resolution',
|
||||
'os_install_x11_composite', 'os_install_fb_resolution'),
|
||||
expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
next_label=_("Save"))
|
||||
return dv
|
||||
|
||||
@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
@core_method(category=__('Configuration'),title=__('Video'),
|
||||
image='video-display,gnome-multimedia',
|
||||
command="cl-setup-video",
|
||||
gui=True, rights=['setup'])
|
||||
def setup_video ( self, sid, info):
|
||||
"""
|
||||
Setup video
|
||||
"""
|
||||
return self.callMethod(sid,info,logicClass=cl_install.Install,
|
||||
method="setupSystem",method_name="setup_video")
|
||||
|
||||
@rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
@installCatchExcept
|
||||
def setup_video_view (self, sid, params):
|
||||
return commonView(self,sid,params,"setup_video")
|
||||
|
||||
def setup_locale_vars(self):
|
||||
dv = cl_install.DataVarsInstall()
|
||||
dv.importInstall()
|
||||
dv.flIniFile()
|
||||
dv.Set('cl_action','merge',True)
|
||||
dv.Set('cl_merge_pkg',[None],True)
|
||||
dv.Set('cl_merge_set',"on",True)
|
||||
dv.Set('cl_setup','locale',True)
|
||||
dv.addGroup(None,
|
||||
normal=('os_install_locale_lang',
|
||||
'os_install_clock_timezone'),
|
||||
expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
next_label=_("Save"))
|
||||
return dv
|
||||
|
||||
@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
@core_method(category=__('Configuration'),title=__('Locale'),
|
||||
image='locale,preferences-desktop-locale',
|
||||
command="cl-setup-locale",
|
||||
gui=True, rights=['setup'])
|
||||
def setup_locale ( self, sid, info):
|
||||
"""
|
||||
Setup locale
|
||||
"""
|
||||
return self.callMethod(sid,info,logicClass=cl_install.Install,
|
||||
method="setupSystem",method_name="setup_locale")
|
||||
|
||||
@rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
@installCatchExcept
|
||||
def setup_locale_view (self, sid, params):
|
||||
return commonView(self,sid,params,"setup_locale")
|
||||
|
||||
def setup_boot_vars(self):
|
||||
dv = cl_install.DataVarsInstall()
|
||||
dv.importInstall()
|
||||
dv.flIniFile()
|
||||
dv.Set('cl_action','merge',True)
|
||||
dv.Set('cl_merge_pkg',[None],True)
|
||||
dv.Set('cl_merge_set',"on",True)
|
||||
dv.Set('cl_setup','boot',True)
|
||||
dv.addGroup(None,
|
||||
normal=('os_install_mbr','os_install_uefi_set',
|
||||
'os_install_kernel_scheduler','os_install_grub_terminal'),
|
||||
expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
next_label=_("Save"))
|
||||
return dv
|
||||
|
||||
@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
@core_method(category=__('Configuration'),title=__('Boot'),
|
||||
image='stock_save,drive-harddisk',command="cl-setup-boot",
|
||||
gui=True, rights=['setup'])
|
||||
def setup_boot ( self, sid, info):
|
||||
"""
|
||||
Setup locale
|
||||
"""
|
||||
return self.callMethod(sid,info,logicClass=cl_install.Install,
|
||||
method="setupSystem",method_name="setup_boot")
|
||||
|
||||
@rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
@installCatchExcept
|
||||
def setup_boot_view (self, sid, params):
|
||||
return commonView(self,sid,params,"setup_boot")
|
||||
|
||||
def setup_system_vars(self):
|
||||
dv = cl_install.DataVarsInstall()
|
||||
dv.importInstall()
|
||||
dv.flIniFile()
|
||||
dv.Set('cl_action','merge',True)
|
||||
dv.Set('cl_live','off')
|
||||
dv.addGroup(None,
|
||||
normal=("cl_live",),
|
||||
expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
next_label=_("Reconfigure"))
|
||||
return dv
|
||||
|
||||
@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
@core_method(category=__('Configuration'),title=__('System'),
|
||||
image='system-run,system,computer',command="cl-setup-system",
|
||||
gui=True, rights=['setup'])
|
||||
def setup_system ( self, sid, info):
|
||||
"""
|
||||
Setup system
|
||||
"""
|
||||
return self.callMethod(sid,info,logicClass=cl_install.Install,
|
||||
method="setupSystem",method_name="setup_system")
|
||||
|
||||
@rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
@installCatchExcept
|
||||
def setup_system_view (self, sid, params):
|
||||
return commonView(self,sid,params,"setup_system")
|
||||
|
||||
def setup_audio_vars(self):
|
||||
dv = cl_install.DataVarsInstall()
|
||||
dv.importInstall()
|
||||
dv.flIniFile()
|
||||
dv.Set('cl_action','merge',True)
|
||||
dv.Set('cl_merge_pkg',[None],True)
|
||||
dv.Set('cl_merge_set',"on",True)
|
||||
dv.Set('cl_setup','audio',True)
|
||||
dv.addGroup(None,
|
||||
normal=('os_audio_default',),
|
||||
expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
next_label=_("Save"))
|
||||
return dv
|
||||
|
||||
@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
@core_method(category=__('Configuration'),title=__('Audio'),
|
||||
image='audio-card',command="cl-setup-audio",
|
||||
gui=True, rights=['setup'])
|
||||
def setup_audio ( self, sid, info):
|
||||
"""
|
||||
Setup locale
|
||||
"""
|
||||
return self.callMethod(sid,info,logicClass=cl_install.Install,
|
||||
method="setupSystem",method_name="setup_audio")
|
||||
|
||||
@rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
@installCatchExcept
|
||||
def setup_audio_view (self, sid, params):
|
||||
return commonView(self,sid,params,"setup_audio")
|
@ -0,0 +1,400 @@
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2010-2012 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 sys, time, os
|
||||
|
||||
from calculate.lib.datavars import VariableError,DataVarsError,DataVars
|
||||
from calculate.install.install import InstallError
|
||||
|
||||
import install
|
||||
from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate
|
||||
setLocalTranslate('cl_install3',sys.modules[__name__])
|
||||
__ = getLazyLocalTranslate(_)
|
||||
|
||||
from calculate.core.server.func import WsdlBase
|
||||
from calculate.install.utils.cl_install import ClInstallAction
|
||||
from calculate.install.utils.cl_setup import ClSetupAudioAction
|
||||
|
||||
|
||||
# def setup_network_vars(self):
|
||||
# dv = install.DataVarsInstall()
|
||||
# dv.importInstall()
|
||||
# dv.flIniFile()
|
||||
# dv.Set('cl_action','merge',True)
|
||||
# dv.Set('cl_merge_pkg',[None],True)
|
||||
# dv.Set('cl_merge_set',"on",True)
|
||||
# dv.Set('cl_setup','network',True)
|
||||
# dv.addGroup(None,
|
||||
# normal=('os_install_net_conf','os_install_net_data',
|
||||
# 'os_install_net_fqdn','os_install_ntp'),
|
||||
# expert=('os_install_net_dns','os_install_net_dns_search',
|
||||
# 'os_install_net_route_data',
|
||||
# 'cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
# next_label=_("Save"))
|
||||
# return dv
|
||||
#
|
||||
# @rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
# @core_method(category=__('Configuration'),title=__('Network'),
|
||||
# image='gnome-network-properties,'
|
||||
# 'network-idle,preferences-system-network',
|
||||
# command="cl-setup-network",
|
||||
# gui=True, rights=['setup'])
|
||||
# def setup_network ( self, sid, info):
|
||||
# """
|
||||
# Setup network
|
||||
# """
|
||||
# return self.callMethod(sid,info,logicClass=install.Install,
|
||||
# method="setupSystem",method_name="setup_network")
|
||||
#
|
||||
# @rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
# @installCatchExcept
|
||||
# def setup_network_view (self, sid, params):
|
||||
# return commonView(self,sid,params,"setup_network")
|
||||
#
|
||||
# def setup_video_vars(self):
|
||||
# dv = install.DataVarsInstall()
|
||||
# dv.importInstall()
|
||||
# dv.flIniFile()
|
||||
# dv.Set('cl_action','merge',True)
|
||||
# dv.Set('cl_merge_pkg',[None],True)
|
||||
# dv.Set('cl_merge_set',"on",True)
|
||||
# dv.Set('cl_setup','video',True)
|
||||
# dv.addGroup(None,
|
||||
# normal=('os_install_x11_video_drv', 'os_install_x11_resolution',
|
||||
# 'os_install_x11_composite', 'os_install_fb_resolution'),
|
||||
# expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
# next_label=_("Save"))
|
||||
# return dv
|
||||
#
|
||||
# @rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
# @core_method(category=__('Configuration'),title=__('Video'),
|
||||
# image='video-display,gnome-multimedia',
|
||||
# command="cl-setup-video",
|
||||
# gui=True, rights=['setup'])
|
||||
# def setup_video ( self, sid, info):
|
||||
# """
|
||||
# Setup video
|
||||
# """
|
||||
# return self.callMethod(sid,info,logicClass=install.Install,
|
||||
# method="setupSystem",method_name="setup_video")
|
||||
#
|
||||
# @rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
# @installCatchExcept
|
||||
# def setup_video_view (self, sid, params):
|
||||
# return commonView(self,sid,params,"setup_video")
|
||||
#
|
||||
# def setup_locale_vars(self):
|
||||
# dv = install.DataVarsInstall()
|
||||
# dv.importInstall()
|
||||
# dv.flIniFile()
|
||||
# dv.Set('cl_action','merge',True)
|
||||
# dv.Set('cl_merge_pkg',[None],True)
|
||||
# dv.Set('cl_merge_set',"on",True)
|
||||
# dv.Set('cl_setup','locale',True)
|
||||
# dv.addGroup(None,
|
||||
# normal=('os_install_locale_lang',
|
||||
# 'os_install_clock_timezone'),
|
||||
# expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
# next_label=_("Save"))
|
||||
# return dv
|
||||
#
|
||||
# @rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
# @core_method(category=__('Configuration'),title=__('Locale'),
|
||||
# image='locale,preferences-desktop-locale',
|
||||
# command="cl-setup-locale",
|
||||
# gui=True, rights=['setup'])
|
||||
# def setup_locale ( self, sid, info):
|
||||
# """
|
||||
# Setup locale
|
||||
# """
|
||||
# return self.callMethod(sid,info,logicClass=install.Install,
|
||||
# method="setupSystem",method_name="setup_locale")
|
||||
#
|
||||
# @rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
# @installCatchExcept
|
||||
# def setup_locale_view (self, sid, params):
|
||||
# return commonView(self,sid,params,"setup_locale")
|
||||
#
|
||||
# def setup_boot_vars(self):
|
||||
# dv = install.DataVarsInstall()
|
||||
# dv.importInstall()
|
||||
# dv.flIniFile()
|
||||
# dv.Set('cl_action','merge',True)
|
||||
# dv.Set('cl_merge_pkg',[None],True)
|
||||
# dv.Set('cl_merge_set',"on",True)
|
||||
# dv.Set('cl_setup','boot',True)
|
||||
# dv.addGroup(None,
|
||||
# normal=('os_install_mbr','os_install_uefi_set',
|
||||
# 'os_install_kernel_scheduler','os_install_grub_terminal'),
|
||||
# expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
# next_label=_("Save"))
|
||||
# return dv
|
||||
#
|
||||
# @rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
# @core_method(category=__('Configuration'),title=__('Boot'),
|
||||
# image='stock_save,drive-harddisk',command="cl-setup-boot",
|
||||
# gui=True, rights=['setup'])
|
||||
# def setup_boot ( self, sid, info):
|
||||
# """
|
||||
# Setup locale
|
||||
# """
|
||||
# return self.callMethod(sid,info,logicClass=install.Install,
|
||||
# method="setupSystem",method_name="setup_boot")
|
||||
#
|
||||
# @rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
# @installCatchExcept
|
||||
# def setup_boot_view (self, sid, params):
|
||||
# return commonView(self,sid,params,"setup_boot")
|
||||
#
|
||||
# def setup_system_vars(self):
|
||||
# dv = install.DataVarsInstall()
|
||||
# dv.importInstall()
|
||||
# dv.flIniFile()
|
||||
# dv.Set('cl_action','merge',True)
|
||||
# dv.Set('cl_live','off')
|
||||
# dv.addGroup(None,
|
||||
# normal=("cl_live",),
|
||||
# expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
# next_label=_("Reconfigure"))
|
||||
# return dv
|
||||
#
|
||||
# @rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
# @core_method(category=__('Configuration'),title=__('System'),
|
||||
# image='system-run,system,computer',command="cl-setup-system",
|
||||
# gui=True, rights=['setup'])
|
||||
# def setup_system ( self, sid, info):
|
||||
# """
|
||||
# Setup system
|
||||
# """
|
||||
# return self.callMethod(sid,info,logicClass=install.Install,
|
||||
# method="setupSystem",method_name="setup_system")
|
||||
#
|
||||
# @rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
# @installCatchExcept
|
||||
# def setup_system_view (self, sid, params):
|
||||
# return commonView(self,sid,params,"setup_system")
|
||||
#
|
||||
# def setup_audio_vars(self):
|
||||
# dv = install.DataVarsInstall()
|
||||
# dv.importInstall()
|
||||
# dv.flIniFile()
|
||||
# dv.Set('cl_action','merge',True)
|
||||
# dv.Set('cl_merge_pkg',[None],True)
|
||||
# dv.Set('cl_merge_set',"on",True)
|
||||
# dv.Set('cl_setup','audio',True)
|
||||
# dv.addGroup(None,
|
||||
# normal=('os_audio_default',),
|
||||
# expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
# next_label=_("Save"))
|
||||
# return dv
|
||||
#
|
||||
# @rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
# @core_method(category=__('Configuration'),title=__('Audio'),
|
||||
# image='audio-card',command="cl-setup-audio",
|
||||
# gui=True, rights=['setup'])
|
||||
# def setup_audio ( self, sid, info):
|
||||
# """
|
||||
# Setup locale
|
||||
# """
|
||||
# return self.callMethod(sid,info,logicClass=install.Install,
|
||||
# method="setupSystem",method_name="setup_audio")
|
||||
#
|
||||
# @rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
# @installCatchExcept
|
||||
# def setup_audio_view (self, sid, params):
|
||||
# return commonView(self,sid,params,"setup_audio")
|
||||
|
||||
class Wsdl(WsdlBase):
|
||||
methods = [{
|
||||
# идентификатор метода
|
||||
'method_name':"install",
|
||||
# категория метода
|
||||
'category':__("Installation"),
|
||||
# заголовок метода
|
||||
'title':__("System install"),
|
||||
# иконка для графической консоли
|
||||
'image':'calculate-install,system-installer,applications-other,'\
|
||||
'drive-harddisk',
|
||||
# метод присутствует в графической консоли
|
||||
'gui':True,
|
||||
# консольная команда
|
||||
'command':'cl-install',
|
||||
# права для запуска метода
|
||||
'rights':['install'],
|
||||
# объект содержащий модули для действия
|
||||
'logic':{'Install':install.Install},
|
||||
# описание действия
|
||||
'action':ClInstallAction,
|
||||
# объект переменных
|
||||
'datavars':"install",
|
||||
'native_error':(VariableError,DataVarsError, install.InstallError),
|
||||
# значения по умолчанию для переменных этого метода
|
||||
'setvars':{'cl_action!':'system','cl_dispatch_conf':'usenew'},
|
||||
# описание груп (список лямбда функций)
|
||||
'groups': [
|
||||
lambda group:group(_("Language and locale"),
|
||||
image="welcome",
|
||||
normal=('os_install_locale_lang','os_install_clock_timezone')),
|
||||
lambda group:group(_("Distribution"),
|
||||
normal=('cl_image_filename',),
|
||||
expert=('cl_image_linux_shortname', 'cl_image_arch_machine',
|
||||
'cl_image_new_only')),
|
||||
lambda group:group(_("Allocate drive space"),
|
||||
normal=('cl_autopartition_set',),
|
||||
expert=('cl_autopartition_scheme','cl_autopartition_device',
|
||||
'cl_autopartition_table','cl_autopartition_root_size'),
|
||||
expert_label=_("Click to set up autopartition options")),
|
||||
lambda group:group(_("Mount points"),
|
||||
normal=('os_location_data',),
|
||||
hide=('os_location_data','os_install_mbr','os_install_uefi_set'),
|
||||
brief_force=('os_location_brief_data','os_install_bootloader',
|
||||
'os_install_uefi_set'),
|
||||
expert=('os_install_scratch','cl_uuid_set',
|
||||
'os_install_root_type',
|
||||
'os_install_mbr',
|
||||
'os_install_uefi_set',
|
||||
'os_install_kernel_scheduler')),
|
||||
lambda group:group(_("Network settings"),
|
||||
normal=('os_install_net_conf','os_install_net_data',
|
||||
'os_install_net_fqdn','os_install_ntp'),
|
||||
expert=('os_install_net_dns','os_install_net_dns_search',
|
||||
'os_install_net_route_data')),
|
||||
lambda group:group(_("Users"),
|
||||
normal=('cl_migrate_root_pwd','cl_migrate_data','cl_autologin'),
|
||||
hide=('cl_migrate_data',),
|
||||
brief=('cl_migrate_user',)),
|
||||
lambda group:group(_("Audio"),
|
||||
normal=('os_audio_default',)),
|
||||
lambda group:group(_("Video"),
|
||||
normal=('os_install_x11_video_drv','os_install_x11_composite',
|
||||
'os_install_x11_resolution','os_install_fb_resolution',
|
||||
'os_install_grub_terminal'))],
|
||||
# действие выводит информацию перед запуском
|
||||
'brief':{'next':__("Installation"),
|
||||
'image':'finish',
|
||||
'name':__("Start installing")}},
|
||||
# установка на Flash
|
||||
{
|
||||
'method_name':"install_flash",
|
||||
'category':__("Installation"),
|
||||
'title':__("Flash install"),
|
||||
'image':'drive-removable-media-usb-pendrive,'\
|
||||
'drive-removable-media-usb,media-flash',
|
||||
'gui':True,
|
||||
'rights':['install'],
|
||||
'logic':{'Install':install.Install},
|
||||
'action':ClInstallAction,
|
||||
'datavars':"install",
|
||||
'native_error':(VariableError,DataVarsError,install.InstallError),
|
||||
'setvars':{'cl_action!':'system','cl_install_type':'flash',
|
||||
'cl_dispatch_conf':'usenew'},
|
||||
'groups':[
|
||||
lambda group:group(_("Flash install"),
|
||||
normal=('os_install_disk_single','cl_image_filename'),
|
||||
expert=('os_location_data',),
|
||||
next_label=_("Install"))]},
|
||||
# PXE установка
|
||||
{
|
||||
'method_name':"install_pxe",
|
||||
'category':__("Installation"),
|
||||
'title':__("PXE install"),
|
||||
'image':'network-server,preferences-desktop-remote-desktop',
|
||||
'command':'cl-install-pxe',
|
||||
'gui':True,
|
||||
'rights':['installpxe'],
|
||||
'logic':{'Install':install.Install},
|
||||
'action':ClInstallAction,
|
||||
'datavars':"install",
|
||||
'native_error':(VariableError,DataVarsError,install.InstallError),
|
||||
'setvars':{'cl_action!':'system','os_install_pxe!':'on',
|
||||
'cl_dispatch_conf':'usenew'},
|
||||
'groups':[
|
||||
lambda group:group(_("PXE install"),
|
||||
normal=('cl_image_filename',),
|
||||
expert=('os_install_pxe_path',),
|
||||
next_label=_("Install"))]},
|
||||
# настройка аудио
|
||||
{
|
||||
'method_name':"setup_audio",
|
||||
'category':__("Configuration"),
|
||||
'title':__("Audio"),
|
||||
'image':'audio-card',
|
||||
'command':'cl-setup-audio',
|
||||
'gui':True,
|
||||
'rights':['setupaudio'],
|
||||
'logic':{'Install':install.Install},
|
||||
'action':ClSetupAudioAction,
|
||||
'datavars':"install",
|
||||
'native_error':(VariableError,DataVarsError,install.InstallError),
|
||||
'setvars':{'cl_action!':'merge','cl_merge_pkg!':[None],
|
||||
'cl_merge_set!':"on",'cl_setup!':'audio'},
|
||||
'groups':[
|
||||
lambda group:group(_("Audio"),
|
||||
normal=('os_audio_default',),
|
||||
expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
next_label=_("Save"))]},
|
||||
{
|
||||
# настройка локали
|
||||
'method_name':"setup_locale",
|
||||
'category':__("Configuration"),
|
||||
'title':__("Locale"),
|
||||
'image':'locale,preferences-desktop-locale',
|
||||
'command':'cl-setup-locale',
|
||||
'gui':True,
|
||||
'rights':['setuplocale'],
|
||||
'logic':{'Install':install.Install},
|
||||
'action':ClSetupLocaleAction,
|
||||
'datavars':"install",
|
||||
'native_error':(VariableError,DataVarsError,install.InstallError),
|
||||
'setvars':{'cl_action!':'merge','cl_merge_pkg!':[None],
|
||||
'cl_merge_set!':"on",'cl_setup!':'locale'},
|
||||
'groups':[
|
||||
lambda group:group(_("Locale"),
|
||||
normal=('os_install_locale_lang',
|
||||
'os_install_clock_timezone'),
|
||||
expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
next_label=_("Save"))]}]
|
||||
|
||||
|
||||
# def setup_audio_vars(self):
|
||||
# dv = install.DataVarsInstall()
|
||||
# dv.importInstall()
|
||||
# dv.flIniFile()
|
||||
# dv.Set('cl_action','merge',True)
|
||||
# dv.Set('cl_merge_pkg',[None],True)
|
||||
# dv.Set('cl_merge_set',"on",True)
|
||||
# dv.Set('cl_setup','audio',True)
|
||||
# dv.addGroup(None,
|
||||
# normal=('os_audio_default',),
|
||||
# expert=('cl_templates_locate',"cl_dispatch_conf","cl_verbose_set"),
|
||||
# next_label=_("Save"))
|
||||
# return dv
|
||||
#
|
||||
# @rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
# @core_method(category=__('Configuration'),title=__('Audio'),
|
||||
# image='audio-card',command="cl-setup-audio",
|
||||
# gui=True, rights=['setup'])
|
||||
# def setup_audio ( self, sid, info):
|
||||
# """
|
||||
# Setup locale
|
||||
# """
|
||||
# return self.callMethod(sid,info,logicClass=install.Install,
|
||||
# method="setupSystem",method_name="setup_audio")
|
||||
#
|
||||
# @rpc(Integer, ViewParams,_returns = ViewInfo)
|
||||
# @installCatchExcept
|
||||
# def setup_audio_view (self, sid, params):
|
||||
# return commonView(self,sid,params,"setup_audio")
|
Loading…
Reference in new issue