search for: with_open_out

Displaying 20 results from an estimated 45 matches for "with_open_out".

2017 Nov 05
3
[PATCH 1/2] common/mlstdutils: Add with_open_in and with_open_out functions.
....ml +++ b/common/mlstdutils/std_utils.ml @@ -654,20 +654,29 @@ let verbose = ref false let set_verbose () = verbose := true let verbose () = !verbose +let with_open_in filename f = + let chan = open_in filename in + protect ~f:(fun () -> f chan) ~finally:(fun () -> close_in chan) + +let with_open_out filename f = + let chan = open_out filename in + protect ~f:(fun () -> f chan) ~finally:(fun () -> close_out chan) + let read_whole_file path = let buf = Buffer.create 16384 in - let chan = open_in path in - let maxlen = 16384 in - let b = Bytes.create maxlen in - let rec loop () =...
2018 Jun 27
1
[PATCH] v2v: -o local: print libvirt XML
...), 1 deletion(-) diff --git a/v2v/output_local.ml b/v2v/output_local.ml index 4e1088afc..c70428134 100644 --- a/v2v/output_local.ml +++ b/v2v/output_local.ml @@ -68,7 +68,13 @@ class output_local dir = object let name = source.s_name in let file = dir // name ^ ".xml" in - with_open_out file (fun chan -> DOM.doc_to_chan chan doc) + with_open_out file (fun chan -> DOM.doc_to_chan chan doc); + + if verbose () then ( + eprintf "resulting local libvirt XML:\n%!"; + DOM.doc_to_chan stderr doc; + eprintf "\n%!"; + ) end let output_lo...
2017 Nov 07
0
[PATCH] common/mlstdutils: Add with_openfile function.
.../inspect_fs_windows.ml | 7 +++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml index ee6bea5af..5d451fae8 100644 --- a/common/mlstdutils/std_utils.ml +++ b/common/mlstdutils/std_utils.ml @@ -662,6 +662,10 @@ let with_open_out filename f = let chan = open_out filename in protect ~f:(fun () -> f chan) ~finally:(fun () -> close_out chan) +let with_openfile filename flags perms f = + let fd = Unix.openfile filename flags perms in + protect ~f:(fun () -> f fd) ~finally:(fun () -> Unix.close fd) + let r...
2017 Nov 05
0
[PATCH 2/2] common/mlstdutils: Add with_openfile function.
...indows.ml | 18 ++++++++---------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml index ee6bea5af..32944ed27 100644 --- a/common/mlstdutils/std_utils.ml +++ b/common/mlstdutils/std_utils.ml @@ -662,6 +662,10 @@ let with_open_out filename f = let chan = open_out filename in protect ~f:(fun () -> f chan) ~finally:(fun () -> close_out chan) +let with_openfile filename flags perms = + let fd = Unix.openfile filename flags perms in + protect ~f:(fun () -> f fd) ~finally:(fun () -> close fd) + let read_who...
2018 Mar 08
6
[PATCH v5 0/4] v2v: Add -o rhv-upload output mode.
Mainly minor fixes and code cleanups over the v4 patch. There are still several problems with this patch, but it is in a reviewable state, especially the Python code. Rich.
2018 Mar 08
0
[PATCH v5 4/4] v2v: Add -o rhv-upload output mode.
...hvupload." in + rmdir_on_exit t; + t in + + let diskid_file_of_id id = tmpdir // sprintf "diskid.%d" id in + + (* Write the Python precheck, plugin and create VM to a temporary file. *) + let precheck = + let precheck = tmpdir // "rhv-upload-precheck.py" in + with_open_out + precheck + (fun chan -> output_string chan Output_rhv_upload_precheck_source.code); + precheck in + let plugin = + let plugin = tmpdir // "rhv-upload-plugin.py" in + with_open_out + plugin + (fun chan -> output_string chan Output_rhv_upload_plugin_sou...
2018 Mar 27
1
[PATCH FOR DISCUSSION ONLY] v2v: Add -o kubevirt output mode.
...TargetFile (dir // sprintf "%s-disk-%d" name i) in + { t with target_file } + ) targets + + method create_metadata source targets target_buses + guestcaps inspect target_firmware = + (* Create the YAML-format metadata. *) + (* XXX ESCAPING? *) + with_open_out (dir // name ^ ".yaml") ( + fun chan -> + let fpf fs = fprintf chan fs in + fpf "apiVersion: kubevirt.io/v1alpha1\n"; + fpf "kind: OfflineVirtualMachine\n"; + fpf "metadata:\n"; + fpf " name: %s\n" name; +...
2018 Mar 08
2
Re: [PATCH v5 4/4] v2v: Add -o rhv-upload output mode.
...+ t in > + > + let diskid_file_of_id id = tmpdir // sprintf "diskid.%d" id in > + > + (* Write the Python precheck, plugin and create VM to a temporary file. > *) > + let precheck = > + let precheck = tmpdir // "rhv-upload-precheck.py" in > + with_open_out > + precheck > + (fun chan -> output_string chan > Output_rhv_upload_precheck_source.code); > + precheck in > + let plugin = > + let plugin = tmpdir // "rhv-upload-plugin.py" in > + with_open_out > + plugin > + (fun chan -> ou...
2018 Mar 11
2
Re: [PATCH v5 4/4] v2v: Add -o rhv-upload output mode.
...> + t in > + > + let diskid_file_of_id id = tmpdir // sprintf "diskid.%d" id in > + > + (* Write the Python precheck, plugin and create VM to a temporary file. *) > + let precheck = > + let precheck = tmpdir // "rhv-upload-precheck.py" in > + with_open_out > + precheck > + (fun chan -> output_string chan Output_rhv_upload_precheck_source.code); > + precheck in > + let plugin = > + let plugin = tmpdir // "rhv-upload-plugin.py" in > + with_open_out > + plugin > + (fun chan -> output_...
2018 Mar 09
1
Re: [PATCH v5 4/4] v2v: Add -o rhv-upload output mode.
...  let diskid_file_of_id id = tmpdir // sprintf "diskid.%d" id in > + > +  (* Write the Python precheck, plugin and create VM to a temporary > file. *) > +  let precheck = > +    let precheck = tmpdir // "rhv-upload-precheck.py" in > +    with_open_out > +      precheck > +      (fun chan -> output_string chan > Output_rhv_upload_precheck_source.code); > +    precheck in > +  let plugin = > +    let plugin = tmpdir // "rhv-upload-plugin.py" in > +    with_open_out > +      plugi...
2018 Mar 21
2
[PATCH v6] v2v: Add -o rhv-upload output mode.
v5 was here: https://www.redhat.com/archives/libguestfs/2018-March/msg00032.html There is only a single patch in this version because the other patches went upstream. This patch adds the virt-v2v -o rhv-upload mode (https://bugzilla.redhat.com/show_bug.cgi?id=1557273). Compared to v5, this adds the ability to make zero, trim and flush requests to the oVirt imageio server
2018 Mar 21
0
[PATCH v6] v2v: Add -o rhv-upload output mode.
...hvupload." in + rmdir_on_exit t; + t in + + let diskid_file_of_id id = tmpdir // sprintf "diskid.%d" id in + + (* Write the Python precheck, plugin and create VM to a temporary file. *) + let precheck = + let precheck = tmpdir // "rhv-upload-precheck.py" in + with_open_out + precheck + (fun chan -> output_string chan Output_rhv_upload_precheck_source.code); + precheck in + let plugin = + let plugin = tmpdir // "rhv-upload-plugin.py" in + with_open_out + plugin + (fun chan -> output_string chan Output_rhv_upload_plugin_sou...
2018 Mar 12
1
[PATCH RHEL 7] RHEL 7: -o rhv-upload: Use Python 2 instead of Python
For interest only, here is the patch required to make -o rhv-upload work with Python 2 (for RHEL 7). I don't think we want this upstream. A couple of remarks: * It's supposed to be possible to add ‘coding: utf-8’ to the top of .py files to make Python 2 accept that the file is UTF-8 (otherwise it gives an error on loading). However I added this and it didn't appear to make any
2018 Mar 22
0
[PATCH v7 6/6] v2v: Add -o rhv-upload output mode (RHBZ#1557273).
...hvupload." in + rmdir_on_exit t; + t in + + let diskid_file_of_id id = tmpdir // sprintf "diskid.%d" id in + + (* Write the Python precheck, plugin and create VM to a temporary file. *) + let precheck = + let precheck = tmpdir // "rhv-upload-precheck.py" in + with_open_out + precheck + (fun chan -> output_string chan Output_rhv_upload_precheck_source.code); + precheck in + let plugin = + let plugin = tmpdir // "rhv-upload-plugin.py" in + with_open_out + plugin + (fun chan -> output_string chan Output_rhv_upload_plugin_sou...
2018 Apr 05
2
[PATCH v8] v2v: Add -o rhv-upload output mode (RHBZ#1557273).
v7 was here: https://www.redhat.com/archives/libguestfs/2018-March/msg00143.html Since then: - Earlier patches are now upstream. - The to-do list is moved from the commit message to the TODO file. - This version forces -of raw + -oa sparse and gives an error in any other mode. We intend to lift these restrictions later. - Tested against latest imageio which supports longer timeouts,
2019 Sep 17
1
Re: [PATCH 7/8] v2v: -o rhv-upload: remove uploaded disks on failure
...delete_disks disks_uuids > + ); > + > (* Create an nbdkit instance for each disk and set the > * target URI to point to the NBD socket. > *) > @@ -419,7 +441,12 @@ If the messages above are not sufficient to diagnose the problem then add the > with_open_out ovf_file (fun chan -> output_string chan ovf); > if Python_script.run_command createvm_script json_params [ovf_file] <> 0 > then > - error (f_"failed to create virtual machine, see earlier errors") > + error (f_"failed to create virtual machin...
2018 Apr 05
0
[PATCH v8] v2v: Add -o rhv-upload output mode (RHBZ#1557273).
...hvupload." in + rmdir_on_exit t; + t in + + let diskid_file_of_id id = tmpdir // sprintf "diskid.%d" id in + + (* Write the Python precheck, plugin and create VM to a temporary file. *) + let precheck = + let precheck = tmpdir // "rhv-upload-precheck.py" in + with_open_out + precheck + (fun chan -> output_string chan Output_rhv_upload_precheck_source.code); + precheck in + let plugin = + let plugin = tmpdir // "rhv-upload-plugin.py" in + with_open_out + plugin + (fun chan -> output_string chan Output_rhv_upload_plugin_sou...
2018 Apr 10
0
[PATCH v9] v2v: Add -o rhv-upload output mode (RHBZ#1557273).
...hvupload." in + rmdir_on_exit t; + t in + + let diskid_file_of_id id = tmpdir // sprintf "diskid.%d" id in + + (* Write the Python precheck, plugin and create VM to a temporary file. *) + let precheck = + let precheck = tmpdir // "rhv-upload-precheck.py" in + with_open_out + precheck + (fun chan -> output_string chan Output_rhv_upload_precheck_source.code); + precheck in + let plugin = + let plugin = tmpdir // "rhv-upload-plugin.py" in + with_open_out + plugin + (fun chan -> output_string chan Output_rhv_upload_plugin_sou...
2018 Apr 10
2
[PATCH v9] v2v: Add -o rhv-upload output mode (RHBZ#1557273).
v8 was here: https://www.redhat.com/archives/libguestfs/2018-April/msg00022.html v8 -> v9: - Addresses the only feedback from Tomáš. Rich.
2019 Aug 13
5
[PATCH 0/3] generator: pod2text-related improvements
- refactor memoization code - pass pod as stdin rather than files Pino Toscano (3): generator: isolate memoized cache in own module generator: adjust variable names generator: improve pod2text invocation generator/Makefile.am | 3 ++ generator/memoized_cache.ml | 62 +++++++++++++++++++++ generator/memoized_cache.mli | 29 ++++++++++ generator/utils.ml | 101