'Updates the aggregate metadata.'

@wrap_exception()
def update_aggregate_metadata(self, context, aggregate_id, metadata):

    aggregate = objects.Aggregate.get_by_id(context, aggregate_id)
    self.is_safe_to_update_az(context, metadata, aggregate=aggregate, action_name=AGGREGATE_ACTION_UPDATE_META)
    aggregate.update_metadata(metadata)
    self.scheduler_client.update_aggregates(context, [aggregate])
    if (metadata and metadata.get('availability_zone')):
        availability_zones.reset_cache()
    aggregate.updated_at = timeutils.utcnow()
    return aggregate
