|
|
|
@ -22,182 +22,29 @@ 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
|
|
|
|
|
#from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
|
#setLocalTranslate('cl_install',sys.modules[__name__])
|
|
|
|
|
from calculate.api.server.api_types import ReturnedMessage
|
|
|
|
|
|
|
|
|
|
from calculate.api.server.baseClass import Basic
|
|
|
|
|
##########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 = Array(String)
|
|
|
|
|
#default = String
|
|
|
|
|
#value = String
|
|
|
|
|
#tablevalue = Table
|
|
|
|
|
|
|
|
|
|
#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 FieldError(ClassSerializer):
|
|
|
|
|
#field = String
|
|
|
|
|
#error = String
|
|
|
|
|
|
|
|
|
|
#class NewType (ClassSerializer):
|
|
|
|
|
#helper = Integer
|
|
|
|
|
#value = Any
|
|
|
|
|
|
|
|
|
|
#class UserInfo (ClassSerializer):
|
|
|
|
|
#name = String
|
|
|
|
|
#surname = String
|
|
|
|
|
|
|
|
|
|
#class UserInfoValue (ClassSerializer):
|
|
|
|
|
#table = UserInfo
|
|
|
|
|
|
|
|
|
|
#class GroupInfo (ClassSerializer):
|
|
|
|
|
#name = String
|
|
|
|
|
#gid = Integer
|
|
|
|
|
|
|
|
|
|
#class SH (ClassSerializer):
|
|
|
|
|
#name = String
|
|
|
|
|
#times = Integer
|
|
|
|
|
|
|
|
|
|
#def __init__(self, name):
|
|
|
|
|
# self.name = name
|
|
|
|
|
#def __cmp__(self, other):
|
|
|
|
|
# return cmp(self.name, other.name)
|
|
|
|
|
#def __copy__(self):
|
|
|
|
|
# print '__copy__()'
|
|
|
|
|
# return MyClass(self.name)
|
|
|
|
|
#def __deepcopy__(self, memo):
|
|
|
|
|
# print '__deepcopy__(%s)' % str(memo)
|
|
|
|
|
# #import ipdb
|
|
|
|
|
# #ipdb.set_trace()
|
|
|
|
|
# import copy
|
|
|
|
|
# return SH(copy.deepcopy(self.name, memo))
|
|
|
|
|
|
|
|
|
|
class ApiWsdl:
|
|
|
|
|
|
|
|
|
|
def cl_template_meth (self, args) :
|
|
|
|
|
try:
|
|
|
|
|
#result = os.popen('cl-template '+args).read()
|
|
|
|
|
#self.startTask("cl_template task start")
|
|
|
|
|
a = ['cl-template']+args.split()
|
|
|
|
|
try:
|
|
|
|
|
#for line in os.popen(cmd).readlines():
|
|
|
|
|
p = subprocess.Popen(a, stdout = subprocess.PIPE, \
|
|
|
|
|
stderr = subprocess.PIPE)
|
|
|
|
|
for line in p.stdout.readlines():
|
|
|
|
|
#try:
|
|
|
|
|
#line = unicode(line)
|
|
|
|
|
line = line.replace('\x1b[1;33m','')
|
|
|
|
|
line = line.replace('\x1b[0m','')
|
|
|
|
|
#line = line[19:]
|
|
|
|
|
self.addMessage(type = 'normal', message = line)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for line in p.stderr.readlines():
|
|
|
|
|
self.addMessage(type = 'normal', message = line)
|
|
|
|
|
#except:
|
|
|
|
|
#print "========>>",line
|
|
|
|
|
#pass
|
|
|
|
|
#result = os.popen('ls -la').read()
|
|
|
|
|
|
|
|
|
|
except Exception, e:
|
|
|
|
|
self.printERROR ('start cl-template exception!')
|
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
|
#self.endTask("cl-template completed!")
|
|
|
|
|
|
|
|
|
|
#p = re.compile('[-]+[\w ]+[-]+\n+[\w\n\+\\=/]+[-]+[\w ]+[-]+\n?')
|
|
|
|
|
#user_ca_certs_list = p.findall(user_ca_certs)
|
|
|
|
|
|
|
|
|
|
# Помещение данных в словарь процессов
|
|
|
|
|
#self.briefParams('say_hello_view')
|
|
|
|
|
#result = result.replace('\x1b[1;33m','')
|
|
|
|
|
|
|
|
|
|
#self.setData (result)
|
|
|
|
|
## Учёт процесса выполнения
|
|
|
|
|
#perc = 0
|
|
|
|
|
#while self.getProgress() < 100:
|
|
|
|
|
#time.sleep(0.2)
|
|
|
|
|
#perc += 20
|
|
|
|
|
## Увеличение процента выполнения процесса
|
|
|
|
|
#self.setProgress (perc)
|
|
|
|
|
##question = self.askQuestion('enter name: ', None)
|
|
|
|
|
##print question
|
|
|
|
|
##print self.askPassword ('Please, your enter pass: ')
|
|
|
|
|
##if not question in [None, "", []]:
|
|
|
|
|
##head = [' ', question, 'two', question]
|
|
|
|
|
##else:
|
|
|
|
|
#head = [' ','One','Two','Three']
|
|
|
|
|
#body = [['One','11','12','13'],['Two','21','22','23'],['Three','31','32','33']]
|
|
|
|
|
|
|
|
|
|
#self.printTable(head, body, "Table 1!")
|
|
|
|
|
#self.startTask("Second task!", True)
|
|
|
|
|
#perc = 0
|
|
|
|
|
#while self.getProgress() < 50:
|
|
|
|
|
#time.sleep(0.3)
|
|
|
|
|
#perc += 10
|
|
|
|
|
## Увеличение процента выполнения процесса
|
|
|
|
|
#self.setProgress (perc)
|
|
|
|
|
#self.printERROR ('you not entered country!')
|
|
|
|
|
#self.endTask("Message about error task 2!")
|
|
|
|
|
#self.endFrame()
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
# Обработка сигнала прерывания работы процесса
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
@ -209,12 +56,8 @@ class ApiWsdl:
|
|
|
|
|
self.printERROR (e)
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
#@rpc( NewType, UserInfoValue, _returns = Array(String) )
|
|
|
|
|
#def func (self, a, b):
|
|
|
|
|
#return []
|
|
|
|
|
|
|
|
|
|
from calculate.api.server.baseClass import Basic
|
|
|
|
|
|
|
|
|
|
from calculate.api.server.decorators import Dec
|
|
|
|
|
|
|
|
|
|
@rpc(Integer, String, _returns = Array(ReturnedMessage))
|
|
|
|
@ -223,23 +66,9 @@ class ApiWsdl:
|
|
|
|
|
@Dec.console('cl-template')
|
|
|
|
|
@Dec.gui('cl-utils')
|
|
|
|
|
def cl_template ( self, sid, args):
|
|
|
|
|
#print "cl-template"
|
|
|
|
|
#print "sid = %d, args = %s" %(sid, args)
|
|
|
|
|
#print type (name)
|
|
|
|
|
#name_meth = 'cl_template'
|
|
|
|
|
#sh = self.get_cache(sid, name_meth)
|
|
|
|
|
#if sh == None:
|
|
|
|
|
#sh = SH()
|
|
|
|
|
#sh.name = name
|
|
|
|
|
#sh.times = times
|
|
|
|
|
#sh.iii = 4
|
|
|
|
|
#self.set_cache(sid, name_meth, sh)
|
|
|
|
|
cl_template_meth = type("CommonInstall",(self.Common, ApiWsdl, object), {})
|
|
|
|
|
#name = sh.name
|
|
|
|
|
|
|
|
|
|
pid = self.startprocess(sid, target=cl_template_meth, \
|
|
|
|
|
method="cl_template_meth", args_proc = (args, ))
|
|
|
|
|
returnmess = ReturnedMessage(type = 'pid', message = pid)
|
|
|
|
|
#returnmess.type = "pid"
|
|
|
|
|
#returnmess.message = pid
|
|
|
|
|
return [returnmess]
|
|
|
|
|
return [returnmess]
|
|
|
|
|