#NEWLINE# def index( self , req , server_id ) : #NEWLINE# #INDENT# 'Returns a list of security groups for the given instance.' #NEWLINE# context = _authorize_context ( req ) #NEWLINE# self . security_group_api . ensure_default ( context ) #NEWLINE# with translate_exceptions ( ) : #NEWLINE# #INDENT# instance = common . get_instance ( self . compute_api , context , server_id ) #NEWLINE# groups = self . security_group_api . get_instance_security_groups ( context , instance , True ) #NEWLINE# #UNINDENT# result = [ self . _format_security_group ( context , group ) for group in groups ] #NEWLINE# return { #NEWLINE# #INDENT# 'security_groups' : list ( sorted ( result , key = ( lambda k : ( k [ 'tenant_id' ] , k [ 'name' ] ) ) ) ) , #NEWLINE# #UNINDENT# }