Skip to content

Commit

Permalink
Merge pull request xapi-project#5419 from robhoes/ca388437
Browse files Browse the repository at this point in the history
CA-388437: fix bond status reporting
  • Loading branch information
robhoes authored Feb 5, 2024
2 parents e3602e1 + 97f41c3 commit 004590e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions ocaml/networkd/lib/network_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1278,25 +1278,29 @@ module Ovs = struct

let get_bond_link_status name =
try
(* Note: bond links are called "members" by the OVS. In old OVS
versions, the term "slaves" was used, which is also used by the
Linux kernel and in xapi. The terms bond link/slave/member are
used interchangably. *)
let raw = appctl ~log:false ["bond/show"; name] in
let lines = Astring.String.cuts ~empty:false ~sep:"\n" raw in
List.fold_left
(fun (slaves, active_slave) line ->
let slaves =
(fun (members, active_member) line ->
let members =
try
Scanf.sscanf line "slave %s@: %s" (fun slave state ->
(slave, state = "enabled") :: slaves
Scanf.sscanf line "member %s@: %s" (fun member state ->
(member, state = "enabled") :: members
)
with _ -> slaves
with _ -> members
in
let active_slave =
let active_member =
try
Scanf.sscanf line "active slave %s@(%s@)" (fun _ slave ->
Some slave
Scanf.sscanf line "active member %s@(%s@)" (fun _ member ->
Some member
)
with _ -> active_slave
with _ -> active_member
in
(slaves, active_slave)
(members, active_member)
)
([], None) lines
with _ -> ([], None)
Expand Down

0 comments on commit 004590e

Please sign in to comment.