Skip to content

Commit bccf5d3

Browse files
author
David Scott
committed
SR.ls should list the volumes
Signed-off-by: David Scott <dave.scott@citrix.com>
1 parent d839f85 commit bccf5d3

File tree

1 file changed

+36
-3
lines changed
  • examples/volume/org.xen.xcp.storage.plainlvm

1 file changed

+36
-3
lines changed

examples/volume/org.xen.xcp.storage.plainlvm/SR.ls

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env ocamlscript
22
Ocaml.sources := ["common.ml"; "lvm.ml"];
3-
Ocaml.packs := ["xapi-storage"; "cmdliner"; "re.str"; "oUnit"];
3+
Ocaml.packs := ["xapi-storage"; "cmdliner"; "re.str"; "oUnit"; "uri"];
44
Ocaml.ocamlflags := ["-thread"]
55
--
66
(*
@@ -23,13 +23,46 @@ module Command = struct
2323
include SR.Ls
2424

2525
let command common { SR.Ls.In.dbg; sr } =
26-
[]
26+
List.map
27+
(fun lv -> {
28+
key = lv.Lvm.name;
29+
name = lv.Lvm.name;
30+
description = "";
31+
read_write = true;
32+
uri = ["block://" ^ (Lvm.path_of sr lv.Lvm.name) ];
33+
virtual_size = 0L;
34+
} ) (Lvm.lvs sr)
2735
end
2836

2937
module Test = struct
3038
open OUnit
3139

32-
let test common = ()
40+
let test_lvs () =
41+
let vol = Lvm.make_temp_volume () in
42+
let vg_name = "hello" in
43+
finally
44+
(fun () ->
45+
Lvm.vgcreate vg_name [ vol ];
46+
Lvm.lvcreate vg_name "testvol" 1L;
47+
finally
48+
(fun () ->
49+
match Lvm.lvs vg_name with
50+
| [ { Lvm.name = "testvol"; tags = [] } ] -> ()
51+
| [ ] -> failwith "I created 'testvol' but it didnt show in 'lvs'"
52+
| _ -> failwith "I created 'testvol' but multiple volumes showed up in 'lvs'"
53+
) (fun () ->
54+
Lvm.lvremove vg_name "testvol"
55+
)
56+
) (fun () ->
57+
Lvm.remove_temp_volume vol
58+
)
59+
60+
let test common =
61+
let suite = "create" >::: [
62+
"lvs" >:: test_lvs;
63+
] in
64+
ignore(run_test_tt ~verbose:common.Common.verbose suite)
65+
3366
end
3467

3568
module M = Make(Command)(Test)

0 commit comments

Comments
 (0)