'Creates an aggregate, given its name and
optional availability zone.'

@extensions.expected_errors((400, 409))
@validation.schema(aggregates.create_v20, '2.0', '2.0')
@validation.schema(aggregates.create, '2.1')
def create(self, req, body):

    context = _get_context(req)
    context.can((aggr_policies.POLICY_ROOT % 'create'))
    host_aggregate = body['aggregate']
    name = common.normalize_name(host_aggregate['name'])
    avail_zone = host_aggregate.get('availability_zone')
    if avail_zone:
        avail_zone = common.normalize_name(avail_zone)
    try:
        aggregate = self.api.create_aggregate(context, name, avail_zone)
    except exception.AggregateNameExists as e:
        raise exc.HTTPConflict(explanation=e.format_message())
    except exception.ObjectActionError:
        raise exc.HTTPConflict(explanation=_('Not    all    aggregates    have    been    migrated    to    the    API    database'))
    except exception.InvalidAggregateAction as e:
        raise exc.HTTPBadRequest(explanation=e.format_message())
    agg = self._marshall_aggregate(req, aggregate)
    del agg['aggregate']['hosts']
    del agg['aggregate']['metadata']
    return agg
