parent
488b8caa13
commit
f15b3be39b
@ -0,0 +1,194 @@
|
||||
#!/usr/bin/python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 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.
|
||||
|
||||
from cert_cmd import check_server_certificate, sing_req_by_server
|
||||
import post_request
|
||||
|
||||
from calculate.api.client.cert_func import new_key_req
|
||||
from calculate.api.client.function import get_ip_mac_type
|
||||
|
||||
from calculate.lib.utils import ip as ip_mod
|
||||
|
||||
|
||||
def init(cert, key, cert_path, data_path, certbase, args, port):
|
||||
if check():
|
||||
for step in range (2):
|
||||
args = change_args(args, step)
|
||||
create_server_cert(cert, key, cert_path, args, port)
|
||||
|
||||
create_client_cert(cert, cert_path, data_path, certbase, port)
|
||||
|
||||
def change_args(args, step = None):
|
||||
if step == 0:
|
||||
args.host = False
|
||||
args.gen_root_cert = True
|
||||
args.root_host = False
|
||||
args.use_root_cert = False
|
||||
elif step == 1:
|
||||
args.gen_root_cert = False
|
||||
args.use_root_cert = True
|
||||
|
||||
return args
|
||||
|
||||
def create_server_cert(cert, key, cert_path, args, port):
|
||||
check_server_certificate(cert, key, cert_path, args, port, auto = True)
|
||||
|
||||
def create_client_cert(server_cert, cert_path, data_path, certbase):
|
||||
req_id = create_request(server_cert, cert_path, data_path, certbase)
|
||||
sign_certificate(req_id, cert_path, data_path)
|
||||
get_certificate(cert_path, data_path, certbase)
|
||||
|
||||
def create_request(server_cert, cert_path, data_path, certbase):
|
||||
server_host_name = 'localhost'
|
||||
|
||||
#key = cert_path + server_host_name + '.key'
|
||||
#csr_file = cert_path + server_host_name +'.csr'
|
||||
#pritn 'request file = ', csr_file
|
||||
|
||||
client_req_file = new_key_req(key, cert_path, server_host_name, auto = True)
|
||||
|
||||
ip, mac, client_type = get_ip_mac_type()
|
||||
data = open(client_req_file).read()
|
||||
|
||||
req_id = post_request.serv_post_client_request (data, data_path, ip, mac, \
|
||||
client_type, certbase, cert_path)
|
||||
|
||||
fc = open(cert_path + 'req_id', 'w')
|
||||
fc.write(res)
|
||||
fc.close()
|
||||
return req_id
|
||||
|
||||
def sign_certificate(req_id, cert_path, data_path):
|
||||
sing_req_by_server(req_id, cert_path, data_path)
|
||||
|
||||
def get_ip_mac_type():
|
||||
for Interfaces in ip_mod.getInterfaces():
|
||||
try:
|
||||
ip, mac, client_type = get_ip_mac_type(Interfaces, 'gui')
|
||||
return (ip, mac, client_type)
|
||||
except:
|
||||
pass
|
||||
return ('no_ip','no_mac', 'live')
|
||||
|
||||
def get_certificate(cert_path, data_path, certbase):
|
||||
if not os.path.exists(cert_path + 'req_id'):
|
||||
print _("request was not sent or deleted file %s") \
|
||||
%(cert_path + 'req_id')
|
||||
return 1
|
||||
fc = open(cert_path + 'req_id', 'r')
|
||||
req_id = fc.read()
|
||||
fc.close()
|
||||
|
||||
server_host_name = 'localhost'
|
||||
|
||||
if not os.path.exists(cert_path + server_host_name + '.csr'):
|
||||
print _('Request %s not found') %(cert_path + server_host_name + '.csr')
|
||||
return 1
|
||||
request = open(cert_path + server_host_name + '.csr').read()
|
||||
md5 = hashlib.md5()
|
||||
md5.update(request)
|
||||
md5sum = md5.hexdigest()
|
||||
|
||||
result = post_request.serv_get_client_cert (req_id, request, data_path, \
|
||||
certbase, cert_path)
|
||||
|
||||
cert = result[0][0]
|
||||
ca_root = result[0][1]
|
||||
if cert == '1':
|
||||
print _('Request to sign is rejected!')
|
||||
return 1
|
||||
elif cert == '2':
|
||||
print _("Request for the signing has not yet reviewed.")
|
||||
print _("Your request id = %s") %req_id
|
||||
return 1
|
||||
elif cert == '3':
|
||||
print _("Request on signature does not match sent earlier.")
|
||||
return 1
|
||||
elif cert == '4':
|
||||
print _("Request was sent from another ip.")
|
||||
return 1
|
||||
fc = open(cert_path + server_host_name + '.crt', 'w')
|
||||
fc.write(cert)
|
||||
fc.close()
|
||||
os.unlink(cert_path + 'req_id')
|
||||
print 'OK. Certificate save. Your certificate id = %s' %req_id
|
||||
|
||||
if ca_root:
|
||||
clVars = DataVarsApi()
|
||||
clVars.importApi()
|
||||
clVars.flIniFile()
|
||||
system_ca_db = clVars.Get('cl_glob_root_cert')
|
||||
if os.path.exists(system_ca_db):
|
||||
if ca_root in open(system_ca_db, 'r').read():
|
||||
return 0
|
||||
|
||||
cl_client_cert_dir = clVars.Get('cl_client_cert_dir')
|
||||
homePath = clVars.Get('ur_home_path')
|
||||
|
||||
cl_client_cert_dir = cl_client_cert_dir.replace("~",homePath)
|
||||
root_cert_md5 = cl_client_cert_dir + "/ca/cert_list"
|
||||
|
||||
md5 = hashlib.md5()
|
||||
md5.update(ca_root)
|
||||
md5sum = md5.hexdigest()
|
||||
print "\n================================================="
|
||||
print "md5sum = ", md5sum
|
||||
|
||||
if not os.path.exists(root_cert_md5):
|
||||
fc = open(root_cert_md5,"w")
|
||||
fc.close()
|
||||
|
||||
filename = None
|
||||
with open(root_cert_md5) as fd:
|
||||
t = fd.read()
|
||||
# for each line
|
||||
for line in t.splitlines():
|
||||
# Split string into a words list
|
||||
words = line.split(' ',1)
|
||||
if words[0] == md5sum:
|
||||
filename = words[1]
|
||||
if not filename:
|
||||
certobj = OpenSSL.crypto.load_certificate \
|
||||
(OpenSSL.SSL.FILETYPE_PEM, ca_root)
|
||||
Issuer = certobj.get_issuer().get_components()
|
||||
for item in Issuer:
|
||||
if item[0] == 'CN':
|
||||
filename = item[1]
|
||||
|
||||
fc = open(root_cert_md5,"a")
|
||||
fc.write('%s %s\n' %(md5sum, filename))
|
||||
fc.close()
|
||||
|
||||
if not filename:
|
||||
print _('Not found field "CN" in certificate!')
|
||||
return 1
|
||||
|
||||
fd = open(cl_client_cert_dir + '/ca/' + filename, 'w')
|
||||
fd.write(ca_root)
|
||||
fd.close()
|
||||
|
||||
|
||||
user_root_cert = clVars.Get('cl_user_root_cert')
|
||||
user_root_cert = user_root_cert.replace("~",homePath)
|
||||
fa = open(user_root_cert, 'a')
|
||||
fa.write(ca_root)
|
||||
fa.close()
|
||||
print _("filename = "), filename
|
||||
print _("CERTIFICATE ADD")
|
||||
else:
|
||||
print _("file with ca certificates exists")
|
||||
return 0
|
@ -0,0 +1,229 @@
|
||||
##-*- 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 calculate.api.server.api_types import ReturnedMessage, getViewForVariables
|
||||
#from calculate.api.server.api_types import ChoiceValue, Table, Option, Field, \
|
||||
#GroupField, ViewInfo
|
||||
#from calculate.lib.datavars import VariableError
|
||||
|
||||
##from cl_install import Install,DataVarsInstall
|
||||
#import cl_install
|
||||
#from calculate.lib.cl_lang import setLocalTranslate
|
||||
#from calculate.api.server.decorators import Dec
|
||||
#setLocalTranslate('cl_install',sys.modules[__name__])
|
||||
#import traceback
|
||||
|
||||
#class InstallInfo(ClassSerializer):
|
||||
#"""Parameters for method install"""
|
||||
#request_id = String
|
||||
#request_group = String
|
||||
|
||||
#def catchExcept():
|
||||
#class wrapper:
|
||||
#def __init__(self,f):
|
||||
#self.f = f
|
||||
#self.func_name = f.func_name
|
||||
#self.func_code = f.func_code
|
||||
#self.__doc__ = f.__doc__
|
||||
#self.__name__ = f.__name__
|
||||
|
||||
#def __call__(self,selfobj,*args,**kwargs):
|
||||
#try:
|
||||
#return self.f(selfobj,*args,**kwargs)
|
||||
#except BaseException as e:
|
||||
#view = ViewInfo(groups=[])
|
||||
#group = GroupField(name=_("Error"),last=True)
|
||||
#group.fields = []
|
||||
#group.fields.append(Field(
|
||||
#name = "error",
|
||||
#label = str(e),
|
||||
#default = 'color:red;',
|
||||
#element = "error"))
|
||||
#view.groups.append(group)
|
||||
#print "!!!!EXCEPTION!!!!"
|
||||
#for i in apply(traceback.format_exception, sys.exc_info()):
|
||||
#print i
|
||||
#return view
|
||||
#return wrapper
|
||||
|
||||
#class Wsdl:
|
||||
#def check_params (self, dv, info,allvars=False,ordered=None):
|
||||
#errors = []
|
||||
#keys = sorted(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:
|
||||
## get value of variable from info
|
||||
#val = info.__getattribute__(var)
|
||||
## check value if value send of check allvariables
|
||||
#if val != None or allvars:
|
||||
#try:
|
||||
## if value not send, then get from datavars
|
||||
#if val == None:
|
||||
#val = dv.Get(var)
|
||||
#else:
|
||||
#uncomperr = dv.Uncompatible(var)
|
||||
#if uncomperr:
|
||||
#raise VariableError(uncomperr)
|
||||
#if not dv.Uncompatible(var):
|
||||
#dv.Set(var, val)
|
||||
#except VariableError, e:
|
||||
#mess = ''
|
||||
#messages = e.message if type(e.message) == list else [e.message]
|
||||
#for error in messages:
|
||||
#mess += str(error) + '\n'
|
||||
#errors.append(ReturnedMessage(type = 'error', field = var,
|
||||
#message = mess))
|
||||
#return errors
|
||||
|
||||
#from calculate.api.server.baseClass import Basic
|
||||
#from calculate.api.server.decorators import Dec
|
||||
|
||||
#def installCommon(self,sid,info,methodname,initfunc):
|
||||
#"""
|
||||
#Install common method
|
||||
#"""
|
||||
#try:
|
||||
#dv = self.get_cache(sid,methodname,"vars")
|
||||
#if not dv:
|
||||
#reload(cl_install)
|
||||
#dv = cl_install.DataVarsInstall()
|
||||
#dv.importInstall()
|
||||
#dv.flIniFile()
|
||||
#initfunc(dv)
|
||||
#errors = self.check_params(dv, info,
|
||||
#ordered=['cl_autopartition_scheme',
|
||||
#'cl_autopartition_device',
|
||||
#'cl_autopartition_root_size',
|
||||
#'cl_image_linux_shortname',
|
||||
#'cl_image_arch_machine',
|
||||
#'cl_image_linux_ver',
|
||||
#'cl_image_linux_build'],
|
||||
#allvars=not info.CheckOnly)
|
||||
#if errors:
|
||||
#return errors
|
||||
#if info.CheckOnly:
|
||||
#returnmess = ReturnedMessage(type = '', message = None)
|
||||
#return [returnmess]
|
||||
#install_meth = type("CommonInstall",(self.Common,
|
||||
#cl_install.Install, object), {})
|
||||
#pid = self.startprocess(sid, target=install_meth,
|
||||
#method="installSystem",\
|
||||
#args_proc = (dv,))
|
||||
#returnmess = ReturnedMessage(type = 'pid', message = pid)
|
||||
#returnmess.type = "pid"
|
||||
#returnmess.message = pid
|
||||
#dv = self.clear_cache(sid,methodname)
|
||||
#return [returnmess]
|
||||
#finally:
|
||||
#if dv:
|
||||
#self.set_cache(sid,methodname,"vars",dv,smart=False)
|
||||
#return []
|
||||
|
||||
#@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
#@Dec.check_permissions(["install"])
|
||||
#@Dec.console('cl-install')
|
||||
#@Dec.gui(_('System'),_('Install'),'drive-harddisk')
|
||||
#def install ( self, sid, info):
|
||||
#def init_func(dv):
|
||||
#dv.Set('cl_action','system',True)
|
||||
#return self.installCommon(sid,info,'install',init_func)
|
||||
|
||||
#@rpc(Integer, Integer, Boolean,_returns = ViewInfo)
|
||||
#@catchExcept()
|
||||
#def install_view (self, sid, step,expert):
|
||||
#curThread = threading.currentThread()
|
||||
#dv = self.get_cache(sid,"install","vars")
|
||||
#if not dv:
|
||||
#reload(cl_install)
|
||||
#dv = cl_install.DataVarsInstall()
|
||||
#dv.importInstall()
|
||||
#dv.flIniFile()
|
||||
#dv.Set('cl_action','system',True)
|
||||
#view = getViewForVariables (dv, [
|
||||
#(_("Requests"), \
|
||||
#('cl_req_id',),
|
||||
#('cl_image_linux_shortname','cl_image_arch_machine',
|
||||
#'cl_image_linux_ver','cl_image_linux_build'),
|
||||
#_("Next")), \
|
||||
#(_("Autopartition"), \
|
||||
#('cl_autopartition_device',
|
||||
#'cl_autopartition_scheme'),
|
||||
#('cl_autopartition_table','cl_autopartition_root_size'),
|
||||
#_("Next")), \
|
||||
#(_("Partitioning"), \
|
||||
#('os_location_data','os_install_scratch','cl_uuid_set'),
|
||||
#('os_install_root_type','os_install_mbr',
|
||||
#'os_install_kernel_scheduler'),
|
||||
#_("Next")), \
|
||||
#(_("Locale"), \
|
||||
#('os_install_locale_lang','os_install_clock_timezone'),(), \
|
||||
#_("Next")),
|
||||
#(_("Networking"), \
|
||||
#('os_install_net_conf','os_install_net_data','os_install_net_fqdn',
|
||||
#'os_install_ntp'),('os_install_net_route_data',), \
|
||||
#_("Next")),
|
||||
#(_("Users"), \
|
||||
#('cl_migrate_data','cl_autologin'),(), \
|
||||
#_("Next")),
|
||||
#(_("Video"), \
|
||||
#('os_install_x11_video_drv', 'os_install_x11_composite',
|
||||
#'os_install_x11_resolution', 'os_install_fb_resolution'),(), \
|
||||
#_("Install")),
|
||||
#],step,expert)
|
||||
#self.set_cache(sid, 'install', "vars",dv,smart=False)
|
||||
#return view
|
||||
|
||||
#@rpc(Integer, InstallInfo, _returns = Array(ReturnedMessage))
|
||||
#@Dec.check_permissions(["install"])
|
||||
#@Dec.gui(_('System'),_('Flash install'),
|
||||
#'drive-removable-media-usb-pendrive,media-removable')
|
||||
#def install_flash ( self, sid, info):
|
||||
#"""
|
||||
#Install to flash
|
||||
#"""
|
||||
#def init_func(dv):
|
||||
#dv.Set('cl_action','system',True)
|
||||
#dv.Set('cl_install_type','flash')
|
||||
#return self.installCommon(sid,info,'install_flash',init_func)
|
||||
|
||||
#@rpc(Integer, Integer, Boolean,_returns = ViewInfo)
|
||||
#@catchExcept()
|
||||
#def install_flash_view (self, sid, step,expert):
|
||||
#dv = self.get_cache(sid,"install_flash","vars")
|
||||
#if not dv:
|
||||
#reload(cl_install)
|
||||
#dv = cl_install.DataVarsInstall()
|
||||
#dv.importInstall()
|
||||
#dv.flIniFile()
|
||||
#dv.Set('cl_action','system',True)
|
||||
#dv.Set('cl_install_type','flash')
|
||||
#view = getViewForVariables (dv, [
|
||||
#(_("Distribute"), \
|
||||
#('os_install_disk_single','cl_image_filename'),
|
||||
#('os_location_data',),
|
||||
#_("Install")), \
|
||||
#],step,expert)
|
||||
#self.set_cache(sid, 'install_flash', "vars",dv,smart=False)
|
||||
#return view
|
@ -0,0 +1,216 @@
|
||||
#-*- 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.
|
||||
|
||||
# mode - read only or writeable variable
|
||||
# value - default variable value
|
||||
# select - list of posible values for variable
|
||||
# hide - flag, if it is True, then the variable is not printable
|
||||
# printval - print value of variable
|
||||
|
||||
from calculate.lib.datavars import Variable,ReadonlyVariable,VariableError
|
||||
import os
|
||||
import sys
|
||||
from os import path
|
||||
import OpenSSL
|
||||
|
||||
from calculate.lib.cl_lang import setLocalTranslate
|
||||
from calculate.api.cert_cmd import find_id_cert
|
||||
setLocalTranslate('cl_api',sys.modules[__name__])
|
||||
|
||||
class VariableClReqId(Variable):
|
||||
"""
|
||||
Certificate Identification
|
||||
"""
|
||||
type = "choice"
|
||||
value = ""
|
||||
opt = ["-r"]
|
||||
metavalue = "REQ_ID"
|
||||
|
||||
def init(self):
|
||||
self.help = _("Request Identification")
|
||||
self.label = _("Request Identification")
|
||||
|
||||
def choice(self):
|
||||
data_path = self.Get('cl_api_data')
|
||||
|
||||
result = []
|
||||
cert_dir = data_path + '/client_certs/'
|
||||
for filename in glob.glob(cert_dir+"*"):
|
||||
if filename.endswith('.csr'):
|
||||
result.append(filename.split('.')[0])
|
||||
return result
|
||||
|
||||
def check(self, req_id):
|
||||
try:
|
||||
int(req_id)
|
||||
except ValueError:
|
||||
raise VariableError(_("Group %s does not exist") %group)
|
||||
|
||||
class VariableClReqBaseData(Variable):
|
||||
"""
|
||||
"""
|
||||
def get(self):
|
||||
req_id = self.Get('cl_req_id')
|
||||
serv_certbase = self.Get('cl_api_serv_database')
|
||||
|
||||
for line in readFileLine(serv_certbase):
|
||||
if line.split()[0] == req_id:
|
||||
return line.strip().split()
|
||||
return ['']*7
|
||||
|
||||
class VariableClReqData(Variable):
|
||||
"""
|
||||
"""
|
||||
def get(self):
|
||||
req_id = self.Get('cl_req_id')
|
||||
data_path = self.Get('cl_api_data')
|
||||
|
||||
req_file = data_path + '/client_certs/%s.csr' %req_id
|
||||
if os.path.exists(req_file):
|
||||
fp = open(req_file, 'r')
|
||||
request = fp.read()
|
||||
fp.close()
|
||||
reqobj = OpenSSL.crypto.load_certificate_request \
|
||||
(OpenSSL.SSL.FILETYPE_PEM, request)
|
||||
Subject = reqobj.get_subject().get_components()
|
||||
return Subject
|
||||
return [['','']]*6
|
||||
|
||||
class VariableClReqIp(Variable):
|
||||
"""
|
||||
Ip Request
|
||||
"""
|
||||
|
||||
def init(self):
|
||||
self.help = _("Request Ip adress")
|
||||
self.label = _("Request Ip")
|
||||
|
||||
def get(self):
|
||||
return self.Get('cl_req_base_data')[4]
|
||||
|
||||
class VariableClReqMac(Variable):
|
||||
"""
|
||||
Mac Adress Request
|
||||
"""
|
||||
|
||||
def init(self):
|
||||
self.help = _("Request Mac adress")
|
||||
self.label = _("Request Mac")
|
||||
|
||||
|
||||
def get(self):
|
||||
return self.Get('cl_req_base_data')[5]
|
||||
|
||||
class VariableClReqDate(Variable):
|
||||
"""
|
||||
Date send Request
|
||||
"""
|
||||
|
||||
def init(self):
|
||||
self.help = _("Request Date")
|
||||
self.label = _("Request Date")
|
||||
|
||||
def get(self):
|
||||
words = self.Get('cl_req_base_data')
|
||||
return '%s %s' %(words[2], words[3])
|
||||
|
||||
|
||||
class VariableClReqUserName(Variable):
|
||||
"""
|
||||
UserName Owner Request
|
||||
"""
|
||||
|
||||
def init(self):
|
||||
self.help = _("Request Owner UserName")
|
||||
self.label = _("Request Owner UserName")
|
||||
|
||||
def get(self):
|
||||
Subject = self.Get('cl_req_data')
|
||||
for item in Subject:
|
||||
if item[0] == 'OU':
|
||||
return item[1]
|
||||
return ''
|
||||
|
||||
class VariableClReqLocation(Variable):
|
||||
"""
|
||||
Location Owner Request
|
||||
"""
|
||||
|
||||
def init(self):
|
||||
self.help = _("Request Location")
|
||||
self.label = _("Request Location")
|
||||
|
||||
def get(self):
|
||||
Subject = self.Get('cl_req_data')
|
||||
for item in Subject:
|
||||
if item[0] == 'L':
|
||||
return item[1]
|
||||
return ''
|
||||
|
||||
class VariableClReqGroup(Variable):
|
||||
"""
|
||||
Certificate Group
|
||||
"""
|
||||
type = "choice"
|
||||
value = ""
|
||||
opt = ["-g"]
|
||||
metavalue = "REQ_GROUP"
|
||||
|
||||
def init(self):
|
||||
self.help = _("set certificate group")
|
||||
self.label = _("Certificate group")
|
||||
|
||||
def choice(self):
|
||||
group_rights = self.Get('cl_api_group_rights')
|
||||
|
||||
t = open(group_rights, 'r').read()
|
||||
result = []
|
||||
for line in t.splitlines():
|
||||
words = line.split()
|
||||
|
||||
if not words[0].startswith('#'):
|
||||
result.append(words[0])
|
||||
return result
|
||||
|
||||
def check(self, group):
|
||||
group_rights = self.Get('cl_api_group_rights')
|
||||
|
||||
t = open(group_rights, 'r').read()
|
||||
for line in t.splitlines():
|
||||
words = line.split()
|
||||
|
||||
if group == words[0]:
|
||||
return
|
||||
raise VariableError(_("Group %s does not exist") %group)
|
||||
|
||||
class VariableClCertActive(Variable):
|
||||
"""
|
||||
Certificate Identification
|
||||
"""
|
||||
type = "choice"
|
||||
value = ""
|
||||
opt = ["-c"]
|
||||
metavalue = "CERT_ID"
|
||||
|
||||
def init(self):
|
||||
self.help = _("set certificate group")
|
||||
self.label = _("Certificate group")
|
||||
|
||||
def choice(self):
|
||||
return [""]+self.Get('os_device_dev')
|
||||
|
||||
def check(self,value):
|
||||
if self.Get('cl_autopartition_scheme') and not value:
|
||||
raise VariableError(_("For autopartition need select install device"))
|
Loading…
Reference in new issue