@contextmanager
def target_cell(context, cell_mapping):
 original_db_connection = context.db_connection
 from nova import db
 db_connection_string = cell_mapping.database_connection
 context.db_connection = db.create_context_manager(db_connection_string)
 try:
  (yield context)
 finally:
  context.db_connection = original_db_connection

@ contextmanager def target_cell ( context , cell_mapping ) : original_db_connection = context . db_connection from nova import db db_connection_string = cell_mapping . database_connection context . db_connection = db . create_context_manager ( db_connection_string ) try : ( yield context ) finally : context . db_connection = original_db_connection
adds database connection information to the context for communicating with the given target cell .