Esempio n. 1
0
 def __get_backend(self):
     """Get the actual backend.  May be a module or an instance of
     a class.  Doesn't matter to us.  We do this synchronized as it's
     possible multiple greenthreads started very quickly trying to do
     DB calls and eventlet can switch threads before self.__backend gets
     assigned.
     """
     if self.__backend:
         # Another thread assigned it
         return self.__backend
     backend_name = CONF.database.backend
     self.__use_tpool = CONF.database.use_tpool
     if self.__use_tpool:
         from eventlet import tpool
         self.__tpool = tpool
     # Import the untranslated name if we don't have a
     # mapping.
     backend_path = self.__backend_mapping.get(backend_name,
                                               backend_name)
     backend_mod = importutils.import_module(backend_path)
     self.__backend = backend_mod.get_backend()
     return self.__backend
Esempio n. 2
0
 def __init__(self, hashtype='SHA256'):
     self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype)
     self.max_okm_length = 255 * self.hashfn.digest_size
Esempio n. 3
0
 def __init__(self, enctype='AES', hashtype='SHA256'):
     self.cipher = importutils.import_module('Crypto.Cipher.' + enctype)
     self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype)