#NEWLINE# def keypair_field_data( request , include_empty_option = False ) : #NEWLINE# #INDENT# 'Returns a list of tuples of all keypairs.\n\n    Generates a list of keypairs available to the user (request). And returns\n    a list of (id, name) tuples.\n\n    :param request: django http request object\n    :param include_empty_option: flag to include a empty tuple in the front of\n        the list\n    :return: list of (id, name) tuples\n    ' #NEWLINE# keypair_list = [ ] #NEWLINE# try : #NEWLINE# #INDENT# keypairs = api . nova . keypair_list ( request ) #NEWLINE# keypair_list = [ ( kp . name , kp . name ) for kp in keypairs ] #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# exceptions . handle ( request , _ ( 'Unable to retrieve key pairs.' ) ) #NEWLINE# #UNINDENT# if ( not keypair_list ) : #NEWLINE# #INDENT# if include_empty_option : #NEWLINE# #INDENT# return [ ( '' , _ ( 'No key pairs available' ) ) ] #NEWLINE# #UNINDENT# return [ ] #NEWLINE# #UNINDENT# if include_empty_option : #NEWLINE# #INDENT# return ( [ ( '' , _ ( 'Select a key pair' ) ) ] + request ) #NEWLINE# #UNINDENT# return keypair_list