'Creates a new agent build.'

@extensions.expected_errors((400, 409))
@wsgi.response(200)
@validation.schema(schema.create)
def create(self, req, body):

    context = req.environ['nova.context']
    context.can(agents_policies.BASE_POLICY_NAME)
    agent = body['agent']
    hypervisor = agent['hypervisor']
    os = agent['os']
    architecture = agent['architecture']
    version = agent['version']
    url = agent['url']
    md5hash = agent['md5hash']
    agent_obj = objects.Agent(context=context)
    agent_obj.hypervisor = hypervisor
    agent_obj.os = os
    agent_obj.architecture = architecture
    agent_obj.version = version
    agent_obj.url = url
    agent_obj.md5hash = md5hash
    try:
        agent_obj.create()
        agent['agent_id'] = agent_obj.id
    except exception.AgentBuildExists as ex:
        raise webob.exc.HTTPConflict(explanation=ex.format_message())
    return {'agent': agent}
