From dfb639b904aaa120373aaf5993bbe7482e752f20 Mon Sep 17 00:00:00 2001 From: Jan Doms Date: Thu, 17 Aug 2017 10:16:18 +0200 Subject: [PATCH 1/2] --to-json option for list-objects command --- ocaml/src/alba.ml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ocaml/src/alba.ml b/ocaml/src/alba.ml index e402feba..31b29089 100644 --- a/ocaml/src/alba.ml +++ b/ocaml/src/alba.ml @@ -487,7 +487,7 @@ let alba_show_object_cmd = ), Term.info "show-object" ~doc -let alba_list_objects cfg_file tls_config namespace verbose = +let alba_list_objects cfg_file tls_config namespace to_json verbose = let t () = with_alba_client cfg_file tls_config @@ -495,19 +495,27 @@ let alba_list_objects cfg_file tls_config namespace verbose = alba_client # get_base_client # with_nsm_client ~namespace (fun nsm -> - nsm # list_all_objects ())) >>= fun (cnt, objs) -> - Lwt_io.printlf - "Found %i objects: %s" - cnt - ([%show: string list] objs) + nsm # list_all_objects () + ) + ) >>= fun (cnt, objs) -> + + if to_json + then + print_result objs [%to_yojson : string list] + else + Lwt_io.printlf + "Found %i objects: %s" + cnt + ([%show: string list] objs) in - lwt_cmd_line ~to_json:false ~verbose t + lwt_cmd_line ~to_json ~verbose t let alba_list_objects_cmd = Term.(pure alba_list_objects $ alba_cfg_url $ tls_config $ namespace 0 + $ to_json $ verbose ), Term.info "list-objects" ~doc:"list all objects in the specified namespace" From 9ca9cd51601dcd9d924c944e65a2cfb644568d2f Mon Sep 17 00:00:00 2001 From: Jan Doms Date: Thu, 17 Aug 2017 11:04:05 +0200 Subject: [PATCH 2/2] allow specifying multiple hosts for get-osd-claimed-by & add-osd commands --- ocaml/src/cli_common.ml | 4 ++-- ocaml/src/cli_osd.ml | 20 +++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ocaml/src/cli_common.ml b/ocaml/src/cli_common.ml index 2c5acab3..f3a550db 100644 --- a/ocaml/src/cli_common.ml +++ b/ocaml/src/cli_common.ml @@ -261,9 +261,9 @@ let hosts = & opt_all string [] & info ["h";"host"] ~docv:"HOST" ~doc) -let host_option = +let hosts_option = Arg.(value - & opt (some string) None + & opt (some (list string)) None & info ["host"; "h";] ~docv:"HOST" ~doc:"the host to connect with") diff --git a/ocaml/src/cli_osd.ml b/ocaml/src/cli_osd.ml index 615b1e53..f622f88e 100644 --- a/ocaml/src/cli_osd.ml +++ b/ocaml/src/cli_osd.ml @@ -84,7 +84,7 @@ let get_osd_kind tls_config (* for asd/kinetic *) - host port + hosts port (* for alba osd *) alba_osd_cfg_url (* for proxy osd *) @@ -92,15 +92,15 @@ let get_osd_kind prefix preset = - match host, port, alba_osd_cfg_url, endpoints, prefix, preset with - | Some host, Some port, None, [], None, None -> - let conn_info = Networking2.make_conn_info [host] port tls_config in + match hosts, port, alba_osd_cfg_url, endpoints, prefix, preset with + | (_ :: _), Some port, None, [], None, None -> + let conn_info = Networking2.make_conn_info hosts port tls_config in Discovery.get_kind Buffer_pool.default_buffer_pool conn_info >>= (function | None -> Lwt.fail_with "I don't think this is an OSD" | Some kind -> Lwt.return kind) - | None, None, Some alba_osd_cfg_url, [], Some prefix, Some preset -> + | [], None, Some alba_osd_cfg_url, [], Some prefix, Some preset -> Alba_arakoon.config_from_url alba_osd_cfg_url >>= fun alba_osd_cfg -> Albamgr_client.with_client' ~attempts:1 @@ -112,7 +112,7 @@ let get_osd_kind prefix; preset; }) - | None, None, None, endpoints, Some prefix, Some preset -> + | [], None, None, endpoints, Some prefix, Some preset -> let pp = new Proxy_osd.multi_proxy_pool ~alba_id:None @@ -278,7 +278,7 @@ let alba_add_osd_cmd = Term.(pure alba_add_osd $ alba_cfg_url $ tls_config - $ host_option + $ hosts $ port_option $ alba_osd_cfg_url $ endpoints @@ -324,9 +324,7 @@ let alba_update_osd_cmd = $ Arg.(value & opt (some (list string)) None & info ["ip"]) - $ Arg.(value - & opt (some int) None - & info ["port"]) + $ port_option $ alba_osd_cfg_url $ Arg.(value & opt (some (list string)) None @@ -380,7 +378,7 @@ let alba_get_claimed_by let alba_get_claimed_by_cmd = Term.(pure alba_get_claimed_by $ tls_config - $ host_option + $ hosts $ port_option $ alba_osd_cfg_url $ endpoints