def get_ports_and_sgs(context, port_ids):
 if (len(port_ids) > MAX_PORTS_PER_QUERY):
  LOG.debug('Number of ports %(pcount)s exceeds the maximum per query %(maxp)s. Partitioning queries.', {'pcount': len(port_ids), 'maxp': MAX_PORTS_PER_QUERY})
  return (get_ports_and_sgs(context, port_ids[:MAX_PORTS_PER_QUERY]) + get_ports_and_sgs(context, port_ids[MAX_PORTS_PER_QUERY:]))
 LOG.debug('get_ports_and_sgs() called for port_ids %s', port_ids)
 if (not port_ids):
  return []
 ports_to_sg_ids = get_sg_ids_grouped_by_port(context, port_ids)
 return [make_port_dict_with_security_groups(port, sec_groups) for (port, sec_groups) in six.iteritems(ports_to_sg_ids)]

def get_ports_and_sgs ( context , port_ids ) : if ( len ( port_ids ) > MAX_PORTS_PER_QUERY ) : LOG . debug ( 'Number of ports %(pcount)s exceeds the maximum per query %(maxp)s. Partitioning queries.' , { 'pcount' : len ( port_ids ) , 'maxp' : MAX_PORTS_PER_QUERY } ) return ( get_ports_and_sgs ( context , port_ids [ : MAX_PORTS_PER_QUERY ] ) + get_ports_and_sgs ( context , port_ids [ MAX_PORTS_PER_QUERY : ] ) ) LOG . debug ( 'get_ports_and_sgs() called for port_ids %s' , port_ids ) if ( not port_ids ) : return [ ] ports_to_sg_ids = get_sg_ids_grouped_by_port ( context , port_ids ) return [ make_port_dict_with_security_groups ( port , sec_groups ) for ( port , sec_groups ) in six . iteritems ( ports_to_sg_ids ) ]
get ports from database with security group info .