diff --git a/pym/ldap/variables/action.py b/pym/ldap/variables/action.py deleted file mode 100644 index bc844e4..0000000 --- a/pym/ldap/variables/action.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- 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" diff --git a/pym/ldap/__init__.py b/pym/unix/__init__.py similarity index 100% rename from pym/ldap/__init__.py rename to pym/unix/__init__.py diff --git a/pym/ldap/datavars.py b/pym/unix/datavars.py similarity index 88% rename from pym/ldap/datavars.py rename to pym/unix/datavars.py index bd62d03..522a657 100644 --- a/pym/ldap/datavars.py +++ b/pym/unix/datavars.py @@ -20,13 +20,13 @@ from calculate.lib.utils.tools import AddonError from calculate.lib.cl_lang import setLocalTranslate -setLocalTranslate('cl_ldap3', sys.modules[__name__]) +setLocalTranslate('cl_unix3', sys.modules[__name__]) -class DataVarsLdap(DataVars): +class DataVarsUnix(DataVars): """Variable class for desktop package""" - var_module = "ldap" + var_module = "unix" - def importLdap(self, **args): + def importUnix(self, **args): """Import desktop variables""" self.importVariables() self.importVariables('calculate.%s.variables' % self.var_module) diff --git a/pym/ldap/ldap.py b/pym/unix/unix.py similarity index 74% rename from pym/ldap/ldap.py rename to pym/unix/unix.py index bb925c8..2ba1140 100644 --- a/pym/ldap/ldap.py +++ b/pym/unix/unix.py @@ -15,25 +15,30 @@ # limitations under the License. import sys +import os +from os import path from calculate.core.server.func import MethodsInterface +from calculate.server.server import Server +from calculate.lib.utils.files import listDirectory +from calculate.ldap.ldap import Ldap +import shutil _ = lambda x: x from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate) -setLocalTranslate('cl_ldap3', sys.modules[__name__]) +setLocalTranslate('cl_unix3', sys.modules[__name__]) __ = getLazyLocalTranslate(_) -class LdapError(Exception): +class UnixError(Exception): pass -class Ldap(MethodsInterface): +class Unix(Ldap): """Основной объект для выполнения действий связанных - с настройкой LDAP сервиса + с настройкой Unix сервиса """ - class Method(object): - Setup = "ldap_setup" + Setup = "unix_setup" All = (Setup,) def init(self): diff --git a/pym/ldap/utils/__init__.py b/pym/unix/utils/__init__.py similarity index 100% rename from pym/ldap/utils/__init__.py rename to pym/unix/utils/__init__.py diff --git a/pym/ldap/utils/cl_ldap_setup.py b/pym/unix/utils/cl_unix_setup.py similarity index 68% rename from pym/ldap/utils/cl_ldap_setup.py rename to pym/unix/utils/cl_unix_setup.py index 7d7fade..2acdbba 100644 --- a/pym/ldap/utils/cl_ldap_setup.py +++ b/pym/unix/utils/cl_unix_setup.py @@ -19,29 +19,33 @@ 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 +from calculate.lib.datavars import VariableError +from calculate.server.variables.action import Actions +from ..unix import UnixError, Unix +from calculate.ldap.ldap import LdapError +from calculate.server.server import ServerError _ = lambda x: x -setLocalTranslate('cl_ldap3', sys.modules[__name__]) +setLocalTranslate('cl_unix3', sys.modules[__name__]) __ = getLazyLocalTranslate(_) -class ClLdapSetupAction(Action): +class ClUnixSetupAction(Action): """ Действие обновление конфигурационных файлов """ # ошибки, которые отображаются без подробностей native_error = (FilesError, TemplatesError, + VariableError, + ServerError, + UnixError, LdapError) - successMessage = __("SUCCESS") - failedMessage = __("FAILED") - interruptMessage = __("INTERRUPT") + successMessage = __("Unix server configured!") + failedMessage = __("Failed to configure Unix server!") + interruptMessage = __("Unix server configuration manually interrupted") # список задач для действия tasks = [ - {'name': 'test', - 'message': 'test' - } ] diff --git a/pym/ldap/variables/__init__.py b/pym/unix/variables/__init__.py similarity index 95% rename from pym/ldap/variables/__init__.py rename to pym/unix/variables/__init__.py index 0617c7d..cac3c44 100644 --- a/pym/ldap/variables/__init__.py +++ b/pym/unix/variables/__init__.py @@ -15,6 +15,6 @@ # limitations under the License. import action -import ldap +import unix -section = "ldap" +section = "unix" diff --git a/pym/ldap/variables/ldap.py b/pym/unix/variables/action.py similarity index 87% rename from pym/ldap/variables/ldap.py rename to pym/unix/variables/action.py index e1cdec8..3874fda 100644 --- a/pym/ldap/variables/ldap.py +++ b/pym/unix/variables/action.py @@ -15,6 +15,8 @@ # 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__]) +setLocalTranslate('cl_unix3', sys.modules[__name__]) diff --git a/pym/unix/variables/unix.py b/pym/unix/variables/unix.py new file mode 100644 index 0000000..c60451c --- /dev/null +++ b/pym/unix/variables/unix.py @@ -0,0 +1,51 @@ +# -*- 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 (ReadonlyVariable, Variable, + VariableInterface, VariableError) +from calculate.lib.utils.common import genpassword +from calculate.lib.utils.tools import repeater + +_ = lambda x: x +from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate) + +setLocalTranslate('cl_unix3', sys.modules[__name__]) +__ = getLazyLocalTranslate(_) + + +class HashHelper(VariableInterface): + """ + Хэш пароля для LDAP + """ + source = "" + hash_var = "ld_encrypt" + + def get(self): + return SlapPasswd(self.Get(self.hash_var)).get_hash( + self.Get(self.source)) + + +class RandomPasswordHelper(VariableInterface): + """ + Генератор пароля + """ + password_len = 9 + + def get(self): + return genpassword(self.password_len).strip() + + diff --git a/pym/ldap/wsdl_ldap.py b/pym/unix/wsdl_unix.py similarity index 70% rename from pym/ldap/wsdl_ldap.py rename to pym/unix/wsdl_unix.py index ff11336..d888b4a 100644 --- a/pym/ldap/wsdl_ldap.py +++ b/pym/unix/wsdl_unix.py @@ -19,14 +19,15 @@ 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 +from .unix import Unix, UnixError +from calculate.ldap.ldap import LdapError +from calculate.server.variables.action import Actions as ServerActions +from utils.cl_unix_setup import ClUnixSetupAction _ = lambda x: x from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate -setLocalTranslate('cl_ldap3', sys.modules[__name__]) +setLocalTranslate('cl_unix3', sys.modules[__name__]) __ = getLazyLocalTranslate(_) @@ -37,9 +38,9 @@ class Wsdl(WsdlBase): # { # идентификатор метода - 'method_name': Ldap.Method.Setup, + 'method_name': Unix.Method.Setup, # категория метода - 'category': __('LDAP'), + 'category': __('Unix'), # заголовок метода 'title': __("Setup"), # иконка для графической консоли @@ -47,28 +48,32 @@ class Wsdl(WsdlBase): # метод присутствует в графической консоли 'gui': True, # консольная команда - 'command': 'cl-ldap-setup', + 'command': 'cl-unix-setup', # права для запуска метода - 'rights': ['ldap'], + 'rights': ['unix'], # объект содержащий модули для действия - 'logic': {'Ldap': Ldap}, + 'logic': {'Unix': Unix}, # описание действия - 'action': ClLdapSetupAction, + 'action': ClUnixSetupAction, # объект переменных - 'datavars': "ldap", - 'native_error': (VariableError, DataVarsError, LdapError), + 'datavars': "unix", + 'native_error': (VariableError, DataVarsError, LdapError, UnixError), # значения по умолчанию для переменных этого метода - 'setvars': {'cl_action!': LdapActions.Setup}, + 'setvars': {'cl_action!': ServerActions.Setup, + 'server.cl_server_name!': "unix", + 'cl_autoupdate_set': 'on' + # 'cl_dispatch_conf_default': "usenew" + }, # описание груп (список лямбда функций) 'groups': [ lambda group: group( - _("Repository"), - brief=(), + _("Unix server"), + brief=('ldap.ld_base_dn',), hide=(), normal=(), expert=()), ], 'brief': {'next': __("Perform"), - 'name': __("Setup LDAP"),} + 'name': __("Setup Unix"),} }, ] diff --git a/setup.py b/setup.py index bc296d5..4c083a2 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # -*- coding: utf-8 -*- -# setup.py --- Setup script for calculate-ldap +# setup.py --- Setup script for calculate-unix # Copyright 2016 Mir Calculate. http://www.calculate-linux.org # @@ -17,7 +17,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -__app__ = "calculate-ldap" +__app__ = "calculate-unix" __version__ = "3.5.0_alpha1" import os @@ -27,18 +27,20 @@ from distutils.command import install_data as module_install_data from distutils.util import change_root, convert_path packages = [ - "calculate."+str('.'.join(root.split(os.sep)[1:])) - for root, dirs, files in os.walk('pym/ldap') + "calculate." + str('.'.join(root.split(os.sep)[1:])) + for root, dirs, files in os.walk('pym/unix') if '__init__.py' in files -] + ] + +print packages setup( name=__app__, version=__version__, - description="LDAP service for Calculate utilities", + description="Unix service for Calculate utilities", author="Calculate Ltd.", author_email="support@calculate.ru", url="http://calculate-linux.org", license="http://www.apache.org/licenses/LICENSE-2.0", - package_dir = {'calculate.ldap': "pym/ldap"}, - packages = packages) + package_dir={'calculate.unix': "pym/unix", }, + packages=packages)