def get_backend_instance(name): backend_kwargs = cfg.CONF.auth.backend_kwargs if backend_kwargs: try: kwargs = json.loads(backend_kwargs) except ValueError as e: raise ValueError('Failed to JSON parse backend settings for backend "%s": %s' % (name, six.text_type(e))) else: kwargs = {} cls = driver_loader.get_backend_driver(namespace=BACKENDS_NAMESPACE, name=name) try: cls_instance = cls(**kwargs) except Exception as e: tb_msg = traceback.format_exc() class_name = cls.__name__ msg = ('Failed to instantiate auth backend "%s" (class %s) with backend settings ' '"%s": %s' % (name, class_name, str(kwargs), six.text_type(e))) msg += '\n\n' + tb_msg exc_cls = type(e) raise exc_cls(msg) return cls_instance
def get_backend_instance(name): backend_kwargs = cfg.CONF.auth.backend_kwargs if backend_kwargs: try: kwargs = json.loads(backend_kwargs) except ValueError as e: raise ValueError( 'Failed to JSON parse backend settings for backend "%s": %s' % (name, six.text_type(e))) else: kwargs = {} cls = driver_loader.get_backend_driver(namespace=BACKENDS_NAMESPACE, name=name) try: cls_instance = cls(**kwargs) except Exception as e: tb_msg = traceback.format_exc() class_name = cls.__name__ msg = ( 'Failed to instantiate auth backend "%s" (class %s) with backend settings ' '"%s": %s' % (name, class_name, str(kwargs), six.text_type(e))) msg += '\n\n' + tb_msg exc_cls = type(e) raise exc_cls(msg) return cls_instance
def get_backend_driver(name): return driver_loader.get_backend_driver(namespace=BACKENDS_NAMESPACE, name=name)