'Return a list of all agent builds. Filter by hypervisor.'

@extensions.expected_errors(())
def index(self, req):

    context = req.environ['nova.context']
    context.can(agents_policies.BASE_POLICY_NAME)
    hypervisor = None
    agents = []
    if ('hypervisor' in req.GET):
        hypervisor = req.GET['hypervisor']
    builds = objects.AgentList.get_all(context, hypervisor=hypervisor)
    for agent_build in builds:
        agents.append({'hypervisor': agent_build.hypervisor, 'os': agent_build.os, 'architecture': agent_build.architecture, 'version': agent_build.version, 'md5hash': agent_build.md5hash, 'agent_id': agent_build.id, 'url': agent_build.url})
    return {'agents': agents}
