Displaying 20 results from an estimated 194 matches for "external_command".
2015 Mar 18
0
[PATCH 1/2] mllib: allow external_command to return on nonzero return value
This is useful for probing probing for cache files such as:
external_command ?ignore_error:(Some true) ~prog "ls .cache/something.*"
will return command output (matched files) on its success or empty list
whenits exit code is other than 0 (there are no such files).
---
mllib/common_utils.ml | 15 ++++++++++-----
mllib/common_utils.mli | 2 +-
2 files changed, 1...
2019 Jan 16
1
Re: [PATCH 3/5] mltools: add simple tests for external_command
...-> "(" ^ (String.escaped (String.concat "," x)) ^ ")")
>
> (* Test Tools_utils.parse_size and Tools_utils.parse_resize. *)
> let test_parse_resize ctx =
> @@ -156,6 +157,26 @@ let test_run_commands ctx =
> end;
> ()
>
> +let test_external_command ctx =
> + assert_equal_stringlist [] (external_command "true");
> + assert_equal_stringlist ["out"] (external_command "echo out");
> + begin
> + let lines, code = external_command_code "true" in
> + assert_equal_int 0 code;
> + a...
2019 Jan 16
0
[PATCH 3/5] mltools: add simple tests for external_command
...tringlist = assert_equal ~printer:(fun x -> "(" ^ (String.escaped (String.concat "," x)) ^ ")")
(* Test Tools_utils.parse_size and Tools_utils.parse_resize. *)
let test_parse_resize ctx =
@@ -156,6 +157,26 @@ let test_run_commands ctx =
end;
()
+let test_external_command ctx =
+ assert_equal_stringlist [] (external_command "true");
+ assert_equal_stringlist ["out"] (external_command "echo out");
+ begin
+ let lines, code = external_command_code "true" in
+ assert_equal_int 0 code;
+ assert_equal_stringlist [] line...
2019 Jan 16
10
[PATCH 0/5] [RFC] builder: handle unavailable repos
...lures, and handle the failures gracefully in virt-builder.
RFC because I'm not yet too convinced the approach I used (especially
for the changes in the Curl module) is optimal, so looking for feedback
on this.
Pino Toscano (5):
mltools: split helper do_check_exitcode
mltools: create a new external_command_code
mltools: add simple tests for external_command
mltools: curl: turn Curl.run to raise exceptions
builder: ignore repositories with download failures
builder/builder.ml | 39 ++++++++++++++++++++---------
common/mltools/curl.ml | 15 ++++++++++-
common/mltoo...
2015 Mar 18
5
[PATCH 0/2] [RFE] virt-builder should support download resume
...port for resuming downloads in virt-builder.
Partially downloaded file is not deleted on exit anymore.
There is a check for partially downloaded image in cache directory
based on its name. When found, download_to crafts appropriate
options to continue its download.
Maros Zatko (2):
mllib: allow external_command to return [] on nonzero return value
builder: support for download resume
builder/downloader.ml | 16 ++++++++++++----
mllib/common_utils.ml | 15 ++++++++++-----
mllib/common_utils.mli | 2 +-
3 files changed, 23 insertions(+), 10 deletions(-)
--
1.9.3
2019 Jan 16
0
[PATCH 2/5] mltools: create a new external_command_code
Split most of the code from external_command to a new
external_command_code, so it is possible to get the exit code of the
process without considering it fatal.
---
common/mltools/tools_utils.ml | 22 ++++++++++------------
common/mltools/tools_utils.mli | 8 ++++++++
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/common/...
2019 Jan 16
2
Re: [PATCH 2/5] mltools: create a new external_command_code
On Wed, Jan 16, 2019 at 03:17:32PM +0100, Pino Toscano wrote:
> Split most of the code from external_command to a new
> external_command_code, so it is possible to get the exit code of the
> process without considering it fatal.
> ---
> common/mltools/tools_utils.ml | 22 ++++++++++------------
> common/mltools/tools_utils.mli | 8 ++++++++
> 2 files changed, 18 insertions(+), 12 dele...
2017 Oct 11
2
[PATCH] v2v: -i vmx: Refuse to load a disk image by accident.
...ve_vmx_escapes str =
(* Parsing. *)
let rec parse_file vmx_filename =
+ (* One person pointed -i vmx at the VMDK file, resulting in an out
+ * of memory error. Avoid this narrow case.
+ *)
+ let () =
+ let cmd = sprintf "file -b %s ||:" (quote vmx_filename) in
+ let out = external_command cmd in
+ match out with
+ | line :: _ when String.find line "disk image" >= 0 ->
+ error (f_"-i vmx: %s: this may be a disk image. You must specify the .vmx file only on the command line.")
+ vmx_filename
+ | _ -> () in
+
(* Read the whole...
2016 May 23
7
[PATCH 1/5] mllib: make external_command echo the command executed
...a/builder/checksums.ml b/builder/checksums.ml
index 95103e9..c8cdc98 100644
--- a/builder/checksums.ml
+++ b/builder/checksums.ml
@@ -43,7 +43,6 @@ let verify_checksum csum filename =
in
let cmd = sprintf "%s %s" prog (quote filename) in
- debug "%s" cmd;
let lines = external_command cmd in
match lines with
| [] ->
diff --git a/builder/downloader.ml b/builder/downloader.ml
index e31748d..7dc0a29 100644
--- a/builder/downloader.ml
+++ b/builder/downloader.ml
@@ -99,7 +99,6 @@ and download_to t ?(progress_bar = false) ~proxy uri filename =
t.curl
(if verbos...
2019 Mar 20
2
[PATCH] v2v: fix directory check for virtio-win as directory
...ebug "windows: copy_from_virtio_win: guest tools source directory %s" dir;
- if not (is_directory srcdir) then missing ()
+ if not (is_directory dir) then missing ()
else (
let cmd = sprintf "cd %s && find -L -type f" (quote dir) in
let paths = external_command cmd in
--
2.20.1
2017 Oct 11
1
Re: [PATCH] v2v: -i vmx: Refuse to load a disk image by accident.
...mx_filename =
> > + (* One person pointed -i vmx at the VMDK file, resulting in an out
> > + * of memory error. Avoid this narrow case.
> > + *)
> > + let () =
> > + let cmd = sprintf "file -b %s ||:" (quote vmx_filename) in
> > + let out = external_command cmd in
> > + match out with
> > + | line :: _ when String.find line "disk image" >= 0 ->
> > + error (f_"-i vmx: %s: this may be a disk image. You must specify the .vmx file only on the command line.")
> > + vmx_filename
>...
2016 May 23
0
[PATCH 4/5] mllib: move stringify_args from dib
...rec quote_args = function
+ | [] -> ""
+ | x :: xs -> " " ^ (Filename.quote x) ^ quote_args xs
+ in
+ match args with
+ | [] -> ""
+ | app :: xs -> app ^ quote_args xs
+
(* Run an external command, slurp up the output as a list of lines. *)
let external_command ?(echo_cmd = true) cmd =
if echo_cmd then
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index 7f288b4..5bcc692 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -239,6 +239,10 @@ val compare_version : string -> string -> int
val compare_lvm2_uuids : string...
2017 Oct 11
0
Re: [PATCH] v2v: -i vmx: Refuse to load a disk image by accident.
...*)
> let rec parse_file vmx_filename =
> + (* One person pointed -i vmx at the VMDK file, resulting in an out
> + * of memory error. Avoid this narrow case.
> + *)
> + let () =
> + let cmd = sprintf "file -b %s ||:" (quote vmx_filename) in
> + let out = external_command cmd in
> + match out with
> + | line :: _ when String.find line "disk image" >= 0 ->
> + error (f_"-i vmx: %s: this may be a disk image. You must specify the .vmx file only on the command line.")
> + vmx_filename
> + | _ -> ()...
2015 Mar 18
0
[PATCH 2/2] builder: support for download resume
...to ~prog t ?(progress_bar = false) ~proxy uri filename =
if bad_status_code status_code then
error (f_"failed to download %s: HTTP status code %s") uri status_code;
+ let cmd = sprintf "ls %s.* 2>/dev/null" filename in
+ let lines = if continue
+ then external_command ~prog ?ignore_error:(Some true) cmd
+ else [] in
+ let filename_new, continue_download = match List.length lines with
+ | 0 -> filename_new, ""
+ | _ -> List.hd lines, " -C -" in
+
(* Now download the file. *)
- let cmd = sprintf "%s%s%s -g -...
2016 Nov 12
0
[PATCH v2 4/5] v2v: ova: don't extract files from OVA if it's not needed
...let uncompress_head zcat file =
let cmd = sprintf "%s %s" zcat (quote file) in
@@ -67,11 +73,53 @@ object
tmpfile in
+ (* Untar only ovf and manifest from the archive *)
+ let untar_partial file outdir =
+ let files =
+ external_command (sprintf "tar -tf %s" (Filename.quote file)) in
+ List.iter (fun f ->
+ if Filename.check_suffix f ".ovf" ||
+ Filename.check_suffix f ".mf" then
+ untar ~path:f file outdir
+ ) files in
+
+ let qemu_im...
2017 Feb 06
0
[PATCH] v2v: ova: Don't rely on qemu-img version, test "offset" and "size" features.
...untar_metadata ova tmpdir;
diff --git a/v2v/utils.ml b/v2v/utils.ml
index 6a3074e..09d7af5 100644
--- a/v2v/utils.ml
+++ b/v2v/utils.ml
@@ -91,26 +91,37 @@ let du filename =
| line::_ -> Int64.of_string line
| [] -> invalid_arg filename
-let qemu_img_version () =
- let lines = external_command "qemu-img --version" in
- match lines with
- | [] -> error (f_"'qemu-img --version' returned no output")
- | line :: _ ->
- let rex = Str.regexp
- "qemu-img version \\([0-9]+\\)\\.\\([0-9]+\\)" in
- if Str.string_match rex line 0 then...
2019 Jan 28
1
Re: [PATCH 1/2] v2v: fix path to source when copying files from guest tools directory
...code actually work before? It seems to be checking if
literally srcdir (as a directory on the host) exists.
But yes, looks good apart from the overlong line.
Rich.
> else (
> let cmd = sprintf "cd %s && find -L -type f" (quote dir) in
> let paths = external_command cmd in
> --
> 2.20.1
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs@redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programmi...
2016 Sep 30
6
[PATCH 0/4] Consolidate Checksums as common code
Hi,
this small series moves the OCaml Checksums module from virt-builder to
mllib, adding more features to use it also for v2v.
Thanks,
Pino Toscano (4):
mllib: move Checksums from builder
mllib, builder: add and use Checksums.of_string
mllib: add SHA1 support in Checksums
v2v: -i ova: use Checksums
builder/Makefile.am | 2 --
builder/builder.ml | 6 +++-
2016 Nov 21
2
Re: [PATCH v2 4/5] v2v: ova: don't extract files from OVA if it's not needed
...object
>
> tmpfile in
>
> + (* Untar only ovf and manifest from the archive *)
> + let untar_partial file outdir =
I'd rename this as "untar_metadata", as it seems a better fitting name.
YMMV.
> + let files =
> + external_command (sprintf "tar -tf %s" (Filename.quote file)) in
> + List.iter (fun f ->
> + if Filename.check_suffix f ".ovf" ||
> + Filename.check_suffix f ".mf" then
> + untar ~path:f file outdir
> + ) files...
2014 Aug 21
3
Re: [PATCH] v2v: adding input -i ova
...let file = Str.matched_group 1 line in
> + let sha1 = Str.matched_group 2 line in
> +
> + let cmd = sprintf "sha1sum %s" (dir // file) in
Quoting needed, so:
let cmd = sprintf "sha1sum %s" (quote (dir // file)) in
> + let out = external_command ~prog cmd in
> + if List.exists (fun line -> string_contains line sha1) out == false then
You wouldn't normally write `== false'. This is more natural and
shorter:
if not (List.exists (fun line -> string_contains line sha1) out) then
> + error (f_&...