25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.8 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 Mir Calculate. http://www.calculate-linux.org
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import sys
  16. from calculate.core.server.func import Action, Tasks
  17. from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
  18. from calculate.lib.cl_template import TemplatesError
  19. from calculate.lib.utils.files import FilesError
  20. from calculate.lib.datavars import VariableError
  21. from calculate.server.variables.action import Actions
  22. from ..unix import UnixError, Unix
  23. from calculate.ldap.ldap import LdapError
  24. from calculate.ldap.utils.cl_ldap_setup import MetaTasks
  25. from calculate.server.server import ServerError
  26. _ = lambda x: x
  27. setLocalTranslate('cl_unix3', sys.modules[__name__])
  28. __ = getLazyLocalTranslate(_)
  29. class ClUnixGroupmodAction(Action):
  30. """
  31. Действие обновление конфигурационных файлов
  32. """
  33. # ошибки, которые отображаются без подробностей
  34. native_error = (FilesError,
  35. TemplatesError,
  36. VariableError,
  37. ServerError,
  38. UnixError,
  39. LdapError)
  40. successMessage = __("Group {ur_unix_group_name} modified in Unix service!")
  41. failedMessage = __("Failed to modify {ur_unix_group_name} group "
  42. "in Unix server!")
  43. interruptMessage = __("Modifing of group manually interrupted")
  44. stop_tasks = [
  45. ]
  46. meta_tasks = MetaTasks("Unix")
  47. # список задач для действия
  48. tasks = [
  49. {'name': 'remove_users',
  50. 'method': 'Unix.remove_users_from_group(unix.ur_unix_group_users_del,'
  51. 'unix.ur_unix_group_name_exists)',
  52. 'condition': lambda Get: Get('unix.ur_unix_group_users_del')
  53. },
  54. {'name': 'append_users',
  55. 'method': 'Unix.add_users_in_group(unix.ur_unix_group_users_add,'
  56. 'unix.ur_unix_group_name_exists)',
  57. 'condition': lambda Get: Get('unix.ur_unix_group_users_add')
  58. },
  59. {'name': 'rename_group',
  60. 'message': _("Renaming group {unix.ur_unix_group_name} to "
  61. "{unix.ur_unix_group_newname}"),
  62. 'method': 'Unix.rename_group(unix.ur_unix_group_name,'
  63. 'unix.ur_unix_group_newname)',
  64. 'condition': lambda Get: (Get('unix.ur_unix_group_newname') !=
  65. Get('unix.ur_unix_group_name'))
  66. },
  67. {'name': 'change_comment',
  68. 'message': _("Comment for group {unix.ur_unix_group_name} changed to "
  69. "{unix.ur_unix_group_comment}"),
  70. 'method': 'Unix.update_group_comment(unix.ur_unix_group_name,'
  71. 'unix.ur_unix_group_comment)',
  72. 'condition': lambda Get: Get('unix.ur_unix_group_comment') != Get(
  73. 'unix.ur_unix_group_comment_exists')
  74. },
  75. {'name': 'group_change_id',
  76. 'message': _("Changed ID for group {unix.ur_unix_group_name} "
  77. "to {unix.ur_unix_group_id}"),
  78. 'method': 'Unix.update_group_id(unix.ur_unix_group_name,'
  79. 'unix.ur_unix_group_id,unix.ur_unix_group_id_exists)',
  80. 'condition': lambda Get: (Get('unix.ur_unix_group_id') != Get(
  81. 'unix.ur_unix_group_id_exists'))
  82. },
  83. ]