'Expand a remote group rule to rule per remote group IP.'

def _expand_sg_rule_with_remote_ips(self, rule, port, direction):

    remote_group_id = rule.get('remote_group_id')
    if remote_group_id:
        ethertype = rule['ethertype']
        port_ips = port.get('fixed_ips', [])
        for ip in self.sg_members[remote_group_id][ethertype]:
            if (ip not in port_ips):
                ip_rule = rule.copy()
                direction_ip_prefix = firewall.DIRECTION_IP_PREFIX[direction]
                ip_prefix = str(netaddr.IPNetwork(ip).cidr)
                ip_rule[direction_ip_prefix] = ip_prefix
                (yield ip_rule)
    else:
        (yield rule)
