#NEWLINE# def _convert_remote_group_id_to_ip_prefix( self , context , ports ) : #NEWLINE# #INDENT# remote_group_ids = self . _select_remote_group_ids ( ports ) #NEWLINE# ips = self . _select_ips_for_remote_group ( context , remote_group_ids ) #NEWLINE# for port in ports . values ( ) : #NEWLINE# #INDENT# updated_rule = [ ] #NEWLINE# for rule in port . get ( 'security_group_rules' ) : #NEWLINE# #INDENT# remote_group_id = rule . get ( 'remote_group_id' ) #NEWLINE# direction = rule . get ( 'direction' ) #NEWLINE# direction_ip_prefix = DIRECTION_IP_PREFIX [ direction ] #NEWLINE# if ( not remote_group_id ) : #NEWLINE# #INDENT# updated_rule . append ( rule ) #NEWLINE# continue #NEWLINE# #UNINDENT# port [ 'security_group_source_groups' ] . append ( remote_group_id ) #NEWLINE# base_rule = self #NEWLINE# for ip in ips [ remote_group_id ] : #NEWLINE# #INDENT# if ( ip in port . get ( 'fixed_ips' , [ ] ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ip_rule = base_rule . copy ( ) #NEWLINE# version = netaddr . IPNetwork ( ip ) . version #NEWLINE# ethertype = ( 'IPv%s' % version ) #NEWLINE# if ( base_rule [ 'ethertype' ] != ethertype ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ip_rule [ direction_ip_prefix ] = str ( netaddr . IPNetwork ( ip ) . cidr ) #NEWLINE# updated_rule . append ( ip_rule ) #NEWLINE# #UNINDENT# #UNINDENT# port [ 'security_group_rules' ] = updated_rule #NEWLINE# #UNINDENT# return ports