1414
1515open Xapi_stdext_pervasives
1616open Xapi_stdext_unix
17- open Xapi_stdext_std
1817open Network_interface
1918
2019module D = Debug. Make (struct let name = " network_utils" end )
@@ -93,7 +92,7 @@ let check_n_run ?(on_error=default_error_handler) ?(log=true) run_func script ar
9392
9493let call_script ?(timeout =Some 60.0 ) ?on_error ?log script args =
9594 let call_script_internal env script args =
96- let (out,err ) = Forkhelpers. execute_command_get_output ~env ?timeout script args in
95+ let (out,_err ) = Forkhelpers. execute_command_get_output ~env ?timeout script args in
9796 out
9897 in
9998 check_n_run ?on_error ?log call_script_internal script args
@@ -155,7 +154,7 @@ module Sysfs = struct
155154 try
156155 output_string outchan (l ^ " \n " );
157156 close_out outchan
158- with exn -> close_out outchan; raise (Network_error (Write_error file))
157+ with _ -> close_out outchan; raise (Network_error (Write_error file))
159158
160159 let is_physical name =
161160 try
@@ -175,7 +174,7 @@ module Sysfs = struct
175174 try
176175 let devpath = Unix. readlink (getpath name " device" ) in
177176 List. hd (List. rev (Astring.String. cuts ~empty: false ~sep: " /" devpath))
178- with exn -> " N/A"
177+ with _ -> " N/A"
179178
180179 let get_pci_ids name =
181180 let read_id_from path =
@@ -193,7 +192,7 @@ module Sysfs = struct
193192 try
194193 let driver_path = Unix. readlink (getpath dev " device/driver" ) in
195194 match Astring.String. cut ~sep: " /" ~rev: true driver_path with
196- | Some (prefix , suffix ) -> Some suffix
195+ | Some (_prefix , suffix ) -> Some suffix
197196 | None ->
198197 debug " get %s driver name: %s does not contain slash" dev driver_path;
199198 None
@@ -417,11 +416,6 @@ module Ip = struct
417416 let get_mtu dev =
418417 int_of_string (List. hd (link dev " mtu" ))
419418
420- let get_state dev =
421- match addr dev " state" with
422- | "UP" :: _ -> true
423- | _ -> false
424-
425419 let get_mac dev =
426420 List. hd (link dev " link/ether" )
427421
@@ -748,7 +742,7 @@ module Dhclient = struct
748742 let ipv6' = if ipv6 then " 6" else " " in
749743 Filename. concat " /var/lib/xcp" (Printf. sprintf " dhclient%s-%s.conf" ipv6' interface)
750744
751- let generate_conf ?(ipv6 =false ) interface options =
745+ let [ @ warning " -27 " ] generate_conf ?(ipv6= false ) interface options =
752746 let minimal = [" subnet-mask" ; " broadcast-address" ; " time-offset" ; " host-name" ; " nis-domain" ;
753747 " nis-servers" ; " ntp-servers" ; " interface-mtu" ] in
754748 let set_gateway =
@@ -874,7 +868,7 @@ module Proc = struct
874868 loop None [] lines
875869 in
876870 check_lines lines
877- with e ->
871+ with _ ->
878872 error " Error: could not read %s." (bonding_dir ^ name);
879873 []
880874
@@ -894,14 +888,10 @@ module Proc = struct
894888 with _ ->
895889 vlans
896890 ) [] " /proc/net/vlan/config"
897- with e ->
891+ with _ ->
898892 error " Error: could not read /proc/net/vlan/config" ;
899893 []
900894
901- let get_bond_links_up name =
902- let statusses = get_bond_slave_info name " MII Status" in
903- List. fold_left (fun x (_ , y ) -> x + (if y = " up" then 1 else 0 )) 0 statusses
904-
905895 let get_ipv6_disabled () =
906896 try
907897 Unixext. string_of_file " /proc/sys/net/ipv6/conf/all/disable_ipv6"
@@ -1002,7 +992,7 @@ module Ovs = struct
1002992
1003993 let get_real_bridge name =
1004994 match bridge_to_vlan name with
1005- | Some (parent , vlan ) -> parent
995+ | Some (parent , _vlan ) -> parent
1006996 | None -> name
1007997
1008998 let get_bond_link_status name =
@@ -1026,11 +1016,6 @@ module Ovs = struct
10261016 ) ([] , None ) lines
10271017 with _ -> [] , None
10281018
1029- let get_bond_links_up name =
1030- let slaves, _ = get_bond_link_status name in
1031- let links_up = List. filter snd slaves in
1032- List. length (links_up)
1033-
10341019 let get_bond_mode name =
10351020 try
10361021 let output = String. trim (vsctl ~log: false [" get" ; " port" ; name; " bond_mode" ]) in
@@ -1119,7 +1104,7 @@ module Ovs = struct
11191104
11201105 let inject_igmp_query ~name =
11211106 try
1122- let vvifs = get_bridge_vlan_vifs name in
1107+ let vvifs = get_bridge_vlan_vifs ~ name in
11231108 let bvifs = bridge_to_interfaces name in
11241109 let bvifs' = List. filter (fun vif -> Astring.String. is_prefix ~affix: " vif" vif) bvifs in
11251110 (* The vifs may be large. However considering current XS limit of 1000VM*7NIC/VM + 800VLANs, the buffer of CLI should be sufficient for lots of vifxxxx.xx *)
@@ -1210,9 +1195,6 @@ module Ovs = struct
12101195 let destroy_port name =
12111196 vsctl [" --" ; " --with-iface" ; " --if-exists" ; " del-port" ; name]
12121197
1213- let port_to_bridge name =
1214- vsctl ~log: false [" port-to-br" ; name]
1215-
12161198 let make_bond_properties name properties =
12171199 let known_props = [" mode" ; " hashing-algorithm" ; " updelay" ; " downdelay" ;
12181200 " miimon" ; " use_carrier" ; " rebalance-interval" ;
@@ -1422,7 +1404,7 @@ module Modprobe = struct
14221404 let get_config_from_comments driver =
14231405 try
14241406 let open Xapi_stdext_std.Listext in
1425- Unixext. read_lines (getpath driver)
1407+ Unixext. read_lines ~path: (getpath driver)
14261408 |> List. filter_map (fun x ->
14271409 let line = String. trim x in
14281410 if not (Astring.String. is_prefix ~affix: (" # " ) line)
@@ -1501,7 +1483,7 @@ module Modprobe = struct
15011483 else
15021484 trimed_s
15031485 in
1504- let lines = try Unixext. read_lines (getpath driver) with _ -> [] in
1486+ let lines = try Unixext. read_lines ~path: (getpath driver) with _ -> [] in
15051487 let new_conf = List. map parse_single_line lines in
15061488 match ! has_probe_conf, ! need_rebuild_initrd with
15071489 | true , true ->
0 commit comments