Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various cli improvements #790

Merged
merged 2 commits into from
Aug 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions ocaml/src/alba.ml
Original file line number Diff line number Diff line change
Expand Up @@ -487,27 +487,35 @@ 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
(fun alba_client ->
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"
Expand Down
4 changes: 2 additions & 2 deletions ocaml/src/cli_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 9 additions & 11 deletions ocaml/src/cli_osd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ let get_osd_kind
tls_config

(* for asd/kinetic *)
host port
hosts port
(* for alba osd *)
alba_osd_cfg_url
(* for proxy osd *)
endpoints

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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down