#NEWLINE# def _get_remote_sg_ids( self , port , direction = None ) : #NEWLINE# #INDENT# sg_ids = port . get ( 'security_groups' , [ ] ) #NEWLINE# remote_sg_ids = { #NEWLINE# #INDENT# constants . IPv4 : set ( ) , #NEWLINE# constants . IPv6 : set ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# for sg_id in direction : #NEWLINE# #INDENT# for rule in self . sg_rules . get ( sg_id , [ ] ) : #NEWLINE# #INDENT# if ( ( not direction ) or ( rule [ 'direction' ] == direction ) ) : #NEWLINE# #INDENT# remote_sg_id = rule . get ( 'remote_group_id' ) #NEWLINE# ether_type = rule . get ( 'ethertype' ) #NEWLINE# if ( remote_sg_id and ether_type ) : #NEWLINE# #INDENT# remote_sg_ids [ ether_type ] . add ( remote_sg_id ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return remote_sg_ids