mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-22 09:24:21 +01:00
fixing typos in role files
This commit is contained in:
parent
804e2b7202
commit
d74893d104
@ -12,8 +12,11 @@ class MissingParameter(Exception):
|
|||||||
self.log = "missing parameter <%(key)s> in section <%(section)s>" % { 'key' : key, 'section' : section }
|
self.log = "missing parameter <%(key)s> in section <%(section)s>" % { 'key' : key, 'section' : section }
|
||||||
|
|
||||||
class MissingKey(Exception):
|
class MissingKey(Exception):
|
||||||
def __init__(self, key):
|
def __init__(self, key, section, ymlfile):
|
||||||
self.key = key
|
self.key = key
|
||||||
|
self.section = section
|
||||||
|
self.ymlfile = ymlfile
|
||||||
|
self.log = "missing key <%(key)s> in section <%(section)s> inside file <%(ymlfile)s>" % {'key': key, 'section': section, 'ymlfile': ymlfile }
|
||||||
|
|
||||||
class DumplicateRoleKey(Exception):
|
class DumplicateRoleKey(Exception):
|
||||||
def __init__(self, role):
|
def __init__(self, role):
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from sets import Set
|
||||||
from ldapcherry.pyyamlwrapper import loadNoDump
|
from ldapcherry.pyyamlwrapper import loadNoDump
|
||||||
from ldapcherry.pyyamlwrapper import DumplicatedKey
|
from ldapcherry.pyyamlwrapper import DumplicatedKey
|
||||||
from ldapcherry.exceptions import DumplicateRoleKey, MissingKey, DumplicateRoleContent, MissingRolesFile
|
from ldapcherry.exceptions import DumplicateRoleKey, MissingKey, DumplicateRoleContent, MissingRolesFile
|
||||||
@ -16,6 +17,8 @@ from ldapcherry.exceptions import DumplicateRoleKey, MissingKey, DumplicateRoleC
|
|||||||
class Roles:
|
class Roles:
|
||||||
|
|
||||||
def __init__(self, role_file):
|
def __init__(self, role_file):
|
||||||
|
self.role_file = role_file
|
||||||
|
self.backends = Set([])
|
||||||
try:
|
try:
|
||||||
stream = open(role_file, 'r')
|
stream = open(role_file, 'r')
|
||||||
except:
|
except:
|
||||||
@ -29,6 +32,24 @@ class Roles:
|
|||||||
|
|
||||||
def _nest(self):
|
def _nest(self):
|
||||||
"""nests the roles (creates roles hierarchy)"""
|
"""nests the roles (creates roles hierarchy)"""
|
||||||
|
for roleid in self.roles_raw:
|
||||||
|
role = self.roles_raw[roleid]
|
||||||
|
|
||||||
|
# Display name is mandatory
|
||||||
|
if not 'display_name' in role:
|
||||||
|
raise MissingKey('display_name', role, self.role_file)
|
||||||
|
|
||||||
|
# Backend is mandatory
|
||||||
|
if not 'backends' in role:
|
||||||
|
raise MissingKey('backends', role, self.role_file)
|
||||||
|
|
||||||
|
# Create the list of backends
|
||||||
|
for backend in role['backends']:
|
||||||
|
self.backends.add(backend['name'])
|
||||||
|
|
||||||
|
# Create the nested groups
|
||||||
|
for roleid2 in self.roles_raw:
|
||||||
|
role2 = self.roles_raw[roleid2]
|
||||||
self.roles = self.roles_raw
|
self.roles = self.roles_raw
|
||||||
|
|
||||||
def write(self, out_file):
|
def write(self, out_file):
|
||||||
|
@ -2,13 +2,13 @@ admin-lv3:
|
|||||||
display_name: Administrators Level 3
|
display_name: Administrators Level 3
|
||||||
LC_admins: True
|
LC_admins: True
|
||||||
backends:
|
backends:
|
||||||
- backend_name: ldap
|
- name: ldap
|
||||||
groups:
|
groups:
|
||||||
- cn=dns admins,ou=group,dc=example,dc=com
|
- cn=dns admins,ou=group,dc=example,dc=com
|
||||||
- cn=nagios admins,ou=group,dc=example,dc=com
|
- cn=nagios admins,ou=group,dc=example,dc=com
|
||||||
- cn=puppet admins,ou=group,dc=example,dc=com
|
- cn=puppet admins,ou=group,dc=example,dc=com
|
||||||
- cn=users,ou=group,dc=example,dc=com
|
- cn=users,ou=group,dc=example,dc=com
|
||||||
- backend_name: ad
|
- name: ad
|
||||||
groups:
|
groups:
|
||||||
- Domain Users
|
- Domain Users
|
||||||
- Administrators
|
- Administrators
|
||||||
@ -17,32 +17,32 @@ admin-lv3:
|
|||||||
admin-lv2:
|
admin-lv2:
|
||||||
display_name: Administrators Level 2
|
display_name: Administrators Level 2
|
||||||
backends:
|
backends:
|
||||||
- backend_name: ldap
|
- name: ldap
|
||||||
groups:
|
groups:
|
||||||
- cn=nagios admins,ou=group,dc=example,dc=com
|
- cn=nagios admins,ou=group,dc=example,dc=com
|
||||||
- cn=users,ou=group,dc=example,dc=com
|
- cn=users,ou=group,dc=example,dc=com
|
||||||
- backend_name: ad
|
- name: ad
|
||||||
groups:
|
groups:
|
||||||
- Domain Users
|
- Domain Users
|
||||||
|
|
||||||
developpers:
|
developpers:
|
||||||
diplay_name: Developpers
|
display_name: Developpers
|
||||||
backends:
|
backends:
|
||||||
- backend_name: ldap
|
- name: ldap
|
||||||
groups:
|
groups:
|
||||||
- cn=nagios user,ou=group,dc=example,dc=com
|
- cn=nagios user,ou=group,dc=example,dc=com
|
||||||
- cn=developpers,ou=group,dc=example,dc=com
|
- cn=developpers,ou=group,dc=example,dc=com
|
||||||
- cn=users,ou=group,dc=example,dc=com
|
- cn=users,ou=group,dc=example,dc=com
|
||||||
- backend_name: ad
|
- name: ad
|
||||||
groups:
|
groups:
|
||||||
- Domain Users
|
- Domain Users
|
||||||
|
|
||||||
users:
|
users:
|
||||||
diplay_name: Simple Users
|
display_name: Simple Users
|
||||||
backends:
|
backends:
|
||||||
- backend_name: ldap
|
- name: ldap
|
||||||
groups:
|
groups:
|
||||||
- cn=users,ou=group,dc=example,dc=com
|
- cn=users,ou=group,dc=example,dc=com
|
||||||
- backend_name: ad
|
- name: ad
|
||||||
groups:
|
groups:
|
||||||
- Domain Users
|
- Domain Users
|
||||||
|
Loading…
Reference in New Issue
Block a user