X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=slave.mli;h=c1fdb04d73f526c29aa42cebc375b01c9500c3f5;hb=87a075aaada42182cd7047d110f83eaa8273b78d;hp=d6f9cf7ada50df0427bfc13fd212ef55733df5cc;hpb=bea873ce68b3e788c2926735fe3d513cbea24f06;p=guestfs-browser.git diff --git a/slave.mli b/slave.mli index d6f9cf7..c1fdb04 100644 --- a/slave.mli +++ b/slave.mli @@ -63,14 +63,12 @@ val no_callback : 'a callback (** The main thread uses this as a callback if it doesn't care about the return value from a command. *) -type domain = { - dom_id : int; - dom_name : string; - dom_state : Libvirt.Domain.state; -} - (** List of domains as returned in the {!connect} callback. *) - -val connect : ?fail:exn callback -> string option -> domain list callback -> unit +val checksum_file : ?fail:exn callback -> Slave_types.source -> string -> string -> string callback -> unit + (** [checksum_file src pathname csumtype cb] calculates the checksum + of the file [pathname]. [csumtype] is one of the types + supported by libguestfs. *) + +val connect : ?fail:exn callback -> string option -> Slave_types.domain list callback -> unit (** [connect uri cb] causes the slave thread to disconnect from libvirt and connect to the libvirt [uri]. If this succeeds, then the list of all domains fetched from libvirt and [cb] is @@ -83,31 +81,43 @@ val connect : ?fail:exn callback -> string option -> domain list callback -> uni If [fail] is passed, then failures cause this callback to be called. If not, the global failure hook is called. *) -type inspection_data = { - insp_all_filesystems : (string * string) list; - (** see {!Guestfs.list_filesystems} *) - insp_oses : inspection_os list; - (** one entry per root (operating system), see {!Guestfs.inspect_os} *) -} - (** The inspection data returned in the callback from - {!open_domain} and {!open_images}. *) -and inspection_os = { - insp_root : string; (** see {!Guestfs.inspect_os} *) - insp_arch : string; - insp_distro : string; - insp_filesystems : string array; - insp_hostname : string; - insp_major_version : int; - insp_minor_version : int; - insp_mountpoints : (string * string) list; - insp_package_format : string; - insp_package_management : string; - insp_product_name : string; - insp_type : string; - insp_windows_systemroot : string option; -} - -val open_domain : ?fail:exn callback -> string -> inspection_data callback -> unit +val disk_usage : ?fail:exn callback -> Slave_types.source -> string -> int64 callback -> unit + (** [disk_usage src pathname cb] calculates the disk usage of + directory [pathname] and calls the callback with the answer + (size of {b kilobytes}). *) + +val download_dir_tarball : ?fail:exn callback -> Slave_types.source -> string -> Slave_types.download_dir_tarball_format -> string -> unit callback -> unit + (** [download_dir_tarball_format src pathname format localfile cb] + downloads directory [pathname] to the named local file (a + tarball), and then calls the callback function. + + [format] controls the download format, which is one of + uncompressed tar, gzip-compressed tar, or xz-compressed tar. *) + +val download_dir_find0 : ?fail:exn callback -> Slave_types.source -> string -> string -> unit callback -> unit + (** [download_dir_find0 src pathname localfile cb] downloads the + list of filenames of directory [pathname] to the named local + file (a ASCII NUL-separated text file), and then calls the + callback function. *) + +val download_file : ?fail:exn callback -> Slave_types.source -> string -> string -> unit callback -> unit + (** [download_file src pathname localfile cb] downloads [pathname] + to the named local file, and then calls the callback function. *) + +val download_file_if_not_exist : ?fail:exn callback -> Slave_types.source -> string -> string -> unit callback -> unit + (** Like {!download_file} except that if [localfile] already exists + then the download is skipped. You can use this to implement + caching of remote files. *) + +val file_information : ?fail:exn callback -> Slave_types.source -> string -> string callback -> unit + (** [file_information src pathname cb] calculates the file + information of the file [pathname]. *) + +val list_applications : ?fail:exn callback -> Slave_types.inspection_os -> Guestfs.application array callback -> unit + (** [list_applications os cb] lists the applications in the + guest using libguestfs inspection. *) + +val open_domain : ?fail:exn callback -> string -> Slave_types.inspection_data callback -> unit (** [open_domain name cb] retrieves the list of block devices for the libvirt domain [name], creates a libguestfs handle, adds those block devices, launches the handle, and performs @@ -122,7 +132,7 @@ val open_domain : ?fail:exn callback -> string -> inspection_data callback -> un If [fail] is passed, then failures cause this callback to be called. If not, the global failure hook is called. *) -val open_images : ?fail:exn callback -> (string * string option) list -> inspection_data callback -> unit +val open_images : ?fail:exn callback -> (string * string option) list -> Slave_types.inspection_data callback -> unit (** [open_images images cb] is like {!open_domain} except that it opens local disk image(s) directly. [images] is a list of [(filename, format)] pairs. @@ -130,17 +140,7 @@ val open_images : ?fail:exn callback -> (string * string option) list -> inspect If [fail] is passed, then failures cause this callback to be called. If not, the global failure hook is called. *) -type source = OS of inspection_os | Volume of string - (** Source type used by {!read_directory}. *) - -type direntry = { - dent_name : string; (** Basename in directory. *) - dent_stat : Guestfs.stat; (** stat(2) for this entry. *) - dent_link : string; (** (for symlinks only) readlink(2). *) -} - (** Directory entry returned by {!read_directory}. *) - -val read_directory : ?fail:exn callback -> source -> string -> direntry list callback -> unit +val read_directory : ?fail:exn callback -> Slave_types.source -> string -> Slave_types.direntry list callback -> unit (** [read_directory src dir cb] reads the contents of the directory [dir] from source [src], and calls the callback function [cb] with the resulting list of directory entries, if successful. @@ -154,6 +154,13 @@ val read_directory : ?fail:exn callback -> source -> string -> direntry list cal If [fail] is passed, then failures cause this callback to be called. If not, the global failure hook is called. *) +val run_command : ?fail:exn callback -> string -> unit callback -> unit + (** [run_command cmd] runs an external command [cmd]. This is + useful for possibly long-running commands as it keeps the + display interactive. Be careful to quote arguments in the + command properly (see {!Filename.quote}). The external command + must eventually terminate and must not wait for user input. *) + val discard_command_queue : unit -> unit (** [discard_command_queue ()] discards any commands on the command queue. @@ -180,7 +187,9 @@ val exit_thread : unit -> unit and display those in the main thread. {!set_busy_hook} and {!set_idle_hook} are used to implement a - "throbber". *) + "throbber". + + {!set_progress_hook} is used to implement a progress bar. *) val set_failure_hook : exn callback -> unit (** Set the function in the main thread which is called if there is @@ -195,3 +204,14 @@ val set_idle_hook : unit callback -> unit (** Set the function in the main thread which is called whenever the slave thread stops working on a command {i and} has no more commands left in the queue to work on. *) + +val set_status_hook : string callback -> unit + (** Set the function in the main thread which is called to + update the status bar. The slave thread updates the + status bar when an operation starts or stops, keeping the + user informed of what is happening. *) + +val set_progress_hook : (int64 * int64) callback -> unit + (** Set the function in the main thread which is called whenever + the slave thread receives a progress notification message + from libguestfs. *)