def list(gandi, limit, format):
    """ List webaccelerators """
    options = {
        'items_per_page': limit,
    }

    result = gandi.webacc.list(options)
    if format:
        output_json(gandi, format, result)
        return result

    output_keys = ['name', 'state', 'ssl']
    for num, webacc in enumerate(result):
        if num:
            gandi.separator_line('-', 4)

        webacc['ssl'] = 'Enabled' if webacc['ssl_enable'] else 'Disable'
        output_generic(gandi, webacc, output_keys, justify=14)

        gandi.echo('Vhosts :')
        for vhost in webacc['vhosts']:
            output_vhosts = ['vhost', 'ssl']
            vhost['vhost'] = vhost['name']
            vhost['ssl'] = 'Disable' if vhost['cert_id'] is None else 'Enabled'
            output_sub_generic(gandi, vhost, output_vhosts,
                               justify=14)
            gandi.echo('')

        gandi.echo('Backends :')
        for server in webacc['servers']:
            try:
                ip = gandi.ip.info(server['ip'])
                iface = gandi.iface.info(ip['iface_id'])
                vm_info = gandi.iaas.info(iface['vm_id'])
                server['name'] = vm_info['hostname']
                output_servers = ['name', 'ip', 'port', 'state']
            except Exception:
                warningmsg = ('\tBackend with ip address %s no longer '
                              'exists.\n\tYou should remove it.'
                              % server['ip'])
                gandi.echo(warningmsg)
                output_servers = ['ip', 'port', 'state']
            output_sub_generic(gandi, server, output_servers,
                               justify=14)
            gandi.echo('')
    return result
List webaccelerators