<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def kernels(gandi, vm, datacenter, flavor, match):
 """List available kernels."""


    if vm:
        vm = gandi.iaas.info(vm)

    dc_list = gandi.datacenter.filtered_list(datacenter, vm)

    for num, dc in enumerate(dc_list):
        if num:
            gandi.echo('\n')
        output_datacenter(gandi, dc, ['dc_name'])
        kmap = gandi.kernel.list(dc['id'], flavor, match)
        for _flavor in kmap:
            gandi.separator_line()
            output_kernels(gandi, _flavor, kmap[_flavor])