'revert a volume to a snapshot'

@wrap_check_policy
def revert_to_snapshot(self, context, volume, snapshot):

    v_res = volume.update_single_status_where('reverting', 'available')
    if (not v_res):
        msg = (_("Can't    revert    volume    %s    to    its    latest    snapshot.    Volume's    status    must    be    'available'.") % volume.id)
        raise exception.InvalidVolume(reason=msg)
    s_res = snapshot.update_single_status_where(fields.SnapshotStatus.RESTORING, fields.SnapshotStatus.AVAILABLE)
    if (not s_res):
        msg = (_("Can't    revert    volume    %s    to    its    latest    snapshot.    Snapshot's    status    must    be    'available'.") % snapshot.id)
        raise exception.InvalidSnapshot(reason=msg)
    self.volume_rpcapi.revert_to_snapshot(context, volume, snapshot)
