Exemple #1
0
    def __init__(self, db, config, cluster_name):

        UserImporter.__init__(self, db, cluster_name)

        self._db = db
        self._conf = config
        self._cluster_name = cluster_name

        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._auth_cert = config.get(ldap_section, "auth_cert")
        self._ldapcert = config.get(ldap_section, "cert")
        self._ldapgroup = config.get(ldap_section, "group")
       
        try:            
            ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, self._ldapcert)
            self._ldapconn = ldap.initialize(self._ldapurl)
            self._ldapconn.simple_bind(self._ldapdn, base64.b64decode(self.decypher(base64.b64decode(self._ldaphash))))
        except ldap.SERVER_DOWN as e:
            logging.error("connection to LDAP failed: %s", e)
            raise RuntimeError
Exemple #2
0
    def __init__(self, db, config, cluster_name):

        UserImporter.__init__(self)

        self._db = db
        self._conf = config
        self._cluster_name = cluster_name

        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._ldappass = config.get(ldap_section,"password")
        self._ldapconn = ldap.initialize(self._ldapurl)
        self._ldapconn.simple_bind(self._ldapdn, self._ldappass)
    def __init__(self, db, config, cluster_name):

        UserImporter.__init__(self, db, cluster_name)

        self._conf = config

        ldap_section = self._cluster_name + "/ldap"
        xls_section = self._cluster_name + "/xls"
        db_section = self._cluster_name + "/slurm"

        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._auth_cert = config.get(ldap_section, "auth_cert")
        self._ldapcert = config.get(ldap_section, "cert")
        self._ldapgroup = config.get(ldap_section, "group")      
        try:            
            ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, self._ldapcert)
            self._ldapconn = ldap.initialize(self._ldapurl)
            self._ldapconn.simple_bind(self._ldapdn, base64.b64decode(self.decypher(base64.b64decode(self._ldaphash))))
        except ldap.SERVER_DOWN as e:
            logging.error("connection to LDAP failed: %s", e)
            raise RuntimeError        

        self._xlsfile = config.get(xls_section,"file")
        self._xlssheetname = config.get(xls_section,"sheet")
        self._xlsworkbook = xlrd.open_workbook(self._xlsfile)
        self._xlssheet = self._xlsworkbook.sheet_by_name(self._xlssheetname)

        self._dbhost = config.get(db_section,"host")
        self._dbport = int(config.get(db_section,"port"))
        self._dbname = config.get(db_section,"name")
        self._dbuser = config.get(db_section,"user")
        self._dbpass = config.get(db_section,"password")
        try:
            self._conn = MySQLdb.connect( host = self._dbhost,
                                          user = self._dbuser,
                                          passwd = self._dbpass,
                                          db = self._dbname,
                                          port = self._dbport )
        except _mysql_exceptions.OperationalError as e:
            logging.error("connection to Slurm DBD MySQL failed: %s", e)
            raise RuntimeError
        self._cur = self._conn.cursor(MySQLdb.cursors.DictCursor)