def keypair_field_data(request, include_empty_option=False):
 keypair_list = []
 try:
  keypairs = api.nova.keypair_list(request)
  keypair_list = [(kp.name, kp.name) for kp in keypairs]
 except Exception:
  exceptions.handle(request, _('Unable to retrieve key pairs.'))
 if (not keypair_list):
  if include_empty_option:
   return [('', _('No key pairs available'))]
  return []
 if include_empty_option:
  return ([('', _('Select a key pair'))] + keypair_list)
 return keypair_list

def keypair_field_data ( request , include_empty_option = False ) : keypair_list = [ ] try : keypairs = api . nova . keypair_list ( request ) keypair_list = [ ( kp . name , kp . name ) for kp in keypairs ] except Exception : exceptions . handle ( request , _ ( 'Unable to retrieve key pairs.' ) ) if ( not keypair_list ) : if include_empty_option : return [ ( '' , _ ( 'No key pairs available' ) ) ] return [ ] if include_empty_option : return ( [ ( '' , _ ( 'Select a key pair' ) ) ] + keypair_list ) return keypair_list
returns a list of tuples of all keypairs .