def get_id_from_context(context): if 'ds_id' in context: # Note(thread-safety): blocking call ds_name = db_datasources.get_datasource_name(context.get('ds_id')) return ds_name, context.get('ds_id') elif 'policy_id' in context: return base.ENGINE_SERVICE_ID, context.get('policy_id') else: msg = "Internal error: context %s should have included " % str(context) "either ds_id or policy_id" try: # Py3: ensure LOG.exception is inside except raise webservice.DataModelException('404', msg) except webservice.DataModelException: LOG.exception(msg) raise
def get_id_from_context(context, datasource_mgr=None, policy_engine=None): if cfg.CONF.distributed_architecture: datasource_mgr = db_datasources.get_datasource_name( context.get('ds_id')) if 'ds_id' in context: return datasource_mgr, context.get('ds_id') elif 'policy_id' in context: return policy_engine, context.get('policy_id') else: msg = "Internal error: context %s should have included " % str(context) "either ds_id or policy_id" try: # Py3: ensure LOG.exception is inside except raise webservice.DataModelException('404', msg) except webservice.DataModelException: LOG.exception(msg) raise