parent
8056e81782
commit
169141c918
@ -1,15 +0,0 @@
|
||||
AUTHOR: Calculate Ltd. <support@calculate.ru>
|
||||
|
||||
INSTALL
|
||||
-------
|
||||
|
||||
calculate-ldap needs the following library version installed, in order to run:
|
||||
python >= 2.5
|
||||
python-ldap >= 2.0.0
|
||||
pyxml >= 0.8
|
||||
calculate-lib >= 2.2.0.0
|
||||
|
||||
To install calculate-ldap, just execute the install script 'setup.py'.
|
||||
Example:
|
||||
|
||||
./setup.py install
|
Binary file not shown.
@ -1,30 +0,0 @@
|
||||
# Directory Server
|
||||
dn: #-ld_base_dn-#
|
||||
objectClass: dcObject
|
||||
objectClass: organization
|
||||
dc: #-ld_base_root-#
|
||||
o: Calculate Directory Server
|
||||
|
||||
# Services
|
||||
dn: #-ld_services_dn-#
|
||||
objectClass: top
|
||||
objectClass: organizationalUnit
|
||||
ou: Services
|
||||
|
||||
# Admin
|
||||
dn: #-ld_admin_dn-#
|
||||
cn: #-ld_admin_login-#
|
||||
sn: #-ld_admin_login-#
|
||||
objectClass: person
|
||||
objectClass: top
|
||||
description: LDAP Administrator stuff
|
||||
userPassword: #-ld_admin_hash-#
|
||||
|
||||
# Bind
|
||||
dn: #-ld_bind_dn-#
|
||||
cn: #-ld_bind_login-#
|
||||
sn: #-ld_bind_login-#
|
||||
objectClass: person
|
||||
objectClass: top
|
||||
description: LDAP Proxy User
|
||||
userPassword: #-ld_bind_hash-#
|
@ -1,62 +0,0 @@
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2008-2010 Mir 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
|
||||
from cl_datavars import glob_attr
|
||||
from cl_utils import genpassword
|
||||
from encrypt import getHash
|
||||
|
||||
class fillVars(glob_attr):
|
||||
addDn = lambda x,*y: ",".join(y)
|
||||
genDn = lambda x,*y: "=".join(y)
|
||||
|
||||
def get_ld_temp_dn(self):
|
||||
#DN временного пользователя root (для инициализации базы данных)
|
||||
return self.addDn(self.genDn("cn", "ldaproot"), self.Get('ld_base_dn'))
|
||||
|
||||
def get_ld_temp_pw(self):
|
||||
"""пароль временного пользователя root"""
|
||||
return genpassword()
|
||||
|
||||
def get_ld_temp_hash(self):
|
||||
"""hash пароля временного root"""
|
||||
return getHash(self.Get('ld_temp_pw'), self.Get('ld_encrypt'))
|
||||
|
||||
def get_ld_ldap_access_pw_conf(self):
|
||||
"""строки доступа к аттрибуту userPassword в slapd.conf"""
|
||||
return ' by dn="%s" write' %self.Get("ld_admin_dn")
|
||||
|
||||
def get_ld_ldap_access_dn_conf(self):
|
||||
"""строки доступа к LDAP DN сервиса в slapd.conf"""
|
||||
templStart = 'access to dn.regex=".*%(repl_dn)s$"\n'\
|
||||
' by dn="%(admin_dn)s" write\n'\
|
||||
' by dn="%(repl_dn)s" write\n'\
|
||||
' by dn="%(bind_dn)s" read\n'
|
||||
templMail = ' by dn="%(mail_dn)s" read\n'
|
||||
templEnd = ' by * none'
|
||||
templ = ""
|
||||
if self.Get("ld_repl_set")=="on" and self.Get("ld_repl_id")!="":
|
||||
templ += templStart
|
||||
templDict = {'admin_dn':self.Get("ld_admin_dn"),
|
||||
'repl_dn':self.Get("ld_repl_dn"),
|
||||
'bind_dn':self.Get("ld_bind_dn")}
|
||||
mailDn = self.clGetVar("calculate-mail", "cl_mail_dn")
|
||||
if mailDn:
|
||||
templDict.update({'mail_dn':mailDn})
|
||||
templ += templMail
|
||||
templ += templEnd
|
||||
return templ%templDict
|
||||
return ""
|
@ -1,53 +0,0 @@
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2008-2010 Mir 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 cl_ldap_api import allMethods, __app__
|
||||
from cl_utils import appendProgramToEnvFile, removeProgramToEnvFile
|
||||
|
||||
import sys
|
||||
from cl_lang import lang
|
||||
lang().setLanguage(sys.modules[__name__])
|
||||
|
||||
class ldapService(allMethods):
|
||||
|
||||
def installProg(self):
|
||||
'''Install this program'''
|
||||
apiDict = self.clVars.Get("cl_api")
|
||||
apiDict.update({__app__:self.apiFile})
|
||||
self.clVars.Write("cl_api", force=True)
|
||||
if not appendProgramToEnvFile(__app__, self.clVars):
|
||||
self.printERROR(_("Can not save '%s'") %__app__ + " " +\
|
||||
_("to %s") %self.clVars.Get("cl_env_path")[0])
|
||||
return False
|
||||
self.printOK(_("Save install variables"))
|
||||
return True
|
||||
|
||||
def uninstallProg(self):
|
||||
'''Uninstall this program'''
|
||||
apiDict = self.clVars.Get("cl_api")
|
||||
if __app__ in apiDict:
|
||||
apiDict.pop(__app__)
|
||||
self.clVars.Write("cl_api", force=True)
|
||||
if not removeProgramToEnvFile(__app__, self.clVars):
|
||||
self.printERROR(_("Can not remove '%s' to %s")%(__app__,
|
||||
self.clVars.Get("cl_env_path")[0]))
|
||||
return False
|
||||
self.printOK(_("Delete install variables"))
|
||||
return True
|
||||
|
||||
def printVars(self, *arg, **argv):
|
||||
"""Печать существующих переменных"""
|
||||
self.clVars.printVars(*arg, **argv)
|
@ -1,109 +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.
|
||||
from cl_ldap_api import __app__, __version__
|
||||
from cl_ldap_service import ldapService
|
||||
from cl_opt import opt
|
||||
import sys
|
||||
from cl_share_cmd import share_cmd
|
||||
|
||||
# Перевод сообщений для программы
|
||||
from cl_lang import lang
|
||||
lang().setLanguage(sys.modules[__name__])
|
||||
|
||||
# Использование программы
|
||||
USAGE = _("%prog [options]")
|
||||
|
||||
# Коментарии к использованию программы
|
||||
COMMENT_EXAMPLES = _("Create LDAP tree")
|
||||
|
||||
# Пример использования программы
|
||||
EXAMPLES = _("%prog")
|
||||
|
||||
# Описание программы (что делает программа)
|
||||
DESCRIPTION = _("Creating LDAP tree")
|
||||
|
||||
# Опции командной строки
|
||||
CMD_OPTIONS = [{'shortOption':"f",
|
||||
'longOption':"force",
|
||||
'help':_("forced setup service ldap")},
|
||||
{'longOption':"install",
|
||||
'help':_("configure the system to install this package")},
|
||||
{'longOption':"uninstall",
|
||||
'help':_("configure the system to uninstall this package")}]
|
||||
|
||||
class ldap_setup_cmd(share_cmd):
|
||||
def __init__(self):
|
||||
# Объект опций командной строки
|
||||
self.optobj = opt(package=__app__,
|
||||
version=__version__,
|
||||
usage=USAGE,
|
||||
examples=EXAMPLES,
|
||||
comment_examples=COMMENT_EXAMPLES,
|
||||
description=DESCRIPTION,
|
||||
option_list=CMD_OPTIONS +\
|
||||
opt.variable_control+opt.color_control,
|
||||
check_values=self.checkOpts)
|
||||
# Создаем объект логики
|
||||
self.logicObj = ldapService()
|
||||
# Создаем переменные
|
||||
self.logicObj.createClVars()
|
||||
# Названия несовместимых опций
|
||||
self.optionsNamesIncompatible = ["install", "uninstall", "f"]
|
||||
|
||||
def getIncompatibleOptions(self, optObj):
|
||||
"""Получаем несовместимые опции"""
|
||||
retList = []
|
||||
for nameOpt in self.optionsNamesIncompatible:
|
||||
retList.append(getattr(optObj, nameOpt))
|
||||
return retList
|
||||
|
||||
def _getNamesAllSetOptions(self):
|
||||
"""Выдает словарь измененных опций"""
|
||||
setOptDict = self.optobj.values.__dict__.items()
|
||||
defaultOptDict = self.optobj.get_default_values().__dict__.items()
|
||||
return dict(set(setOptDict) - set(defaultOptDict)).keys()
|
||||
|
||||
def getStringIncompatibleOptions(self):
|
||||
"""Форматированная строка несовместимых опций разделенных ','"""
|
||||
listOpt = list(set(self.optionsNamesIncompatible) &\
|
||||
set(self._getNamesAllSetOptions()))
|
||||
return ", ".join(map(lambda x: len(x) == 1 and "'-%s'"%x or "'--%s'"%x,\
|
||||
listOpt))
|
||||
|
||||
def checkOpts(self, optObj, args):
|
||||
"""Check command line opt and arg"""
|
||||
if len(filter(lambda x: x, self.getIncompatibleOptions(optObj)))>1:
|
||||
errMsg = _("incompatible options")+":"+" %s"\
|
||||
%self.getStringIncompatibleOptions()
|
||||
self.optobj.error(errMsg)
|
||||
return False
|
||||
if args:
|
||||
errMsg = _("incorrect argument") + ":" + " %s" %" ".join(args)
|
||||
self.optobj.error(errMsg)
|
||||
return False
|
||||
return optObj, args
|
||||
|
||||
def setup(self, force=False):
|
||||
"""Setup program"""
|
||||
return self.logicObj.setup(force=force)
|
||||
|
||||
def install(self):
|
||||
"""Инсталяция программы"""
|
||||
return self.logicObj.installProg()
|
||||
|
||||
def uninstall(self):
|
||||
"""Удаление программы"""
|
||||
return self.logicObj.uninstallProg()
|
@ -1,83 +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 sys
|
||||
|
||||
from cl_print import color_print
|
||||
from cl_utils import _error
|
||||
|
||||
# Перевод сообщений для программы
|
||||
from cl_lang import lang
|
||||
lang().setLanguage(sys.modules[__name__])
|
||||
|
||||
class share_cmd(color_print, _error):
|
||||
"""Класс общих методов обработки опций командной строки"""
|
||||
|
||||
def printVars(self, optObj):
|
||||
"""Печать переменных"""
|
||||
if optObj.v:
|
||||
varsFilter = None
|
||||
varsNames = []
|
||||
format = "default"
|
||||
# Фильтрование переменных
|
||||
if optObj.filter:
|
||||
optCmd = optObj.filter
|
||||
if ',' in optCmd:
|
||||
varsNames = optCmd.split(",")
|
||||
elif '*' in optCmd:
|
||||
varsFilter = optCmd.replace("*", ".*")
|
||||
else:
|
||||
varsNames.append(optCmd)
|
||||
if optObj.xml:
|
||||
format = "xml"
|
||||
try:
|
||||
v = int(optObj.v)
|
||||
except:
|
||||
v = 1
|
||||
self.logicObj.printVars(varsFilter, varsNames, outFormat=format,
|
||||
verbose=v)
|
||||
|
||||
def setVars(self, optObj):
|
||||
"""Установка переменных"""
|
||||
if optObj.set:
|
||||
for vals in optObj.set:
|
||||
for val in vals.split(','):
|
||||
k,o,v = val.partition('=')
|
||||
if self.logicObj.clVars.exists(k):
|
||||
if not self.logicObj.clVars.SetWriteVar(k,v):
|
||||
return False
|
||||
else:
|
||||
self.printERROR(_('variable %s not found')%k)
|
||||
return False
|
||||
return True
|
||||
|
||||
def writeVars(self, optObj):
|
||||
"""Запись переменных"""
|
||||
if optObj.set:
|
||||
if not self.logicObj.clVars.WriteVars():
|
||||
errMsg = self.getError()
|
||||
if errMsg:
|
||||
self.printERROR(errMsg.strip())
|
||||
self.printERROR(_('Can not write template variables'))
|
||||
return False
|
||||
return True
|
||||
|
||||
def setPrintNoColor(self, optObj):
|
||||
"""Установка печати сообщений без цвета"""
|
||||
if optObj.color and optObj.color=="never":
|
||||
color_print.colorPrint = lambda *arg : sys.stdout.write(arg[-1]) or\
|
||||
sys.stdout.flush()
|
||||
|
@ -1,108 +0,0 @@
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2008-2010 Mir 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 cl_ldap_api import __version__, __app__
|
||||
|
||||
class Data:
|
||||
#базовый суффикс LDAP
|
||||
ld_base_dn = {}
|
||||
|
||||
#bind суффикс LDAP
|
||||
ld_bind_dn = {}
|
||||
|
||||
#пользователь только для чтения
|
||||
ld_bind_login = {}
|
||||
|
||||
#hash пароля для пользователя для чтения
|
||||
ld_bind_hash = {}
|
||||
|
||||
#пароль для пользователя для чтения
|
||||
ld_bind_pw = {}
|
||||
|
||||
#алгоритм шифрования паролей
|
||||
ld_encrypt = {}
|
||||
|
||||
#имя для базового суффикса LDAP
|
||||
ld_base_root = {}
|
||||
|
||||
#временный пользователь root для инициализации базы данных
|
||||
ld_temp_dn = {}
|
||||
|
||||
#hash пароля временного root
|
||||
ld_temp_hash = {}
|
||||
|
||||
#пароль временного пользователя root
|
||||
ld_temp_pw = {}
|
||||
|
||||
#DN пользователя root
|
||||
ld_admin_dn = {}
|
||||
|
||||
#имя пользователя root для LDAP
|
||||
ld_admin_login = {}
|
||||
|
||||
#hash пароля root
|
||||
ld_admin_hash = {}
|
||||
|
||||
#пароль root
|
||||
ld_admin_pw = {}
|
||||
|
||||
#Имя для всех сервисов
|
||||
ld_services= {}
|
||||
|
||||
#DN всех сервисов
|
||||
ld_services_dn = {}
|
||||
|
||||
#Настроен или нет сервис LDAP
|
||||
sr_ldap_set = {'mode':"w",'value':'off'}
|
||||
|
||||
# имя программы
|
||||
cl_name = {'value':__app__}
|
||||
|
||||
# версия программы
|
||||
cl_ver = {'value':__version__}
|
||||
|
||||
# действие программа устанавливает сервис
|
||||
ac_ldap_setup = {'value':'down'}
|
||||
|
||||
# действие программа обновляет конфигурационные файлы
|
||||
ac_ldap_update = {'value':'down'}
|
||||
|
||||
# include строки в slapd.conf
|
||||
ld_ldap_scheme_conf = {'value':\
|
||||
"include\t\t/etc/openldap/schema/core.schema\n"\
|
||||
"include\t\t/etc/openldap/schema/cosine.schema\n"\
|
||||
"include\t\t/etc/openldap/schema/nis.schema\n"\
|
||||
"include\t\t/etc/openldap/schema/inetorgperson.schema\n"\
|
||||
"include\t\t/etc/openldap/schema/misc.schema"}
|
||||
|
||||
# строки доступа к аттрибуту userPassword в slapd.conf
|
||||
ld_ldap_access_pw_conf = {}
|
||||
|
||||
# строки доступа к LDAP DN сервиса в slapd.conf
|
||||
ld_ldap_access_dn_conf = {}
|
||||
|
||||
ld_repl_set = {'value':'off'}
|
||||
|
||||
ld_repl_id = {}
|
||||
|
||||
ld_repl_servers_info = {}
|
||||
|
||||
ld_repl_servers_ref = {}
|
||||
|
||||
# lib vars
|
||||
cl_pass_step = {}
|
||||
cl_api = {}
|
||||
cl_env_path = {}
|
@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Mir Calculate. 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
|
||||
from calculate.lib.datavars import DataVars
|
||||
from calculate.lib.utils.tools import AddonError
|
||||
|
||||
from calculate.lib.cl_lang import setLocalTranslate
|
||||
|
||||
setLocalTranslate('cl_ldap3', sys.modules[__name__])
|
||||
|
||||
class DataVarsLdap(DataVars):
|
||||
"""Variable class for desktop package"""
|
||||
var_module = "ldap"
|
||||
|
||||
def importLdap(self, **args):
|
||||
"""Import desktop variables"""
|
||||
self.importVariables()
|
||||
self.importVariables('calculate.%s.variables' % self.var_module)
|
||||
self.defaultModule = self.var_module
|
@ -0,0 +1,47 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Mir Calculate. 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
|
||||
from calculate.core.server.func import Action, Tasks
|
||||
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
|
||||
from calculate.lib.cl_template import TemplatesError
|
||||
from calculate.lib.utils.files import FilesError
|
||||
from ..ldap import LdapError
|
||||
|
||||
_ = lambda x: x
|
||||
setLocalTranslate('cl_ldap3', sys.modules[__name__])
|
||||
__ = getLazyLocalTranslate(_)
|
||||
|
||||
|
||||
class ClLdapSetupAction(Action):
|
||||
"""
|
||||
Действие обновление конфигурационных файлов
|
||||
"""
|
||||
# ошибки, которые отображаются без подробностей
|
||||
native_error = (FilesError,
|
||||
TemplatesError,
|
||||
LdapError)
|
||||
|
||||
successMessage = __("SUCCESS")
|
||||
failedMessage = __("FAILED")
|
||||
interruptMessage = __("INTERRUPT")
|
||||
|
||||
# список задач для действия
|
||||
tasks = [
|
||||
{'name': 'test',
|
||||
'message': 'test'
|
||||
}
|
||||
]
|
@ -0,0 +1,20 @@
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Mir Calculate. 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 action
|
||||
import ldap
|
||||
|
||||
section = "ldap"
|
@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Mir Calculate. 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
|
||||
from calculate.lib.datavars import ActionVariable
|
||||
|
||||
from calculate.lib.cl_lang import setLocalTranslate
|
||||
|
||||
setLocalTranslate('cl_ldap3', sys.modules[__name__])
|
||||
|
||||
|
||||
class Actions(object):
|
||||
Setup = "ldap_setup"
|
||||
|
||||
|
||||
class VariableAcLdapSetup(ActionVariable):
|
||||
"""
|
||||
Action variable which has value "on" for prepare squash
|
||||
"""
|
||||
|
||||
def action(self, cl_action):
|
||||
if cl_action == Actions.Setup:
|
||||
return "on"
|
||||
return "off"
|
@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Mir Calculate. 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
|
||||
from calculate.lib.cl_lang import setLocalTranslate
|
||||
|
||||
setLocalTranslate('cl_ldap3', sys.modules[__name__])
|
@ -0,0 +1,74 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Mir Calculate. 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
|
||||
|
||||
from calculate.lib.datavars import VariableError, DataVarsError
|
||||
|
||||
from calculate.core.server.func import WsdlBase
|
||||
from .ldap import Ldap, LdapError
|
||||
from .variables.action import Actions as LdapActions
|
||||
from utils.cl_ldap_setup import ClLdapSetupAction
|
||||
|
||||
_ = lambda x: x
|
||||
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
|
||||
|
||||
setLocalTranslate('cl_ldap3', sys.modules[__name__])
|
||||
__ = getLazyLocalTranslate(_)
|
||||
|
||||
|
||||
class Wsdl(WsdlBase):
|
||||
methods = [
|
||||
#
|
||||
# Настроить службу
|
||||
#
|
||||
{
|
||||
# идентификатор метода
|
||||
'method_name': Ldap.Method.Setup,
|
||||
# категория метода
|
||||
'category': __('LDAP'),
|
||||
# заголовок метода
|
||||
'title': __("Setup"),
|
||||
# иконка для графической консоли
|
||||
'image': 'setup',
|
||||
# метод присутствует в графической консоли
|
||||
'gui': True,
|
||||
# консольная команда
|
||||
'command': 'cl-ldap-setup',
|
||||
# права для запуска метода
|
||||
'rights': ['ldap'],
|
||||
# объект содержащий модули для действия
|
||||
'logic': {'Ldap': Ldap},
|
||||
# описание действия
|
||||
'action': ClLdapSetupAction,
|
||||
# объект переменных
|
||||
'datavars': "ldap",
|
||||
'native_error': (VariableError, DataVarsError, LdapError),
|
||||
# значения по умолчанию для переменных этого метода
|
||||
'setvars': {'cl_action!': LdapActions.Setup},
|
||||
# описание груп (список лямбда функций)
|
||||
'groups': [
|
||||
lambda group: group(
|
||||
_("Repository"),
|
||||
brief=(),
|
||||
hide=(),
|
||||
normal=(),
|
||||
expert=()),
|
||||
],
|
||||
'brief': {'next': __("Perform"),
|
||||
'name': __("Setup LDAP"),}
|
||||
},
|
||||
]
|
@ -1,65 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
#-*- 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 sys
|
||||
import os
|
||||
sys.path.insert(0,os.path.abspath('/usr/lib/calculate-2.2/calculate-lib/pym'))
|
||||
sys.path.insert(0,\
|
||||
os.path.abspath('/usr/lib/calculate-2.2/calculate-ldap/pym'))
|
||||
|
||||
from cl_ldap_setup_cmd import ldap_setup_cmd
|
||||
|
||||
from cl_lang import lang
|
||||
tr = lang()
|
||||
tr.setGlobalDomain('cl_ldap')
|
||||
tr.setLanguage(sys.modules[__name__])
|
||||
|
||||
if __name__ == "__main__":
|
||||
obj = ldap_setup_cmd()
|
||||
ret = obj.optobj.parse_args()
|
||||
if ret is False:
|
||||
sys.exit(1)
|
||||
opts, args = ret
|
||||
# Установка цвета при печати сообщений
|
||||
obj.setPrintNoColor(opts)
|
||||
# Установка переменных
|
||||
if not obj.setVars(opts):
|
||||
sys.exit(1)
|
||||
# Печать переменных
|
||||
obj.printVars(opts)
|
||||
# Если нет печати переменных выполняем логику программы
|
||||
if not opts.v and not opts.filter and not opts.xml:
|
||||
if not filter(lambda x: x[1], obj.optobj.values.__dict__.items()):
|
||||
# Setup
|
||||
if not obj.setup():
|
||||
sys.exit(1)
|
||||
elif opts.f:
|
||||
# Force setup
|
||||
if not obj.setup(force=True):
|
||||
sys.exit(1)
|
||||
elif opts.install:
|
||||
# Install
|
||||
if not obj.install():
|
||||
sys.exit(1)
|
||||
elif opts.uninstall:
|
||||
# Uninstall
|
||||
if not obj.uninstall():
|
||||
sys.exit(1)
|
||||
# Запись переменных
|
||||
if not obj.writeVars(opts):
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
@ -1,5 +0,0 @@
|
||||
[install]
|
||||
install-scripts=/usr/bin
|
||||
install-purelib=/usr/lib/calculate-2.2
|
||||
install-platlib=/usr/lib/calculate-2.2
|
||||
install-data=/usr/lib/calculate-2.2/calculate-ldap
|
Loading…
Reference in new issue