'Lists all agent builds.
arguments: <none>'

@args('--hypervisor', metavar='<hypervisor>', help='hypervisor(default:    None)')
def list(self, hypervisor=None):

    fmt = '%-10s        %-8s        %12s        %s'
    ctxt = context.get_admin_context()
    by_hypervisor = {}
    for agent_build in db.agent_build_get_all(ctxt):
        buildlist = by_hypervisor.get(agent_build.hypervisor)
        if (not buildlist):
            buildlist = by_hypervisor[agent_build.hypervisor] = []
        buildlist.append(agent_build)
    for (key, buildlist) in by_hypervisor.items():
        if (hypervisor and (key != hypervisor)):
            continue
        print((_('Hypervisor:    %s') % key))
        print((fmt % (('-' * 10), ('-' * 8), ('-' * 12), ('-' * 32))))
        for agent_build in buildlist:
            print((fmt % (agent_build.os, agent_build.architecture, agent_build.version, agent_build.md5hash)))
            print(('                %s' % agent_build.url))
        print()
