anchor.diff:      ExistingClusters = get_remote_clusters(),
       case validate_remote_cluster_params(Params, ExistingClusters) of
           {ok, KVList} ->
  -            case JustValidate of
  -                undefined ->
  -                    NewClusters = [KVList | ExistingClusters],
  -                    case cas_remote_clusters(ExistingClusters, NewClusters) of
  -                        ok -> menelaus_util:reply_json(Req, build_remote_cluster_info(KVList));
  -                        _ -> do_handle_remote_clusters_post(Req, Params, JustValidate, TriesLeft-1)
  +            case validate_remote_cluster(KVList, ExistingClusters) of
  +                {ok, FinalKVList} ->
  +                    case JustValidate of
  +                        undefined ->
  +                            NewClusters = [FinalKVList | ExistingClusters],
  +
  +                            case cas_remote_clusters(ExistingClusters, NewClusters) of
  +                                ok ->
  +                                    menelaus_util:reply_json(Req,
  +                                                             build_remote_cluster_info(FinalKVList));
  +                                _ ->
  +                                    do_handle_remote_clusters_post(Req, Params,
  +                                                                   JustValidate, TriesLeft-1)
  +                            end;
  +                        _ ->
  +                            menelaus_util:reply_json(Req, [])
                       end;
  -                _ ->
  -                    menelaus_util:reply_json(Req, [])
  +                {errors, Status, Errors} ->
  +                    menelaus_util:reply_json(Req, Errors, Status)
               end;
           {errors, Errors} ->
               menelaus_util:reply_json(Req, Errors, 400)
  
positive.code:               {uri, URI},
                {validateURI, iolist_to_binary([URI, <<"?just_validate=1">>])},
                {hostname, list_to_binary(misc:expect_prop_value(hostname, KV))},
                {username, list_to_binary(misc:expect_prop_value(username, KV))}]}.
  
  handle_remote_clusters(Req) ->
      RemoteClusters = get_remote_clusters(),
  
negative.code: do_handle_remote_cluster_update_found_this(Id, Req, Params, JustValidate, OtherClusters, ExistingClusters, TriesLeft) ->
      case validate_remote_cluster_params(Params, OtherClusters) of
          {ok, KVList} ->
              case validate_remote_cluster(KVList, OtherClusters) of
                  {ok, FinalKVList} ->
                      case JustValidate of
                          undefined ->
                              NewClusters = [FinalKVList | OtherClusters],
  
                              case cas_remote_clusters(ExistingClusters, NewClusters) of
                                  ok ->
                                      menelaus_util:reply_json(
                                        Req, build_remote_cluster_info(FinalKVList));
                                  _ ->
                                      do_handle_remote_cluster_update(Id, Req, Params,
                                                                      JustValidate, TriesLeft-1)
                              end;
                          _ ->
                              menelaus_util:reply_json(Req, [])
                      end;
                  {errors, Status, Errors} ->
                      menelaus_util:reply_json(Req, Errors, Status)
              end;
          {errors, Errors} ->
              menelaus_util:reply_json(Req, Errors, 400)
      end.
  
  check_remote_cluster_already_exists(RemoteUUID, Clusters) ->
      case lists:dropwhile(
             fun (Cluster) ->
                     UUID = proplists:get_value(uuid, Cluster),
                     true = (UUID =/= undefined),
  
                     UUID =/= RemoteUUID
             end, Clusters) of
          [] ->
              ok;
          [Cluster | _] ->
              Name = proplists:get_value(name, Cluster),
              true = Name =/= undefined,
  
              [{<<"_">>,
                iolist_to_binary(
                  io_lib:format("Cluster reference to the same cluster already "
                                "exists under the name `~s`", [Name]))}]
      end.
  
  %% actually go to remote cluster to verify it; returns updated cluster
  %% proplist with uuid being added;
  validate_remote_cluster(Cluster, OtherClusters) ->
      case remote_clusters_info:fetch_remote_cluster(Cluster) of
          {ok, #remote_cluster{uuid=RemoteUUID}} ->
              case check_remote_cluster_already_exists(RemoteUUID, OtherClusters) of
                  ok ->
                      {ok, [{uuid, RemoteUUID} |
                            lists:keydelete(uuid, 1, Cluster)]};
                  Errors ->
                      {errors, 400, Errors}
              end;
          {error, timeout} ->
              Msg = <<"Timeout exceeded when trying to reach remote cluster">>,
              Errors = [{<<"_">>, Msg}],
              {errors, 500, Errors};
          {error, rest_error, Msg, _} ->
              Errors = [{<<"_">>, Msg}],
              {errors, 400, Errors};
          _ ->
              Errors = [{<<"_">>, <<"Unexpected error occurred. See logs for details.">>}],
              {errors, 500, Errors}
      end.
  
  handle_remote_cluster_delete(Id, Req) ->
  