'Update a volume.'

def update(self, req, id, body):

    context = req.environ['cinder.context']
    if (not body):
        msg = _('Missing    request    body')
        raise exc.HTTPBadRequest(explanation=msg)
    if ('volume' not in body):
        msg = (_("Missing    required    element    '%s'    in    request    body") % 'volume')
        raise exc.HTTPBadRequest(explanation=msg)
    volume = body['volume']
    update_dict = {}
    valid_update_keys = ('name', 'description', 'display_name', 'display_description', 'metadata')
    for key in valid_update_keys:
        if (key in volume):
            update_dict[key] = volume[key]
    self.validate_name_and_description(update_dict)
    if ('name' in update_dict):
        update_dict['display_name'] = update_dict.pop('name')
    if ('description' in update_dict):
        update_dict['display_description'] = update_dict.pop('description')
    try:
        volume = self.volume_api.get(context, id, viewable_admin_meta=True)
        volume_utils.notify_about_volume_usage(context, volume, 'update.start')
        self.volume_api.update(context, volume, update_dict)
    except exception.InvalidVolumeMetadataSize as error:
        raise webob.exc.HTTPRequestEntityTooLarge(explanation=error.msg)
    volume.update(update_dict)
    utils.add_visible_admin_metadata(volume)
    volume_utils.notify_about_volume_usage(context, volume, 'update.end')
    return self._view_builder.detail(req, volume)
