33open Cmdliner
44open Xenvm_common
55open Lwt
6+ open Errors
67
78let default_fields = [
89 " lv_name" ;
@@ -18,7 +19,7 @@ let default_fields = [
1819 " convert_lv" ]
1920
2021
21- let lvs copts noheadings nosuffix units fields (vg_name ,lv_name_opt ) =
22+ let lvs copts noheadings nosuffix units fields offline physical_device (vg_name ,lv_name_opt ) =
2223 let open Xenvm_common in
2324 let segs = has_seg_field fields in
2425 let do_row dev vg lv =
@@ -36,10 +37,22 @@ let lvs copts noheadings nosuffix units fields (vg_name,lv_name_opt) =
3637 Lwt_main. run (
3738 get_vg_info_t copts vg_name >> = fun info ->
3839 set_uri copts info;
39- let dev = match info with | Some i -> i.local_device | None -> " <unknown>" in
40+ let dev : string = match (info,physical_device) with
41+ | _ , Some d -> d (* cmdline overrides default for the VG *)
42+ | Some info , None -> info.local_device (* If we've got a default, use that *)
43+ | None , None -> failwith " Need to know the local device!" in
44+
4045 Lwt. catch
41- (Client. get)
42- (fun _ ->
46+ (fun () ->
47+ if offline then begin
48+ with_block dev
49+ (fun x ->
50+ let module Vg_IO = Lvm.Vg. Make (Log )(Block )(Time )(Clock ) in
51+ Vg_IO. connect [ x ] `RO >> |= fun vg ->
52+ return (Vg_IO. metadata_of vg)
53+ )
54+ end else Client. get ()
55+ ) (fun _ ->
4356 stderr " Volume group \" %s\" not found" vg_name
4457 >> = fun () ->
4558 stderr " Skipping volume group %s" vg_name
@@ -66,5 +79,5 @@ let lvs_cmd =
6679 `S " DESCRIPTION" ;
6780 `P " lvs produces formatted output about logical volumes" ;
6881 ] in
69- Term. (pure lvs $ Xenvm_common. copts_t $ noheadings_arg $ nosuffix_arg $ units_arg $ output_arg default_fields $ Xenvm_common. name_arg),
82+ Term. (pure lvs $ Xenvm_common. copts_t $ noheadings_arg $ nosuffix_arg $ units_arg $ output_arg default_fields $ Xenvm_common. offline_arg $ Xenvm_common. physical_device_arg $ Xenvm_common. name_arg),
7083 Term. info " lvs" ~sdocs: " COMMON OPTIONS" ~doc ~man
0 commit comments