def _get_request_audit_info(context, user_id=None):
 remote_addr = None
 http_user_agent = None
 project_id = None
 domain_id = None
 if (context and ('environment' in context) and context['environment']):
  environment = context['environment']
  remote_addr = environment.get('REMOTE_ADDR')
  http_user_agent = environment.get('HTTP_USER_AGENT')
  if (not user_id):
   user_id = environment.get('KEYSTONE_AUTH_CONTEXT', {}).get('user_id')
  project_id = environment.get('KEYSTONE_AUTH_CONTEXT', {}).get('project_id')
  domain_id = environment.get('KEYSTONE_AUTH_CONTEXT', {}).get('domain_id')
 host = pycadf.host.Host(address=remote_addr, agent=http_user_agent)
 initiator = resource.Resource(typeURI=taxonomy.ACCOUNT_USER, host=host)
 if user_id:
  initiator.user_id = user_id
  initiator.id = utils.resource_uuid(user_id)
 if project_id:
  initiator.project_id = project_id
 if domain_id:
  initiator.domain_id = domain_id
 return initiator

def _get_request_audit_info ( context , user_id = None ) : remote_addr = None http_user_agent = None project_id = None domain_id = None if ( context and ( 'environment' in context ) and context [ 'environment' ] ) : environment = context [ 'environment' ] remote_addr = environment . get ( 'REMOTE_ADDR' ) http_user_agent = environment . get ( 'HTTP_USER_AGENT' ) if ( not user_id ) : user_id = environment . get ( 'KEYSTONE_AUTH_CONTEXT' , { } ) . get ( 'user_id' ) project_id = environment . get ( 'KEYSTONE_AUTH_CONTEXT' , { } ) . get ( 'project_id' ) domain_id = environment . get ( 'KEYSTONE_AUTH_CONTEXT' , { } ) . get ( 'domain_id' ) host = pycadf . host . Host ( address = remote_addr , agent = http_user_agent ) initiator = resource . Resource ( typeURI = taxonomy . ACCOUNT_USER , host = host ) if user_id : initiator . user_id = user_id initiator . id = utils . resource_uuid ( user_id ) if project_id : initiator . project_id = project_id if domain_id : initiator . domain_id = domain_id return initiator
collect audit information about the request used for cadf .