1 # libguestfs generated file
2 # WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 # ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 # Copyright (C) 2009 Red Hat Inc.
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 u"""Python bindings for libguestfs
24 g = guestfs.GuestFS ()
25 g.add_drive ("guest.img")
28 parts = g.list_partitions ()
30 The guestfs module provides a Python binding to the libguestfs API
31 for examining and modifying virtual machine disk images.
33 Amongst the things this is good for: making batch configuration
34 changes to guests, getting disk used/free statistics (see also:
35 virt-df), migrating between virtualization systems (see also:
36 virt-p2v), performing partial backups, performing partial guest
37 clones, cloning guests and changing registry/UUID/hostname info, and
40 Libguestfs uses Linux kernel and qemu code, and can access any type of
41 guest filesystem that Linux and qemu can, including but not limited
42 to: ext2/3/4, btrfs, FAT and NTFS, LVM, many different disk partition
43 schemes, qcow, qcow2, vmdk.
45 Libguestfs provides ways to enumerate guest storage (eg. partitions,
46 LVs, what filesystem is in each LV, etc.). It can also run commands
47 in the context of the guest. Also you can access filesystems over FTP.
49 Errors which happen while using the API are turned into Python
50 RuntimeError exceptions.
52 To create a guestfs handle you usually have to perform the following
55 # Create the handle, call add_drive at least once, and possibly
56 # several times if the guest has multiple block devices:
57 g = guestfs.GuestFS ()
58 g.add_drive ("guest.img")
60 # Launch the qemu subprocess and wait for it to become ready:
64 # Now you can issue commands, for example:
72 """Instances of this class are libguestfs API handles."""
75 """Create a new libguestfs handle."""
76 self._o = libguestfsmod.create ()
79 libguestfsmod.close (self._o)
82 u"""Internally libguestfs is implemented by running a
83 virtual machine using qemu(1).
85 You should call this after configuring the handle (eg.
86 adding drives) but before performing any actions.
88 return libguestfsmod.launch (self._o)
90 def wait_ready (self):
91 u"""Internally libguestfs is implemented by running a
92 virtual machine using qemu(1).
94 You should call this after "g.launch" to wait for the
97 return libguestfsmod.wait_ready (self._o)
99 def kill_subprocess (self):
100 u"""This kills the qemu subprocess. You should never need to
103 return libguestfsmod.kill_subprocess (self._o)
105 def add_drive (self, filename):
106 u"""This function adds a virtual machine disk image
107 "filename" to the guest. The first time you call this
108 function, the disk appears as IDE disk 0 ("/dev/sda") in
109 the guest, the second time as "/dev/sdb", and so on.
111 You don't necessarily need to be root when using
112 libguestfs. However you obviously do need sufficient
113 permissions to access the filename for whatever
114 operations you want to perform (ie. read access if you
115 just want to read the image or write access if you want
116 to modify the image).
118 This is equivalent to the qemu parameter "-drive
121 return libguestfsmod.add_drive (self._o, filename)
123 def add_cdrom (self, filename):
124 u"""This function adds a virtual CD-ROM disk image to the
127 This is equivalent to the qemu parameter "-cdrom
130 return libguestfsmod.add_cdrom (self._o, filename)
132 def config (self, qemuparam, qemuvalue):
133 u"""This can be used to add arbitrary qemu command line
134 parameters of the form "-param value". Actually it's not
135 quite arbitrary - we prevent you from setting some
136 parameters which would interfere with parameters that we
139 The first character of "param" string must be a "-"
144 return libguestfsmod.config (self._o, qemuparam, qemuvalue)
146 def set_qemu (self, qemu):
147 u"""Set the qemu binary that we will use.
149 The default is chosen when the library was compiled by
150 the configure script.
152 You can also override this by setting the
153 "LIBGUESTFS_QEMU" environment variable.
155 The string "qemu" is stashed in the libguestfs handle,
156 so the caller must make sure it remains valid for the
157 lifetime of the handle.
159 Setting "qemu" to "NULL" restores the default qemu
162 return libguestfsmod.set_qemu (self._o, qemu)
165 u"""Return the current qemu binary.
167 This is always non-NULL. If it wasn't set already, then
168 this will return the default qemu binary name.
170 return libguestfsmod.get_qemu (self._o)
172 def set_path (self, path):
173 u"""Set the path that libguestfs searches for kernel and
176 The default is "$libdir/guestfs" unless overridden by
177 setting "LIBGUESTFS_PATH" environment variable.
179 The string "path" is stashed in the libguestfs handle,
180 so the caller must make sure it remains valid for the
181 lifetime of the handle.
183 Setting "path" to "NULL" restores the default path.
185 return libguestfsmod.set_path (self._o, path)
188 u"""Return the current search path.
190 This is always non-NULL. If it wasn't set already, then
191 this will return the default path.
193 return libguestfsmod.get_path (self._o)
195 def set_autosync (self, autosync):
196 u"""If "autosync" is true, this enables autosync. Libguestfs
197 will make a best effort attempt to run "g.sync" when the
198 handle is closed (also if the program exits without
201 return libguestfsmod.set_autosync (self._o, autosync)
203 def get_autosync (self):
204 u"""Get the autosync flag.
206 return libguestfsmod.get_autosync (self._o)
208 def set_verbose (self, verbose):
209 u"""If "verbose" is true, this turns on verbose messages (to
212 Verbose messages are disabled unless the environment
213 variable "LIBGUESTFS_DEBUG" is defined and set to 1.
215 return libguestfsmod.set_verbose (self._o, verbose)
217 def get_verbose (self):
218 u"""This returns the verbose messages flag.
220 return libguestfsmod.get_verbose (self._o)
223 u"""This returns true iff this handle is ready to accept
224 commands (in the "READY" state).
226 For more information on states, see guestfs(3).
228 return libguestfsmod.is_ready (self._o)
230 def is_config (self):
231 u"""This returns true iff this handle is being configured
232 (in the "CONFIG" state).
234 For more information on states, see guestfs(3).
236 return libguestfsmod.is_config (self._o)
238 def is_launching (self):
239 u"""This returns true iff this handle is launching the
240 subprocess (in the "LAUNCHING" state).
242 For more information on states, see guestfs(3).
244 return libguestfsmod.is_launching (self._o)
247 u"""This returns true iff this handle is busy processing a
248 command (in the "BUSY" state).
250 For more information on states, see guestfs(3).
252 return libguestfsmod.is_busy (self._o)
254 def get_state (self):
255 u"""This returns the current state as an opaque integer.
256 This is only useful for printing debug and internal
259 For more information on states, see guestfs(3).
261 return libguestfsmod.get_state (self._o)
264 u"""This sets the state to "BUSY". This is only used when
265 implementing actions using the low-level API.
267 For more information on states, see guestfs(3).
269 return libguestfsmod.set_busy (self._o)
271 def set_ready (self):
272 u"""This sets the state to "READY". This is only used when
273 implementing actions using the low-level API.
275 For more information on states, see guestfs(3).
277 return libguestfsmod.set_ready (self._o)
279 def mount (self, device, mountpoint):
280 u"""Mount a guest disk at a position in the filesystem.
281 Block devices are named "/dev/sda", "/dev/sdb" and so
282 on, as they were added to the guest. If those block
283 devices contain partitions, they will have the usual
284 names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
287 The rules are the same as for mount(2): A filesystem
288 must first be mounted on "/" before others can be
289 mounted. Other filesystems can only be mounted on
290 directories which already exist.
292 The mounted filesystem is writable, if we have
293 sufficient permissions on the underlying device.
295 The filesystem options "sync" and "noatime" are set with
296 this call, in order to improve reliability.
298 return libguestfsmod.mount (self._o, device, mountpoint)
301 u"""This syncs the disk, so that any writes are flushed
302 through to the underlying disk image.
304 You should always call this if you have modified a disk
305 image, before closing the handle.
307 return libguestfsmod.sync (self._o)
309 def touch (self, path):
310 u"""Touch acts like the touch(1) command. It can be used to
311 update the timestamps on a file, or, if the file does
312 not exist, to create a new zero-length file.
314 return libguestfsmod.touch (self._o, path)
316 def cat (self, path):
317 u"""Return the contents of the file named "path".
319 Note that this function cannot correctly handle binary
320 files (specifically, files containing "\\0" character
321 which is treated as end of string). For those you need
322 to use the "g.download" function which has a more
325 Because of the message protocol, there is a transfer
326 limit of somewhere between 2MB and 4MB. To transfer
327 large files you should use FTP.
329 return libguestfsmod.cat (self._o, path)
331 def ll (self, directory):
332 u"""List the files in "directory" (relative to the root
333 directory, there is no cwd) in the format of 'ls -la'.
335 This command is mostly useful for interactive sessions.
336 It is *not* intended that you try to parse the output
339 return libguestfsmod.ll (self._o, directory)
341 def ls (self, directory):
342 u"""List the files in "directory" (relative to the root
343 directory, there is no cwd). The '.' and '..' entries
344 are not returned, but hidden files are shown.
346 This command is mostly useful for interactive sessions.
347 Programs should probably use "g.readdir" instead.
349 This function returns a list of strings.
351 return libguestfsmod.ls (self._o, directory)
353 def list_devices (self):
354 u"""List all the block devices.
356 The full block device names are returned, eg. "/dev/sda"
358 This function returns a list of strings.
360 return libguestfsmod.list_devices (self._o)
362 def list_partitions (self):
363 u"""List all the partitions detected on all block devices.
365 The full partition device names are returned, eg.
368 This does not return logical volumes. For that you will
369 need to call "g.lvs".
371 This function returns a list of strings.
373 return libguestfsmod.list_partitions (self._o)
376 u"""List all the physical volumes detected. This is the
377 equivalent of the pvs(8) command.
379 This returns a list of just the device names that
380 contain PVs (eg. "/dev/sda2").
382 See also "g.pvs_full".
384 This function returns a list of strings.
386 return libguestfsmod.pvs (self._o)
389 u"""List all the volumes groups detected. This is the
390 equivalent of the vgs(8) command.
392 This returns a list of just the volume group names that
393 were detected (eg. "VolGroup00").
395 See also "g.vgs_full".
397 This function returns a list of strings.
399 return libguestfsmod.vgs (self._o)
402 u"""List all the logical volumes detected. This is the
403 equivalent of the lvs(8) command.
405 This returns a list of the logical volume device names
406 (eg. "/dev/VolGroup00/LogVol00").
408 See also "g.lvs_full".
410 This function returns a list of strings.
412 return libguestfsmod.lvs (self._o)
415 u"""List all the physical volumes detected. This is the
416 equivalent of the pvs(8) command. The "full" version
419 This function returns a list of PVs. Each PV is
420 represented as a dictionary.
422 return libguestfsmod.pvs_full (self._o)
425 u"""List all the volumes groups detected. This is the
426 equivalent of the vgs(8) command. The "full" version
429 This function returns a list of VGs. Each VG is
430 represented as a dictionary.
432 return libguestfsmod.vgs_full (self._o)
435 u"""List all the logical volumes detected. This is the
436 equivalent of the lvs(8) command. The "full" version
439 This function returns a list of LVs. Each LV is
440 represented as a dictionary.
442 return libguestfsmod.lvs_full (self._o)
444 def read_lines (self, path):
445 u"""Return the contents of the file named "path".
447 The file contents are returned as a list of lines.
448 Trailing "LF" and "CRLF" character sequences are *not*
451 Note that this function cannot correctly handle binary
452 files (specifically, files containing "\\0" character
453 which is treated as end of line). For those you need to
454 use the "g.read_file" function which has a more complex
457 This function returns a list of strings.
459 return libguestfsmod.read_lines (self._o, path)
461 def aug_init (self, root, flags):
462 u"""Create a new Augeas handle for editing configuration
463 files. If there was any previous Augeas handle
464 associated with this guestfs session, then it is closed.
466 You must call this before using any other "g.aug_*"
469 "root" is the filesystem root. "root" must not be NULL,
472 The flags are the same as the flags defined in
473 <augeas.h>, the logical *or* of the following integers:
475 "AUG_SAVE_BACKUP" = 1
476 Keep the original file with a ".augsave" extension.
478 "AUG_SAVE_NEWFILE" = 2
479 Save changes into a file with extension ".augnew",
480 and do not overwrite original. Overrides
484 Typecheck lenses (can be expensive).
487 Do not use standard load path for modules.
490 Make save a no-op, just record what would have been
494 Do not load the tree in "g.aug_init".
496 To close the handle, you can call "g.aug_close".
498 To find out more about Augeas, see <http://augeas.net/>.
500 return libguestfsmod.aug_init (self._o, root, flags)
502 def aug_close (self):
503 u"""Close the current Augeas handle and free up any
504 resources used by it. After calling this, you have to
505 call "g.aug_init" again before you can use any other
508 return libguestfsmod.aug_close (self._o)
510 def aug_defvar (self, name, expr):
511 u"""Defines an Augeas variable "name" whose value is the
512 result of evaluating "expr". If "expr" is NULL, then
515 On success this returns the number of nodes in "expr",
516 or 0 if "expr" evaluates to something which is not a
519 return libguestfsmod.aug_defvar (self._o, name, expr)
521 def aug_defnode (self, name, expr, val):
522 u"""Defines a variable "name" whose value is the result of
525 If "expr" evaluates to an empty nodeset, a node is
526 created, equivalent to calling "g.aug_set" "expr",
527 "value". "name" will be the nodeset containing that
530 On success this returns a pair containing the number of
531 nodes in the nodeset, and a boolean flag if a node was
534 This function returns a tuple (int, bool).
536 return libguestfsmod.aug_defnode (self._o, name, expr, val)
538 def aug_get (self, path):
539 u"""Look up the value associated with "path". If "path"
540 matches exactly one node, the "value" is returned.
542 return libguestfsmod.aug_get (self._o, path)
544 def aug_set (self, path, val):
545 u"""Set the value associated with "path" to "value".
547 return libguestfsmod.aug_set (self._o, path, val)
549 def aug_insert (self, path, label, before):
550 u"""Create a new sibling "label" for "path", inserting it
551 into the tree before or after "path" (depending on the
552 boolean flag "before").
554 "path" must match exactly one existing node in the tree,
555 and "label" must be a label, ie. not contain "/", "*" or
556 end with a bracketed index "[N]".
558 return libguestfsmod.aug_insert (self._o, path, label, before)
560 def aug_rm (self, path):
561 u"""Remove "path" and all of its children.
563 On success this returns the number of entries which were
566 return libguestfsmod.aug_rm (self._o, path)
568 def aug_mv (self, src, dest):
569 u"""Move the node "src" to "dest". "src" must match exactly
570 one node. "dest" is overwritten if it exists.
572 return libguestfsmod.aug_mv (self._o, src, dest)
574 def aug_match (self, path):
575 u"""Returns a list of paths which match the path expression
576 "path". The returned paths are sufficiently qualified so
577 that they match exactly one node in the current tree.
579 This function returns a list of strings.
581 return libguestfsmod.aug_match (self._o, path)
584 u"""This writes all pending changes to disk.
586 The flags which were passed to "g.aug_init" affect
587 exactly how files are saved.
589 return libguestfsmod.aug_save (self._o)
592 u"""Load files into the tree.
594 See "aug_load" in the Augeas documentation for the full
597 return libguestfsmod.aug_load (self._o)
599 def aug_ls (self, path):
600 u"""This is just a shortcut for listing "g.aug_match"
601 "path/*" and sorting the resulting nodes into
604 This function returns a list of strings.
606 return libguestfsmod.aug_ls (self._o, path)
609 u"""Remove the single file "path".
611 return libguestfsmod.rm (self._o, path)
613 def rmdir (self, path):
614 u"""Remove the single directory "path".
616 return libguestfsmod.rmdir (self._o, path)
618 def rm_rf (self, path):
619 u"""Remove the file or directory "path", recursively
620 removing the contents if its a directory. This is like
621 the "rm -rf" shell command.
623 return libguestfsmod.rm_rf (self._o, path)
625 def mkdir (self, path):
626 u"""Create a directory named "path".
628 return libguestfsmod.mkdir (self._o, path)
630 def mkdir_p (self, path):
631 u"""Create a directory named "path", creating any parent
632 directories as necessary. This is like the "mkdir -p"
635 return libguestfsmod.mkdir_p (self._o, path)
637 def chmod (self, mode, path):
638 u"""Change the mode (permissions) of "path" to "mode". Only
639 numeric modes are supported.
641 return libguestfsmod.chmod (self._o, mode, path)
643 def chown (self, owner, group, path):
644 u"""Change the file owner to "owner" and group to "group".
646 Only numeric uid and gid are supported. If you want to
647 use names, you will need to locate and parse the
648 password file yourself (Augeas support makes this
651 return libguestfsmod.chown (self._o, owner, group, path)
653 def exists (self, path):
654 u"""This returns "true" if and only if there is a file,
655 directory (or anything) with the given "path" name.
657 See also "g.is_file", "g.is_dir", "g.stat".
659 return libguestfsmod.exists (self._o, path)
661 def is_file (self, path):
662 u"""This returns "true" if and only if there is a file with
663 the given "path" name. Note that it returns false for
664 other objects like directories.
668 return libguestfsmod.is_file (self._o, path)
670 def is_dir (self, path):
671 u"""This returns "true" if and only if there is a directory
672 with the given "path" name. Note that it returns false
673 for other objects like files.
677 return libguestfsmod.is_dir (self._o, path)
679 def pvcreate (self, device):
680 u"""This creates an LVM physical volume on the named
681 "device", where "device" should usually be a partition
682 name such as "/dev/sda1".
684 return libguestfsmod.pvcreate (self._o, device)
686 def vgcreate (self, volgroup, physvols):
687 u"""This creates an LVM volume group called "volgroup" from
688 the non-empty list of physical volumes "physvols".
690 return libguestfsmod.vgcreate (self._o, volgroup, physvols)
692 def lvcreate (self, logvol, volgroup, mbytes):
693 u"""This creates an LVM volume group called "logvol" on the
694 volume group "volgroup", with "size" megabytes.
696 return libguestfsmod.lvcreate (self._o, logvol, volgroup, mbytes)
698 def mkfs (self, fstype, device):
699 u"""This creates a filesystem on "device" (usually a
700 partition of LVM logical volume). The filesystem type is
701 "fstype", for example "ext3".
703 return libguestfsmod.mkfs (self._o, fstype, device)
705 def sfdisk (self, device, cyls, heads, sectors, lines):
706 u"""This is a direct interface to the sfdisk(8) program for
707 creating partitions on block devices.
709 "device" should be a block device, for example
712 "cyls", "heads" and "sectors" are the number of
713 cylinders, heads and sectors on the device, which are
714 passed directly to sfdisk as the *-C*, *-H* and *-S*
715 parameters. If you pass 0 for any of these, then the
716 corresponding parameter is omitted. Usually for 'large'
717 disks, you can just pass 0 for these, but for small
718 (floppy-sized) disks, sfdisk (or rather, the kernel)
719 cannot work out the right geometry and you will need to
722 "lines" is a list of lines that we feed to "sfdisk". For
723 more information refer to the sfdisk(8) manpage.
725 To create a single partition occupying the whole disk,
726 you would pass "lines" as a single element list, when
727 the single element being the string "," (comma).
729 This command is dangerous. Without careful use you can
730 easily destroy all your data.
732 return libguestfsmod.sfdisk (self._o, device, cyls, heads, sectors, lines)
734 def write_file (self, path, content, size):
735 u"""This call creates a file called "path". The contents of
736 the file is the string "content" (which can contain any
737 8 bit data), with length "size".
739 As a special case, if "size" is 0 then the length is
740 calculated using "strlen" (so in this case the content
741 cannot contain embedded ASCII NULs).
743 Because of the message protocol, there is a transfer
744 limit of somewhere between 2MB and 4MB. To transfer
745 large files you should use FTP.
747 return libguestfsmod.write_file (self._o, path, content, size)
749 def umount (self, pathordevice):
750 u"""This unmounts the given filesystem. The filesystem may
751 be specified either by its mountpoint (path) or the
752 device which contains the filesystem.
754 return libguestfsmod.umount (self._o, pathordevice)
757 u"""This returns the list of currently mounted filesystems.
758 It returns the list of devices (eg. "/dev/sda1",
761 Some internal mounts are not shown.
763 This function returns a list of strings.
765 return libguestfsmod.mounts (self._o)
767 def umount_all (self):
768 u"""This unmounts all mounted filesystems.
770 Some internal mounts are not unmounted by this call.
772 return libguestfsmod.umount_all (self._o)
774 def lvm_remove_all (self):
775 u"""This command removes all LVM logical volumes, volume
776 groups and physical volumes.
778 This command is dangerous. Without careful use you can
779 easily destroy all your data.
781 return libguestfsmod.lvm_remove_all (self._o)
783 def file (self, path):
784 u"""This call uses the standard file(1) command to determine
785 the type or contents of the file. This also works on
786 devices, for example to find out whether a partition
787 contains a filesystem.
789 The exact command which runs is "file -bsL path". Note
790 in particular that the filename is not prepended to the
791 output (the "-b" option).
793 return libguestfsmod.file (self._o, path)
795 def command (self, arguments):
796 u"""This call runs a command from the guest filesystem. The
797 filesystem must be mounted, and must contain a
798 compatible operating system (ie. something Linux, with
799 the same or compatible processor architecture).
801 The single parameter is an argv-style list of arguments.
802 The first element is the name of the program to run.
803 Subsequent elements are parameters. The list must be
804 non-empty (ie. must contain a program name).
806 The $PATH environment variable will contain at least
807 "/usr/bin" and "/bin". If you require a program from
808 another location, you should provide the full path in
811 Shared libraries and data files required by the program
812 must be available on filesystems which are mounted in
813 the correct places. It is the caller's responsibility to
814 ensure all filesystems that are needed are mounted at
817 return libguestfsmod.command (self._o, arguments)
819 def command_lines (self, arguments):
820 u"""This is the same as "g.command", but splits the result
821 into a list of lines.
823 This function returns a list of strings.
825 return libguestfsmod.command_lines (self._o, arguments)
827 def stat (self, path):
828 u"""Returns file information for the given "path".
830 This is the same as the stat(2) system call.
832 This function returns a dictionary, with keys matching
833 the various fields in the stat structure.
835 return libguestfsmod.stat (self._o, path)
837 def lstat (self, path):
838 u"""Returns file information for the given "path".
840 This is the same as "g.stat" except that if "path" is a
841 symbolic link, then the link is stat-ed, not the file it
844 This is the same as the lstat(2) system call.
846 This function returns a dictionary, with keys matching
847 the various fields in the stat structure.
849 return libguestfsmod.lstat (self._o, path)
851 def statvfs (self, path):
852 u"""Returns file system statistics for any mounted file
853 system. "path" should be a file or directory in the
854 mounted file system (typically it is the mount point
855 itself, but it doesn't need to be).
857 This is the same as the statvfs(2) system call.
859 This function returns a dictionary, with keys matching
860 the various fields in the statvfs structure.
862 return libguestfsmod.statvfs (self._o, path)
864 def tune2fs_l (self, device):
865 u"""This returns the contents of the ext2 or ext3 filesystem
866 superblock on "device".
868 It is the same as running "tune2fs -l device". See
869 tune2fs(8) manpage for more details. The list of fields
870 returned isn't clearly defined, and depends on both the
871 version of "tune2fs" that libguestfs was built against,
872 and the filesystem itself.
874 This function returns a dictionary.
876 return libguestfsmod.tune2fs_l (self._o, device)
878 def blockdev_setro (self, device):
879 u"""Sets the block device named "device" to read-only.
881 This uses the blockdev(8) command.
883 return libguestfsmod.blockdev_setro (self._o, device)
885 def blockdev_setrw (self, device):
886 u"""Sets the block device named "device" to read-write.
888 This uses the blockdev(8) command.
890 return libguestfsmod.blockdev_setrw (self._o, device)
892 def blockdev_getro (self, device):
893 u"""Returns a boolean indicating if the block device is
894 read-only (true if read-only, false if not).
896 This uses the blockdev(8) command.
898 return libguestfsmod.blockdev_getro (self._o, device)
900 def blockdev_getss (self, device):
901 u"""This returns the size of sectors on a block device.
902 Usually 512, but can be larger for modern devices.
904 (Note, this is not the size in sectors, use
905 "g.blockdev_getsz" for that).
907 This uses the blockdev(8) command.
909 return libguestfsmod.blockdev_getss (self._o, device)
911 def blockdev_getbsz (self, device):
912 u"""This returns the block size of a device.
914 (Note this is different from both *size in blocks* and
915 *filesystem block size*).
917 This uses the blockdev(8) command.
919 return libguestfsmod.blockdev_getbsz (self._o, device)
921 def blockdev_setbsz (self, device, blocksize):
922 u"""This sets the block size of a device.
924 (Note this is different from both *size in blocks* and
925 *filesystem block size*).
927 This uses the blockdev(8) command.
929 return libguestfsmod.blockdev_setbsz (self._o, device, blocksize)
931 def blockdev_getsz (self, device):
932 u"""This returns the size of the device in units of 512-byte
933 sectors (even if the sectorsize isn't 512 bytes ...
936 See also "g.blockdev_getss" for the real sector size of
937 the device, and "g.blockdev_getsize64" for the more
938 useful *size in bytes*.
940 This uses the blockdev(8) command.
942 return libguestfsmod.blockdev_getsz (self._o, device)
944 def blockdev_getsize64 (self, device):
945 u"""This returns the size of the device in bytes.
947 See also "g.blockdev_getsz".
949 This uses the blockdev(8) command.
951 return libguestfsmod.blockdev_getsize64 (self._o, device)
953 def blockdev_flushbufs (self, device):
954 u"""This tells the kernel to flush internal buffers
955 associated with "device".
957 This uses the blockdev(8) command.
959 return libguestfsmod.blockdev_flushbufs (self._o, device)
961 def blockdev_rereadpt (self, device):
962 u"""Reread the partition table on "device".
964 This uses the blockdev(8) command.
966 return libguestfsmod.blockdev_rereadpt (self._o, device)
968 def upload (self, filename, remotefilename):
969 u"""Upload local file "filename" to "remotefilename" on the
972 "filename" can also be a named pipe.
974 See also "g.download".
976 return libguestfsmod.upload (self._o, filename, remotefilename)
978 def download (self, remotefilename, filename):
979 u"""Download file "remotefilename" and save it as "filename"
980 on the local machine.
982 "filename" can also be a named pipe.
984 See also "g.upload", "g.cat".
986 return libguestfsmod.download (self._o, remotefilename, filename)
988 def checksum (self, csumtype, path):
989 u"""This call computes the MD5, SHAx or CRC checksum of the
992 The type of checksum to compute is given by the
993 "csumtype" parameter which must have one of the
997 Compute the cyclic redundancy check (CRC) specified
998 by POSIX for the "cksum" command.
1001 Compute the MD5 hash (using the "md5sum" program).
1004 Compute the SHA1 hash (using the "sha1sum" program).
1007 Compute the SHA224 hash (using the "sha224sum"
1011 Compute the SHA256 hash (using the "sha256sum"
1015 Compute the SHA384 hash (using the "sha384sum"
1019 Compute the SHA512 hash (using the "sha512sum"
1022 The checksum is returned as a printable string.
1024 return libguestfsmod.checksum (self._o, csumtype, path)
1026 def tar_in (self, tarfile, directory):
1027 u"""This command uploads and unpacks local file "tarfile"
1028 (an *uncompressed* tar file) into "directory".
1030 To upload a compressed tarball, use "g.tgz_in".
1032 return libguestfsmod.tar_in (self._o, tarfile, directory)
1034 def tar_out (self, directory, tarfile):
1035 u"""This command packs the contents of "directory" and
1036 downloads it to local file "tarfile".
1038 To download a compressed tarball, use "g.tgz_out".
1040 return libguestfsmod.tar_out (self._o, directory, tarfile)
1042 def tgz_in (self, tarball, directory):
1043 u"""This command uploads and unpacks local file "tarball" (a
1044 *gzip compressed* tar file) into "directory".
1046 To upload an uncompressed tarball, use "g.tar_in".
1048 return libguestfsmod.tgz_in (self._o, tarball, directory)
1050 def tgz_out (self, directory, tarball):
1051 u"""This command packs the contents of "directory" and
1052 downloads it to local file "tarball".
1054 To download an uncompressed tarball, use "g.tar_out".
1056 return libguestfsmod.tgz_out (self._o, directory, tarball)