コード例 #1
0
ファイル: UserImporterLdap.py プロジェクト: edf-hpc/hpcstats
    def __init__(self, app, db, config, cluster):

        super(UserImporterLdap, self).__init__(app, db, config, cluster)

        ldap_section = self.cluster.name + '/ldap'

        self._ldapurl = config.get(ldap_section, 'url')
        self._ldapbase = config.get(ldap_section, 'basedn')
        self._ldapdn = config.get(ldap_section, 'dn')
        self._ldaphash = config.get(ldap_section, 'phash')
        self.ldap_password = \
          base64.b64decode(decypher(base64.b64decode(self._ldaphash)))
        self._ldapcert = config.get_default(ldap_section, 'cert', None)

        self._ldapgroups = []
        group_list = config.get_default(ldap_section, 'groups', None)
        if group_list is not None:
            self._ldapgroups = group_list.split(',')
        single_ldapgroup = config.get_default(ldap_section, 'group', None)
        if single_ldapgroup is not None:
            self.log.warn(Errors.E_U0005,
                          "Deprecated config option,"
                          "'group' is replaced by 'groups'")
            self._ldapgroups += [single_ldapgroup]

        self.ldap_rdn_people = config.get_default(ldap_section,
                                                  'rdn_people',
                                                  'ou=people')
        self.ldap_rdn_groups = config.get_default(ldap_section,
                                                  'rdn_groups',
                                                  'ou=groups')

        self.ldap_dn_people = self.ldap_rdn_people + ',' + self._ldapbase
        self.ldap_dn_groups = self.ldap_rdn_groups + ',' + self._ldapbase
        self.group_dpt_search = config.get(ldap_section, 'group_dpt_search')
        self.group_dpt_regexp = config.get(ldap_section, 'group_dpt_regexp')
        self.default_subdir = config.get_default(ldap_section,
                                                 'default_subdir',
                                                 'unknown')

        self.strict_user_membership = config.get_default( \
                                               'constraints',
                                               'strict_user_membership',
                                               True,
                                               bool)

        self.groups_alias_file = config.get_default(ldap_section,
                                                    'groups_alias_file',
                                                    None)
        self.groups_alias = {} # hash of aliases

        self.users_acct_ldap = None
        self.users_acct_db = None

        self.ldap_conn = None
コード例 #2
0
from HPCStats.Tests.Mocks.Conf import MockConf
from HPCStats.Tests.Mocks.App import MockApp

CONFIG = {
  'hpcstatsdb': {
    'hostname': 'test_hostname',
    'port':     'test_port',
    'dbname':   'test_name',
    'user':     '******',
    'password': '******',
  },
  'testcluster/ldap': {
    'url': 'test_url',
    'basedn': 'test_basedn',
    'dn': 'test_dn',
    'phash': base64.b64encode(decypher(base64.b64encode('test_passwd'))),
    'groups': 'test_groupA,test_groupB',
    'group_dpt_search': 'test_group_dpt_search',
    'group_dpt_regexp': 'cn=(.+)-dp-(.+),ou.*',
  },
  'testcluster/slurm': {
    'host': 'dbhost',
    'port': 3128,
    'name': 'dbname',
    'user': '******',
    'password': '******'
  }
}

MockMySQLdb.MY_REQS['get_users'] = {
  'req': "SELECT DISTINCT user " \