Skip to content

Commit 7aa4234

Browse files
authored
Merge pull request #84 from jonludlam/packed-stdext
Use packed stdext
2 parents 5335071 + 37c9a1e commit 7aa4234

File tree

10 files changed

+26
-28
lines changed

10 files changed

+26
-28
lines changed

.merlin

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ S lib
22
S networkd
33
S networkd_db
44
S test
5-
B dist/build/lib-network-libs/
6-
B dist/build/xcp-networkd
7-
B dist/build/networkd_db
8-
B dist/build/network_test
5+
S profiling
6+
B _build/profiling
7+
B _build/lib
8+
B _build/networkd
99
PKG forkexec
1010
PKG rpclib
1111
PKG stdext
@@ -17,3 +17,5 @@ PKG xcp-inventory
1717
PKG xcp.network
1818
PKG xcp.network
1919
PKG xen-api-client
20+
PKG oUnit
21+
PKG bisect_ppx.runtime

cli/network_cli.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
open Network_interface
22
open Network_client
33
open Cmdliner
4-
open Xstringext
54

65
let dbg = "cli"
76

@@ -220,11 +219,11 @@ let get_dns_cmd =
220219
let set_dns iface nameservers domains =
221220
try
222221
let ns = match nameservers with
223-
| Some x -> List.map Unix.inet_addr_of_string (String.split ',' x)
222+
| Some x -> List.map Unix.inet_addr_of_string (Stdext.Xstringext.String.split ',' x)
224223
| None -> []
225224
in
226225
let d = match domains with
227-
| Some x -> String.split ',' x
226+
| Some x -> Stdext.Xstringext.String.split ',' x
228227
| None -> []
229228
in
230229
Client.Interface.set_dns dbg iface ns d;
@@ -317,7 +316,7 @@ let list_br_cmd =
317316
Term.info "list-br" ~doc ~man
318317

319318
let read_config path =
320-
let config_json = Unixext.string_of_file path in
319+
let config_json = Stdext.Unixext.string_of_file path in
321320
config_json |> Jsonrpc.of_string |> config_t_of_rpc
322321

323322
let config path =

lib/network_config.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
open Network_interface
1616

17+
open Stdext
1718
open Fun
1819
open Xstringext
1920

lib/network_utils.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414

15+
open Stdext
1516
open Listext
1617
open Xstringext
1718
open Pervasiveext

networkd/network_monitor.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515
open Network_interface
1616
include Network_stats
1717

18-
open Fun
19-
open Xstringext
20-
open Threadext
21-
2218
let write_stats stats =
2319
let payload = stats |> rpc_of_stats_t |> Jsonrpc.to_string in
2420
let checksum = payload |> Digest.string |> Digest.to_hex in
2521
let length = String.length payload in
2622
let data = Printf.sprintf "%s%s%08x%s" magic checksum length payload in
27-
Unixext.write_string_to_file stats_file (data)
23+
Stdext.Unixext.write_string_to_file stats_file (data)

networkd/network_monitor_thread.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
open Network_utils
1616

17-
open Fun
17+
open Stdext
1818
open Xstringext
1919
open Listext
2020
open Threadext

networkd/network_server.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
open Network_utils
1616
open Network_interface
1717

18-
open Fun
19-
open Xstringext
20-
open Listext
18+
(*open Fun*)
19+
open Stdext.Xstringext
20+
open Stdext.Listext
2121

2222
module D = Debug.Make(struct let name = "network_server" end)
2323
open D
@@ -141,7 +141,7 @@ module Interface = struct
141141
Ip.flush_ip_addr name
142142
end
143143
| DHCP4 ->
144-
let gateway = Opt.default [] (Opt.map (fun n -> [`gateway n]) !config.gateway_interface) in
144+
let gateway = Stdext.Opt.default [] (Stdext.Opt.map (fun n -> [`gateway n]) !config.gateway_interface) in
145145
let dns =
146146
if !config.dns_interface = None || !config.dns_interface = Some name then begin
147147
debug "%s is the DNS interface" name;
@@ -260,7 +260,7 @@ module Interface = struct
260260

261261
let get_dns _ dbg ~name =
262262
Debug.with_thread_associated dbg (fun () ->
263-
let nameservers, domains = Unixext.file_lines_fold (fun (nameservers, domains) line ->
263+
let nameservers, domains = Stdext.Unixext.file_lines_fold (fun (nameservers, domains) line ->
264264
if String.startswith "nameserver" line then
265265
let server = List.nth (String.split_f String.isspace line) 1 in
266266
(Unix.inet_addr_of_string server) :: nameservers, domains
@@ -284,7 +284,7 @@ module Interface = struct
284284
let domains' = if domains <> [] then ["search " ^ (String.concat " " domains)] else [] in
285285
let nameservers' = List.map (fun ip -> "nameserver " ^ (Unix.string_of_inet_addr ip)) nameservers in
286286
let lines = domains' @ nameservers' in
287-
Unixext.write_string_to_file resolv_conf ((String.concat "\n" lines) ^ "\n")
287+
Stdext.Unixext.write_string_to_file resolv_conf ((String.concat "\n" lines) ^ "\n")
288288
end else
289289
debug "%s is NOT the DNS interface" name
290290
) ()
@@ -424,7 +424,7 @@ module Bridge = struct
424424

425425
let determine_backend () =
426426
try
427-
let backend = String.strip String.isspace (Unixext.string_of_file !network_conf) in
427+
let backend = String.strip String.isspace (Stdext.Unixext.string_of_file !network_conf) in
428428
match backend with
429429
| "openvswitch" | "vswitch" -> backend_kind := Openvswitch
430430
| "bridge" -> backend_kind := Bridge
@@ -503,7 +503,7 @@ module Bridge = struct
503503
ignore (Brctl.create_bridge name);
504504
Brctl.set_forwarding_delay name 0;
505505
Sysfs.set_multicast_snooping name false;
506-
Opt.iter (Ip.set_mac name) mac;
506+
Stdext.Opt.iter (Ip.set_mac name) mac;
507507
match vlan with
508508
| None -> ()
509509
| Some (parent, vlan) ->
@@ -852,12 +852,12 @@ let on_startup () =
852852
(* Remove DNSDEV and GATEWAYDEV from Centos networking file, because the interfere
853853
* with this daemon. *)
854854
try
855-
let file = String.rtrim (Unixext.string_of_file "/etc/sysconfig/network") in
855+
let file = String.rtrim (Stdext.Unixext.string_of_file "/etc/sysconfig/network") in
856856
let args = String.split '\n' file in
857857
let args = List.map (fun s -> match (String.split '=' s) with k :: [v] -> k, v | _ -> "", "") args in
858858
let args = List.filter (fun (k, v) -> k <> "DNSDEV" && k <> "GATEWAYDEV") args in
859859
let s = String.concat "\n" (List.map (fun (k, v) -> k ^ "=" ^ v) args) ^ "\n" in
860-
Unixext.write_string_to_file "/etc/sysconfig/network" s
860+
Stdext.Unixext.write_string_to_file "/etc/sysconfig/network" s
861861
with _ -> ()
862862
in
863863
try

networkd/networkd.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414

15+
open Stdext
1516
open Pervasiveext
1617
open Fun
1718
open Network_utils

networkd_db/networkd_db.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414

15-
open Fun
1615
open Network_interface
1716

1817
let name = "networkd_db"

test/network_test_lacp_properties.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414

15-
open Fun
1615
open OUnit
1716
open Network_utils
1817

@@ -91,7 +90,7 @@ let test_lacp_aggregation_key_vsctl arg () = skip_if true "Unimplemented" ;
9190
print_endline answer ;
9291
assert_bool "lacp_aggregation_key is passed to ovs-vsctl command"
9392
(List.exists
94-
(fun s -> (Xstringext.String.(strip isspace s) == answer))
93+
(fun s -> (Stdext.Xstringext.String.(strip isspace s) == answer))
9594
!OVS_Cli_test.vsctl_output)
9695

9796
(* Test case for bond_create with default lacp-{time,aggregation-key} settings.
@@ -115,7 +114,7 @@ let test_lacp_defaults_bond_create () =
115114
List.iter
116115
(fun arg ->
117116
assert_bool "key=value argument pairs can't have missing values"
118-
(let open Xstringext.String in
117+
(let open Stdext.Xstringext.String in
119118
arg |> strip isspace |> endswith "=" |> not))
120119
!OVS_Cli_test.vsctl_output
121120

0 commit comments

Comments
 (0)