I just want to check with you if my understanding is correct:

In Python, the call to rename perspective_job_rename returns an array of
None of the same length as the list of files. This is converted into a list
of nulls in JSON and this is why we need to check it against the mapped
call list.

Is it right? Maybe it'd be worth including a comment, as receiving a list
of nulls is a bit unexpected.

Otherwise, LGTM, thanks.


On Thu, Jan 23, 2014 at 11:01 PM, Klaus Aehlig <[email protected]> wrote:

> On sucess, jobqueue_rename returns a list containing one
> null per change request.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/Rpc.hs | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/src/Ganeti/Rpc.hs b/src/Ganeti/Rpc.hs
> index 598b76f..a6a95a8 100644
> --- a/src/Ganeti/Rpc.hs
> +++ b/src/Ganeti/Rpc.hs
> @@ -621,11 +621,13 @@ instance RpcCall RpcCallJobqueueRename where
>    rpcCallData _ call     = J.encode [ rpcCallJobqueueRenameRename call ]
>
>  instance Rpc RpcCallJobqueueRename RpcResultJobqueueRename where
> -  rpcResultFill _ res =
> -    case res of
> -      J.JSNull -> Right RpcResultJobqueueRename
> -      _ -> Left $ JsonDecodeError
> -           ("Expected JSNull, got " ++ show (pp_value res))
> +  rpcResultFill call res =
> +    let expected = J.showJSON . map (const J.JSNull)
> +                     $ rpcCallJobqueueRenameRename call
> +    in if res == expected
> +      then Right RpcResultJobqueueRename
> +      else Left
> +             $ JsonDecodeError ("Expected JSNull, got " ++ show (pp_value
> res))
>
>  -- ** Watcher Status Update
>
> --
> 1.8.5.3
>
>

Reply via email to