'Update the properties of an aggregate.'

@wrap_exception()
def update_aggregate(self, context, aggregate_id, values):

    aggregate = objects.Aggregate.get_by_id(context, aggregate_id)
    if ('name' in values):
        aggregate.name = values.pop('name')
        aggregate.save()
    self.is_safe_to_update_az(context, values, aggregate=aggregate, action_name=AGGREGATE_ACTION_UPDATE)
    if values:
        aggregate.update_metadata(values)
        aggregate.updated_at = timeutils.utcnow()
    self.scheduler_client.update_aggregates(context, [aggregate])
    if values.get('availability_zone'):
        availability_zones.reset_cache()
    return aggregate
