Skip to content

Commit 71c87a1

Browse files
committed
CP-51895: Drop FCoE support when fcoe_driver does not exists
- Add logs when fcoe_driver does not exist - Use List.assoc_opt instead of try catch - Add __FUNCTION__ to the logs Signed-off-by: Lin Liu <[email protected]>
1 parent 2fafeb7 commit 71c87a1

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

ocaml/networkd/lib/network_utils.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,13 +1069,15 @@ module Fcoe = struct
10691069
let get_capabilities name =
10701070
match Sys.file_exists !fcoedriver with
10711071
| false ->
1072+
info "%s: %s not found, does not support FCoE" __FUNCTION__ !fcoedriver ;
10721073
[] (* Does not support FCoE *)
10731074
| true -> (
10741075
try
10751076
let output = call ~log:false ["--xapi"; name; "capable"] in
10761077
if Astring.String.is_infix ~affix:"True" output then ["fcoe"] else []
10771078
with _ ->
1078-
debug "Failed to get fcoe support status on device %s" name ;
1079+
debug "%s: Failed to get fcoe support status on device %s" __FUNCTION__
1080+
name ;
10791081
[]
10801082
)
10811083
end

ocaml/xapi/xapi_pif.ml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,33 +323,32 @@ let assert_fcoe_not_in_use ~__context ~self =
323323
| false ->
324324
(* Does not support FCoE from XS9, presuming not in use
325325
* Upgrade plugin will block upgrade with FCoE in use *)
326-
()
326+
debug "%s not found, does not support FCoE" !Xapi_globs.fcoe_driver
327327
| true ->
328328
let interface = Db.PIF.get_device ~__context ~self in
329329
let output, _ =
330330
Forkhelpers.execute_command_get_output !Xapi_globs.fcoe_driver
331331
["-t"; interface]
332332
in
333333
let output = String.trim output in
334-
debug "Scsi ids on %s are: %s" interface output ;
334+
debug "%s: SCSI ids on %s are: %s" __FUNCTION__ interface output ;
335335
let fcoe_scsids = Str.split (Str.regexp " ") output in
336336
Helpers.get_my_pbds __context
337337
|> List.iter (fun (_, pbd_rec) ->
338338
let sr = pbd_rec.API.pBD_SR in
339339
match Db.SR.get_type ~__context ~self:sr with
340340
| "lvmofcoe" -> (
341-
try
342-
let scsid =
343-
List.assoc "SCSIid" pbd_rec.API.pBD_device_config
344-
in
345-
if List.mem scsid fcoe_scsids then
346-
raise
347-
(Api_errors.Server_error
348-
( Api_errors.pif_has_fcoe_sr_in_use
349-
, [Ref.string_of self; Ref.string_of sr]
350-
)
351-
)
352-
with Not_found -> ()
341+
match List.assoc_opt "SCSIid" pbd_rec.API.pBD_device_config with
342+
| Some scsid ->
343+
if List.mem scsid fcoe_scsids then
344+
raise
345+
(Api_errors.Server_error
346+
( Api_errors.pif_has_fcoe_sr_in_use
347+
, [Ref.string_of self; Ref.string_of sr]
348+
)
349+
)
350+
| None ->
351+
()
353352
)
354353
| _ ->
355354
()

0 commit comments

Comments
 (0)