From 84aa08be26342fd55ecf02a853c2761885fb45b4 Mon Sep 17 00:00:00 2001 From: John Else Date: Mon, 11 Mar 2013 15:22:38 +0000 Subject: [PATCH] Whitespace: create_misc.ml $ camlp4o -printer o -no_comments ocaml/xapi/create_misc.ml | md5sum 016846314b732c13ecadc24ae47ec3f6 - $ git checkout HEAD^ $ camlp4o -printer o -no_comments ocaml/xapi/create_misc.ml | md5sum 016846314b732c13ecadc24ae47ec3f6 - Signed-off-by: John Else --- ocaml/xapi/create_misc.ml | 105 +++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/ocaml/xapi/create_misc.ml b/ocaml/xapi/create_misc.ml index 8cfe22cc5e..704beb64f9 100644 --- a/ocaml/xapi/create_misc.ml +++ b/ocaml/xapi/create_misc.ml @@ -75,20 +75,21 @@ let read_localhost_info () = let result = List.fold_left Int64.add 0L values in Int64.mul 1024L result in - {name_label=this_host_name; - xen_verstring=xen_verstring; - linux_verstring=linux_verstring; - hostname=this_host_name; - uuid=me; - dom0_uuid = Xapi_inventory.lookup Xapi_inventory._control_domain_uuid; - oem_manufacturer = lookup_inventory_nofail Xapi_inventory._oem_manufacturer; - oem_model = lookup_inventory_nofail Xapi_inventory._oem_model; - oem_build_number = lookup_inventory_nofail Xapi_inventory._oem_build_number; - machine_serial_number = lookup_inventory_nofail Xapi_inventory._machine_serial_number; - machine_serial_name = lookup_inventory_nofail Xapi_inventory._machine_serial_name; - total_memory_mib = total_memory_mib; - dom0_static_max = dom0_static_max; - } + { + name_label=this_host_name; + xen_verstring=xen_verstring; + linux_verstring=linux_verstring; + hostname=this_host_name; + uuid=me; + dom0_uuid = Xapi_inventory.lookup Xapi_inventory._control_domain_uuid; + oem_manufacturer = lookup_inventory_nofail Xapi_inventory._oem_manufacturer; + oem_model = lookup_inventory_nofail Xapi_inventory._oem_model; + oem_build_number = lookup_inventory_nofail Xapi_inventory._oem_build_number; + machine_serial_number = lookup_inventory_nofail Xapi_inventory._machine_serial_number; + machine_serial_name = lookup_inventory_nofail Xapi_inventory._machine_serial_name; + total_memory_mib = total_memory_mib; + dom0_static_max = dom0_static_max; + } (** Returns the maximum of two values. *) let maximum x y = if x > y then x else y @@ -126,10 +127,10 @@ and ensure_domain_zero_record ~__context (host_info: host_info): [`VM] Ref.t = and ensure_domain_zero_console_record ~__context ~domain_zero_ref : unit = let dom0_consoles = Db.VM.get_consoles ~__context ~self: domain_zero_ref in - let console_records_rfb = List.filter (fun x -> Db.Console.get_protocol ~__context ~self:x = `rfb) dom0_consoles in + let console_records_rfb = List.filter (fun x -> Db.Console.get_protocol ~__context ~self:x = `rfb) dom0_consoles in let console_records_vt100 = List.filter (fun x -> Db.Console.get_protocol ~__context ~self:x = `vt100) dom0_consoles in - match List.length console_records_rfb, List.length console_records_vt100 with + match List.length console_records_rfb, List.length console_records_vt100 with | 1, 1 -> debug "1 RFB, 1 VT100 console found"; | _ -> (* if there's not more than one console of each type then something strange is happening*) @@ -190,12 +191,11 @@ and create_domain_zero_record ~__context ~domain_zero_ref (host_info: host_info) ~start_delay:0L ~shutdown_delay:0L ~order:0L - ~suspend_SR:Ref.null - ~version:0L - ; + ~suspend_SR:Ref.null + ~version:0L; Xapi_vm_helpers.update_memory_overhead ~__context ~vm:domain_zero_ref -and create_domain_zero_console_record_with_protocol ~__context ~domain_zero_ref ~dom0_console_protocol = +and create_domain_zero_console_record_with_protocol ~__context ~domain_zero_ref ~dom0_console_protocol = let console_ref = Ref.make () in let address = Db.Host.get_address ~__context ~self: (Helpers.get_localhost ~__context) in let location = Printf.sprintf "https://%s%s?ref=%s" address Constants.console_uri (Ref.string_of domain_zero_ref) in @@ -253,16 +253,16 @@ and create_domain_zero_default_memory_constraints host_info : Vm_memory_constrai dynamic_max = vm.Vm.memory_dynamic_max; target = state.Vm.memory_target; } - with _ -> - let target = static_min +++ (Int64.(mul 100L (mul 1024L 1024L))) in - let target = if target > static_max then static_max else target in - { - static_min = static_min; - dynamic_min = target; - target = target; - dynamic_max = target; - static_max = static_max; - } + with _ -> + let target = static_min +++ (Int64.(mul 100L (mul 1024L 1024L))) in + let target = if target > static_max then static_max else target in + { + static_min = static_min; + dynamic_min = target; + target = target; + dynamic_max = target; + static_max = static_max; + } and update_domain_zero_record ~__context ~domain_zero_ref (host_info: host_info) : unit = (* Fetch existing memory constraints for domain 0. *) @@ -321,8 +321,8 @@ let create_root_user ~__context = if all = [] then Db.User.create ~__context ~ref ~fullname ~short_name ~uuid ~other_config:[] let get_xapi_verstring () = - Printf.sprintf "%d.%d" Xapi_globs.version_major Xapi_globs.version_minor - + Printf.sprintf "%d.%d" Xapi_globs.version_major Xapi_globs.version_minor + (** Create assoc list of Supplemental-Pack information. * The package information is taking from the [XS-REPOSITORY] XML file in the package * directory. @@ -385,12 +385,12 @@ let make_software_version () = Xapi_globs.software_version @ (if v6_version = "" then [] else ["dbv", v6_version]) @ [ - "xapi", get_xapi_verstring (); - "xen", info.xen_verstring; - "linux", info.linux_verstring; - "xencenter_min", Xapi_globs.xencenter_min_verstring; - "xencenter_max", Xapi_globs.xencenter_max_verstring; - "network_backend", Netdev.string_of_kind Netdev.network.Netdev.kind; + "xapi", get_xapi_verstring (); + "xen", info.xen_verstring; + "linux", info.linux_verstring; + "xencenter_min", Xapi_globs.xencenter_min_verstring; + "xencenter_max", Xapi_globs.xencenter_max_verstring; + "network_backend", Netdev.string_of_kind Netdev.network.Netdev.kind; ] @ (option_to_list "oem_manufacturer" info.oem_manufacturer) @ (option_to_list "oem_model" info.oem_model) @ @@ -407,7 +407,7 @@ let create_host_cpu ~__context = p.Xenctrl.Phys_info.nr_cpus in let trim_end s = - let i = ref (String.length s - 1) in + let i = ref (String.length s - 1) in while !i > 0 && (List.mem s.[!i] [ ' '; '\t'; '\n'; '\r' ]) do decr i @@ -420,9 +420,9 @@ let create_host_cpu ~__context = modified dom0's VCPUs we don't change out host config... [Important to get this right, otherwise pool homogeneity checks fail] *) let get_cpuinfo () = - let cpu_info_file = - try Unix.access Xapi_globs.cpu_info_file [ Unix.F_OK ]; Xapi_globs.cpu_info_file - with _ -> "/proc/cpuinfo" in + let cpu_info_file = + try Unix.access Xapi_globs.cpu_info_file [ Unix.F_OK ]; Xapi_globs.cpu_info_file + with _ -> "/proc/cpuinfo" in let in_chan = open_in cpu_info_file in let tbl = Hashtbl.create 32 in let rec get_lines () = @@ -432,10 +432,11 @@ let create_host_cpu ~__context = else ( let i = String.index s ':' in let k = trim_end (String.sub s 0 i) in - let v = if String.length s < i + 2 then - "" - else - String.sub s (i + 2) (String.length s - i - 2) in + let v = + if String.length s < i + 2 + then "" + else String.sub s (i + 2) (String.length s - i - 2) + in Hashtbl.add tbl k v; get_lines () ) @@ -446,9 +447,9 @@ let create_host_cpu ~__context = Hashtbl.find tbl "model name", Hashtbl.find tbl "cpu MHz", Hashtbl.find tbl "flags", - Hashtbl.find tbl "stepping", - Hashtbl.find tbl "model", - Hashtbl.find tbl "cpu family" + Hashtbl.find tbl "stepping", + Hashtbl.find tbl "model", + Hashtbl.find tbl "cpu family" in let vendor, modelname, cpu_mhz, flags, stepping, model, family = get_cpuinfo () in let number = get_nb_cpus () in @@ -479,8 +480,8 @@ let create_host_cpu ~__context = "maskable", maskable; ] in Db.Host.set_cpu_info ~__context ~self:host ~value:cpu; - - (* Recreate all Host_cpu objects *) + + (* Recreate all Host_cpu objects *) let speed = Int64.of_float (float_of_string cpu_mhz) in let model = Int64.of_string model in @@ -492,7 +493,7 @@ let create_host_cpu ~__context = for i = 0 to number - 1 do let uuid = Uuid.to_string (Uuid.make_uuid ()) - and ref = Ref.make () in + and ref = Ref.make () in debug "Creating CPU %d: %s" i uuid; ignore (Db.Host_cpu.create ~__context ~ref ~uuid ~host ~number:(Int64.of_int i) ~vendor ~speed ~modelname