@@ -58,30 +58,40 @@ let make_tables ~__context ~host =
58
58
let dbg = Context. string_of_task __context in
59
59
let device_to_position_table = Net.Interface. get_interface_positions dbg () in
60
60
let device_to_mac_table =
61
- let devices =
62
- List. filter
63
- (fun name -> Net.Interface. is_physical dbg name)
64
- (Net.Interface. get_all dbg () )
65
- in
66
- List. combine devices
67
- (List. map (fun name -> Net.Interface. get_mac dbg name) devices)
61
+ List. filter_map
62
+ (fun name ->
63
+ if Net.Interface. is_physical dbg name then
64
+ Some (name, Net.Interface. get_mac dbg name)
65
+ else
66
+ None
67
+ )
68
+ (Net.Interface. get_all dbg () )
68
69
in
69
70
(* Get all PIFs on this host *)
70
- let pifs =
71
+ let pif_to_device_table =
71
72
Db.PIF. get_records_where ~__context
72
73
~expr:
73
74
(And
74
75
( Eq (Field " host" , Literal (Ref. string_of host))
75
76
, Eq (Field " physical" , Literal " true" )
76
77
)
77
78
)
79
+ |> List. map (fun (pref , prec ) -> (pref, prec.API. pIF_device))
78
80
in
79
- {
80
- device_to_position_table
81
- ; device_to_mac_table
82
- ; pif_to_device_table=
83
- List. map (fun (pref , prec ) -> (pref, prec.API. pIF_device)) pifs
84
- }
81
+ debug " tables: device_to_position_table = %s"
82
+ (String. concat " ; "
83
+ (List. map
84
+ (fun (d , p ) -> d ^ " :" ^ string_of_int p)
85
+ device_to_position_table
86
+ )
87
+ ) ;
88
+ debug " tables: device_to_mac_table = %s"
89
+ (String. concat " ; "
90
+ (List. map (fun (d , m ) -> d ^ " :" ^ m) device_to_mac_table)
91
+ ) ;
92
+ debug " tables: pif_to_device_table = %s"
93
+ (String. concat " ; " (List. map snd pif_to_device_table)) ;
94
+ {device_to_position_table; device_to_mac_table; pif_to_device_table}
85
95
86
96
let refresh_internal ~__context ~interface_tables ~self =
87
97
let dbg = Context. string_of_task __context in
0 commit comments