You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
8.0 KiB
226 lines
8.0 KiB
#-*- 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, ClassSerializer
|
|
from soaplib.service import rpc, DefinitionBase
|
|
|
|
from cl_install import Install
|
|
import cl_install
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
from calculate.api.server.decorators import Dec
|
|
setLocalTranslate('cl_install',sys.modules[__name__])
|
|
|
|
##########API########################
|
|
class ChoiceValue(ClassSerializer):
|
|
values = Array(String)
|
|
comments = Array(String)
|
|
typefield = String
|
|
|
|
class Table(ClassSerializer):
|
|
head = Array(String)
|
|
body = Array(Array(String))
|
|
values = Array(ChoiceValue)
|
|
|
|
class Option(ClassSerializer):
|
|
shortopt = String
|
|
longopt = String
|
|
metavalue = String
|
|
help = String
|
|
|
|
class Field(ClassSerializer):
|
|
name = String
|
|
label = String
|
|
type = String
|
|
opt = Option
|
|
help = String
|
|
element = String
|
|
choice = ChoiceValue
|
|
default = String
|
|
value = String
|
|
tablevalue = Table
|
|
listvalue = Array(String)
|
|
|
|
class GroupField(ClassSerializer):
|
|
name = String
|
|
fields = Array(Field)
|
|
nextlabel = String
|
|
last = Boolean
|
|
|
|
class ViewInfo(ClassSerializer):
|
|
groups = Array(GroupField)
|
|
########################################
|
|
|
|
class InstallInfo(ClassSerializer):
|
|
"""Parameters for method install"""
|
|
disk = Array(Array(String))
|
|
mbr = Array(String)
|
|
type = String
|
|
nouuid = Boolean
|
|
iso = String
|
|
system = String
|
|
march = String
|
|
build = Boolean
|
|
lang = String
|
|
user = Array(String)
|
|
autologin = String
|
|
password = Array(String)
|
|
hostname = String
|
|
netconf = String
|
|
dhcp = Array(String)
|
|
ip = Array(String)
|
|
route = Array(Array(String))
|
|
dns = Array(String)
|
|
proxy = String
|
|
ntp = String
|
|
video = String
|
|
xorgres = String
|
|
fbres = String
|
|
timezone = String
|
|
default = Array(String)
|
|
|
|
class ReturnedMessage(ClassSerializer):
|
|
"""type (error,warning,pid)"""
|
|
type = String
|
|
name = String
|
|
message = String
|
|
|
|
class Wsdl:
|
|
|
|
@rpc(Integer,InstallInfo,Boolean,_returns=Array(ReturnedMessage))
|
|
#@wsdl_server.check_permissions(["install"])
|
|
#@Basic.cache
|
|
#@Basic.console('cl-install')
|
|
#@Basic.gui('System.Install')
|
|
def install_system(self,sid,param,onlycheck):
|
|
reload(cl_install)
|
|
install = cl_install.Install()
|
|
install.initVars()
|
|
errors = []
|
|
for err in install.checkInstallParam(param.disk,
|
|
param.mbr,
|
|
param.type,
|
|
param.build):
|
|
errors.append(ReturnedMessage(
|
|
type="error",
|
|
name=err[0],
|
|
message=err[1]))
|
|
if not onlycheck and not errors:
|
|
install.installSystem(param.disk,param.mbr,param.type,param.build)
|
|
return errors
|
|
|
|
def getPartitionInfo(self,install):
|
|
MOUNTPOINT,DEVICE,MAKEFORMAT,FORMAT,LABLE,SIZE = 0,1,2,3,4,5
|
|
installTable = install.getCurrentPartitioning()
|
|
table = Table(head = installTable['head'],
|
|
body = installTable['body'],
|
|
values = [])
|
|
table.values.append(ChoiceValue(
|
|
values=install.clVars.Get('os_disk_dev'),
|
|
comments = map(lambda x:"%s - %s - %s"%
|
|
(x[DEVICE],x[FORMAT],x[SIZE]),
|
|
installTable['body']),
|
|
type="choice"))
|
|
table.values.append(ChoiceValue(
|
|
type="string"))
|
|
table.values.append(ChoiceValue(
|
|
values=install.clVars.Get('os_format_type'),
|
|
type="choice"))
|
|
table.values.append(ChoiceValue(
|
|
values=[_("yes"),_("no")],
|
|
type="choice"))
|
|
return table
|
|
|
|
def getDeviceChoice(self,clVars):
|
|
"""Get choice value for device"""
|
|
deviceDevName = map(lambda x:"%s (%s)"%(x[0],x[1]),
|
|
clVars.zipVars('os_device_name','os_device_dev'))
|
|
return ChoiceValue(
|
|
values = clVars.Get('os_device_dev')+["off"],
|
|
comments = deviceDevName + [_("off")])
|
|
|
|
def getDeviceTypesChoice(self):
|
|
return ChoiceValue(values = ["hdd","usb-hdd","flash"],
|
|
comments = [_("Hard disk"), _("USB Hard disk"),
|
|
_("USB Flash")])
|
|
|
|
@rpc(Integer,Integer,_returns=ViewInfo)
|
|
#@check_permissions('cl_install')
|
|
def install_system_view(self,sid,page):
|
|
threading.currentThread().lang = "ru"
|
|
view = ViewInfo(groups=[])
|
|
install = Install()
|
|
install.initVars()
|
|
|
|
if page is None or page == 0:
|
|
group = GroupField(name=_("Partitioning"),nextlabel=_("Next"))
|
|
group.fields = []
|
|
group.fields.append(Field(
|
|
name = "disk",
|
|
label = _("Mount points"),
|
|
type = "table",
|
|
opt = Option(shortopt="-d",
|
|
longopt="--disk",
|
|
metavalue="DISK[:[DIR:FILESYSTEM:OPTIONS]]"),
|
|
help = \
|
|
_("DISK for installation, will be mounted to DIR. DIR set "
|
|
"to 'none' will cancel the mount point transfer. For "
|
|
"creating bind mount point you have to specify the "
|
|
"source directory as DISK"),
|
|
element = "table",
|
|
tablevalue = self.getPartitionInfo(install)))
|
|
group.fields.append(Field(
|
|
name = "mbr",
|
|
label = _("MBR"),
|
|
type = "list",
|
|
opt = Option(longopt="--mbr",
|
|
metavalue="MBR"),
|
|
help = \
|
|
_("boot disk for the system bound for install (for "
|
|
"recording MBR), off - disable MBR writing"),
|
|
element = "select",
|
|
listvalue = install.clVars.Get('os_install_mbr'),
|
|
choice = self.getDeviceChoice(install.clVars)))
|
|
group.fields.append(Field(
|
|
name = "type",
|
|
label = _("Device type"),
|
|
type = "string",
|
|
opt = Option(longopt="--type",
|
|
metavalue="MBR"),
|
|
help = \
|
|
_("device type for the system bound for install"),
|
|
element = "choice",
|
|
value = install.clVars.Get('os_install_root_type'),
|
|
choice = self.getDeviceTypesChoice()))
|
|
view.groups.append(group)
|
|
if page is None or page == 1:
|
|
group = GroupField(name=_("System"),last=True,nextlable=_("Install"))
|
|
group.fields = []
|
|
group.fields.append(Field(
|
|
name = "build",
|
|
label = _("Builder mode"),
|
|
type = "boolean",
|
|
opt = Option(longopt="--build"),
|
|
help = \
|
|
_("installation for assemble"),
|
|
value = install.clVars.Get('os_install_scratch'),
|
|
element = "checkbox"))
|
|
view.groups.append(group)
|
|
return view
|