'Update volume readonly flag.'

@wsgi.action('os-update_readonly_flag')
def _volume_readonly_update(self, req, id, body):

    context = req.environ['cinder.context']
    volume = self.volume_api.get(context, id)
    try:
        readonly_flag = body['os-update_readonly_flag']['readonly']
    except KeyError:
        msg = _('Must    specify    readonly    in    request.')
        raise webob.exc.HTTPBadRequest(explanation=msg)
    try:
        readonly_flag = strutils.bool_from_string(readonly_flag, strict=True)
    except ValueError as error:
        err_msg = encodeutils.exception_to_unicode(error)
        msg = (_("Invalid    value    for    'readonly':    '%s'") % err_msg)
        raise webob.exc.HTTPBadRequest(explanation=msg)
    self.volume_api.update_readonly_flag(context, volume, readonly_flag)
    return webob.Response(status_int=http_client.ACCEPTED)
