diff --git a/ocaml/xapi-cli-server/cli_operations.ml b/ocaml/xapi-cli-server/cli_operations.ml index 318e0f470f..f1120b21e6 100644 --- a/ocaml/xapi-cli-server/cli_operations.ml +++ b/ocaml/xapi-cli-server/cli_operations.ml @@ -4310,22 +4310,14 @@ let vm_migrate printer rpc session_id params = Client.Session.login_with_password remote_rpc username password "1.3" Constants.xapi_user_agent in + let remote f = f ~rpc:remote_rpc ~session_id:remote_session in finally (fun () -> let host = let host_matches x self = - let hostname () = - Client.Host.get_hostname ~rpc:remote_rpc - ~session_id:remote_session ~self - in - let uuid () = - Client.Host.get_uuid ~rpc:remote_rpc ~session_id:remote_session - ~self - in - let name_label () = - Client.Host.get_name_label ~rpc:remote_rpc - ~session_id:remote_session ~self - in + let hostname () = remote (Client.Host.get_hostname ~self) in + let uuid () = remote (Client.Host.get_uuid ~self) in + let name_label () = remote (Client.Host.get_name_label ~self) in hostname () = x || uuid () = x || name_label () = x in let matches, fail_msg = @@ -4337,9 +4329,7 @@ let vm_migrate printer rpc session_id params = , Printf.sprintf "Failed to find a suitable host" ) in - let all_hosts = - Client.Host.get_all ~rpc:remote_rpc ~session_id:remote_session - in + let all_hosts = remote Client.Host.get_all in match List.filter matches all_hosts with | host :: _ -> host @@ -4348,26 +4338,14 @@ let vm_migrate printer rpc session_id params = in let network = let network_matches x self = - let bridge () = - Client.Network.get_bridge ~rpc:remote_rpc - ~session_id:remote_session ~self - in - let uuid () = - Client.Network.get_uuid ~rpc:remote_rpc ~session_id:remote_session - ~self - in - let name_label () = - Client.Network.get_name_label ~rpc:remote_rpc - ~session_id:remote_session ~self - in + let bridge () = remote (Client.Network.get_bridge ~self) in + let uuid () = remote (Client.Network.get_uuid ~self) in + let name_label () = remote (Client.Network.get_name_label ~self) in bridge () = x || uuid () = x || name_label () = x in match List.assoc_opt "remote-network" params with | Some x -> ( - let all_networks = - Client.Network.get_all ~rpc:remote_rpc - ~session_id:remote_session - in + let all_networks = remote Client.Network.get_all in match List.filter (network_matches x) all_networks with | network :: _ -> network @@ -4375,33 +4353,21 @@ let vm_migrate printer rpc session_id params = failwith (Printf.sprintf "Failed to find network: %s" x) ) | None -> ( - let pifs = - Client.Host.get_PIFs ~rpc:remote_rpc ~session_id:remote_session - ~self:host - in + let pifs = remote (Client.Host.get_PIFs ~self:host) in let management_pifs = List.filter - (fun self -> - Client.PIF.get_management ~rpc:remote_rpc - ~session_id:remote_session ~self - ) + (fun self -> remote (Client.PIF.get_management ~self)) pifs in match management_pifs with | [] -> - let host_uuid = - Client.Host.get_uuid ~rpc:remote_rpc - ~session_id:remote_session ~self:host - in + let host_uuid = remote (Client.Host.get_uuid ~self:host) in failwith (Printf.sprintf "Could not find management PIF on host %s" host_uuid ) | pif :: _ -> - let net = - Client.PIF.get_network ~rpc:remote_rpc - ~session_id:remote_session ~self:pif - in + let net = remote (Client.PIF.get_network ~self:pif) in net ) in @@ -4445,47 +4411,32 @@ let vm_migrate printer rpc session_id params = in pool to host VMs), and then the one with the maximum available space *) try let pbd_in_host self = - let host_of () = - Client.PBD.get_host ~rpc:remote_rpc ~session_id:remote_session - ~self - in + let host_of () = remote (Client.PBD.get_host ~self) in let attached () = - Client.PBD.get_currently_attached ~rpc:remote_rpc - ~session_id:remote_session ~self + remote (Client.PBD.get_currently_attached ~self) in host_of () = host && attached () in let srs = - Client.PBD.get_all ~rpc:remote_rpc ~session_id:remote_session + remote Client.PBD.get_all |> List.filter pbd_in_host - |> List.map (fun self -> - Client.PBD.get_SR ~rpc:remote_rpc - ~session_id:remote_session ~self - ) + |> List.map (fun self -> remote (Client.PBD.get_SR ~self)) in (* In the following loop, the current SR:sr' will be compared with previous checked ones, first if it is an ISO type, then pass this one for selection, then the only shared one from this and previous one will be valued, and if not that case (both shared or none shared), choose the one with more space available *) let is_iso self = - let typ = - Client.SR.get_content_type ~rpc:remote_rpc - ~session_id:remote_session ~self - in + let typ = remote (Client.SR.get_content_type ~self) in typ = "iso" in let physical_size self = - Client.SR.get_physical_size ~rpc:remote_rpc - ~session_id:remote_session ~self + remote (Client.SR.get_physical_size ~self) in let physical_utilisation self = - Client.SR.get_physical_utilisation ~rpc:remote_rpc - ~session_id:remote_session ~self - in - let shared self = - Client.SR.get_shared ~rpc:remote_rpc ~session_id:remote_session - ~self + remote (Client.SR.get_physical_utilisation ~self) in + let shared self = remote (Client.SR.get_shared ~self) in let sr, _ = List.fold_left (fun (sr, free_space) sr' -> @@ -4572,13 +4523,9 @@ let vm_migrate printer rpc session_id params = ) params in - let host_name_label = - Client.Host.get_name_label ~rpc:remote_rpc ~session_id:remote_session - ~self:host - in + let host_name_label = remote (Client.Host.get_name_label ~self:host) in let network_name_label = - Client.Network.get_name_label ~rpc:remote_rpc - ~session_id:remote_session ~self:network + remote (Client.Network.get_name_label ~self:network) in printer (Cli_printer.PMsg