Skip to content

Commit a138ffe

Browse files
committed
CP-28427: probe for first IQN if not given
Signed-off-by: Edwin Török <[email protected]>
1 parent 18ff5f5 commit a138ffe

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

lib/test_sr.ml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,24 @@ let device_config ?(provider= "iscsi") ~ip ~iqn ?scsiid () =
5252
in
5353
(match scsiid with Some id -> ("SCSIid", id) :: conf | None -> conf)
5454

55-
let create_gfs2_sr ctx ~iscsi ~iqn ?scsiid () =
55+
let create_gfs2_sr ctx ~iscsi ?iqn ?scsiid () =
5656
get_pool_master ctx
5757
>>= fun (_pool, master) ->
5858
(* probe *)
59-
let device_config =
60-
[("provider", "iscsi"); ("target", Ipaddr.V4.to_string iscsi); ("targetIQN", iqn)]
59+
let probe_iqn device_config =
60+
match iqn with
61+
| Some iqn ->
62+
Lwt.return (("targetIQN", iqn) :: device_config)
63+
| None ->
64+
rpc ctx @@ SR.probe_ext ~host:master ~device_config ~_type:"gfs2" ~sm_config:[]
65+
>>= function
66+
| [] -> Lwt.fail_with "Probe found nothing, not even a SCSIid"
67+
| probed :: _ ->
68+
Lwt.return probed.API.probe_result_configuration
6169
in
70+
let device_config =
71+
[("provider", "iscsi"); ("target", Ipaddr.V4.to_string iscsi)] in
72+
probe_iqn device_config >>= fun device_config ->
6273
rpc ctx
6374
@@ SR.probe_ext ~host:master ~device_config ~_type:"gfs2" ~sm_config:[]
6475
>>= function
@@ -120,7 +131,7 @@ let plug_pbds ctx ~sr =
120131
pbds
121132

122133

123-
let get_gfs2_sr t ~iscsi ~iqn ?scsiid () =
134+
let get_gfs2_sr t ~iscsi ?iqn ?scsiid () =
124135
step t "GFS2 SR"
125136
@@ fun ctx ->
126137
debug (fun m -> m "Looking for GFS2 SR") ;
@@ -129,7 +140,7 @@ let get_gfs2_sr t ~iscsi ~iqn ?scsiid () =
129140
| (sr, _) :: _ ->
130141
debug (fun m -> m "Found existing GFS2 SR") ;
131142
plug_pbds ctx ~sr >>= fun () -> Lwt.return sr
132-
| [] -> create_gfs2_sr ctx ~iscsi ~iqn ?scsiid ()
143+
| [] -> create_gfs2_sr ctx ~iscsi ?iqn ?scsiid ()
133144

134145

135146
let do_ha t sr =

src/cmd_bonding.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ let do_prepare conf =
9191
>>= fun () ->
9292
Test_sr.enable_clustering t
9393
>>= fun _cluster ->
94-
(match (conf.iscsi, conf.iqn) with
95-
| Some iscsi, Some iqn ->
96-
Test_sr.get_gfs2_sr t ~iscsi ~iqn ?scsiid:conf.scsiid () >>= fun _gfs2 -> Lwt.return_unit
94+
(match conf.iscsi with
95+
| Some iscsi ->
96+
Test_sr.get_gfs2_sr t ~iscsi ?iqn:conf.iqn ?scsiid:conf.scsiid () >>= fun _gfs2 -> Lwt.return_unit
9797
| _ -> Lwt.return_unit)
9898
>>= fun () ->
9999
Test_sr.make_pool ~uname:conf.uname ~pwd:conf.pwd conf conf.hosts)

src/cmd_lwt.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ let do_prepare conf ~rollback ~clear_crashdumps =
4646
>>= fun () ->
4747
Test_sr.enable_clustering t
4848
>>= fun _cluster ->
49-
match (conf.iscsi, conf.iqn) with
50-
| Some iscsi, Some iqn ->
51-
Test_sr.get_gfs2_sr t ~iscsi ~iqn ?scsiid:conf.scsiid () >>= fun _gfs2 -> Lwt.return_unit
49+
match conf.iscsi with
50+
| Some iscsi ->
51+
Test_sr.get_gfs2_sr t ~iscsi ?iqn:conf.iqn ?scsiid:conf.scsiid () >>= fun _gfs2 -> Lwt.return_unit
5252
| _ -> Lwt.return_unit
5353

54-
5554
let lwt_main config f =
5655
Lwt_main.run (
5756
Lwt_io.with_file ~mode:Lwt_io.input config (fun ch -> Lwt_io.read ch)

0 commit comments

Comments
 (0)