Generator now runs automatically when it has changed.
[libguestfs.git] / python / guestfs.py
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.
4 #
5 # Copyright (C) 2009 Red Hat Inc.
6 #
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.
11 #
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.
16 #
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
20
21 u"""Python bindings for libguestfs
22
23 import guestfs
24 g = guestfs.GuestFS ()
25 g.add_drive ("guest.img")
26 g.launch ()
27 g.wait_ready ()
28 parts = g.list_partitions ()
29
30 The guestfs module provides a Python binding to the libguestfs API
31 for examining and modifying virtual machine disk images.
32
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
38 much else besides.
39
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.
44
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.
48
49 Errors which happen while using the API are turned into Python
50 RuntimeError exceptions.
51
52 To create a guestfs handle you usually have to perform the following
53 sequence of calls:
54
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")
59
60 # Launch the qemu subprocess and wait for it to become ready:
61 g.launch ()
62 g.wait_ready ()
63
64 # Now you can issue commands, for example:
65 logvols = g.lvs ()
66
67 """
68
69 import libguestfsmod
70
71 class GuestFS:
72     """Instances of this class are libguestfs API handles."""
73
74     def __init__ (self):
75         """Create a new libguestfs handle."""
76         self._o = libguestfsmod.create ()
77
78     def __del__ (self):
79         libguestfsmod.close (self._o)
80
81     def test0 (self, str, optstr, strlist, b, integer, filein, fileout):
82         return libguestfsmod.test0 (self._o, str, optstr, strlist, b, integer, filein, fileout)
83
84     def test0rint (self, val):
85         return libguestfsmod.test0rint (self._o, val)
86
87     def test0rinterr (self):
88         return libguestfsmod.test0rinterr (self._o)
89
90     def test0rint64 (self, val):
91         return libguestfsmod.test0rint64 (self._o, val)
92
93     def test0rint64err (self):
94         return libguestfsmod.test0rint64err (self._o)
95
96     def test0rbool (self, val):
97         return libguestfsmod.test0rbool (self._o, val)
98
99     def test0rboolerr (self):
100         return libguestfsmod.test0rboolerr (self._o)
101
102     def test0rconststring (self, val):
103         return libguestfsmod.test0rconststring (self._o, val)
104
105     def test0rconststringerr (self):
106         return libguestfsmod.test0rconststringerr (self._o)
107
108     def test0rstring (self, val):
109         return libguestfsmod.test0rstring (self._o, val)
110
111     def test0rstringerr (self):
112         return libguestfsmod.test0rstringerr (self._o)
113
114     def test0rstringlist (self, val):
115         return libguestfsmod.test0rstringlist (self._o, val)
116
117     def test0rstringlisterr (self):
118         return libguestfsmod.test0rstringlisterr (self._o)
119
120     def test0rintbool (self, val):
121         return libguestfsmod.test0rintbool (self._o, val)
122
123     def test0rintboolerr (self):
124         return libguestfsmod.test0rintboolerr (self._o)
125
126     def test0rpvlist (self, val):
127         return libguestfsmod.test0rpvlist (self._o, val)
128
129     def test0rpvlisterr (self):
130         return libguestfsmod.test0rpvlisterr (self._o)
131
132     def test0rvglist (self, val):
133         return libguestfsmod.test0rvglist (self._o, val)
134
135     def test0rvglisterr (self):
136         return libguestfsmod.test0rvglisterr (self._o)
137
138     def test0rlvlist (self, val):
139         return libguestfsmod.test0rlvlist (self._o, val)
140
141     def test0rlvlisterr (self):
142         return libguestfsmod.test0rlvlisterr (self._o)
143
144     def test0rstat (self, val):
145         return libguestfsmod.test0rstat (self._o, val)
146
147     def test0rstaterr (self):
148         return libguestfsmod.test0rstaterr (self._o)
149
150     def test0rstatvfs (self, val):
151         return libguestfsmod.test0rstatvfs (self._o, val)
152
153     def test0rstatvfserr (self):
154         return libguestfsmod.test0rstatvfserr (self._o)
155
156     def test0rhashtable (self, val):
157         return libguestfsmod.test0rhashtable (self._o, val)
158
159     def test0rhashtableerr (self):
160         return libguestfsmod.test0rhashtableerr (self._o)
161
162     def launch (self):
163         u"""Internally libguestfs is implemented by running a
164         virtual machine using qemu(1).
165         
166         You should call this after configuring the handle (eg.
167         adding drives) but before performing any actions.
168         """
169         return libguestfsmod.launch (self._o)
170
171     def wait_ready (self):
172         u"""Internally libguestfs is implemented by running a
173         virtual machine using qemu(1).
174         
175         You should call this after "g.launch" to wait for the
176         launch to complete.
177         """
178         return libguestfsmod.wait_ready (self._o)
179
180     def kill_subprocess (self):
181         u"""This kills the qemu subprocess. You should never need to
182         call this.
183         """
184         return libguestfsmod.kill_subprocess (self._o)
185
186     def add_drive (self, filename):
187         u"""This function adds a virtual machine disk image
188         "filename" to the guest. The first time you call this
189         function, the disk appears as IDE disk 0 ("/dev/sda") in
190         the guest, the second time as "/dev/sdb", and so on.
191         
192         You don't necessarily need to be root when using
193         libguestfs. However you obviously do need sufficient
194         permissions to access the filename for whatever
195         operations you want to perform (ie. read access if you
196         just want to read the image or write access if you want
197         to modify the image).
198         
199         This is equivalent to the qemu parameter "-drive
200         file=filename,cache=off,if=virtio".
201         
202         Note that this call checks for the existence of
203         "filename". This stops you from specifying other types
204         of drive which are supported by qemu such as "nbd:" and
205         "http:" URLs. To specify those, use the general
206         "g.config" call instead.
207         """
208         return libguestfsmod.add_drive (self._o, filename)
209
210     def add_cdrom (self, filename):
211         u"""This function adds a virtual CD-ROM disk image to the
212         guest.
213         
214         This is equivalent to the qemu parameter "-cdrom
215         filename".
216         
217         Note that this call checks for the existence of
218         "filename". This stops you from specifying other types
219         of drive which are supported by qemu such as "nbd:" and
220         "http:" URLs. To specify those, use the general
221         "g.config" call instead.
222         """
223         return libguestfsmod.add_cdrom (self._o, filename)
224
225     def add_drive_ro (self, filename):
226         u"""This adds a drive in snapshot mode, making it
227         effectively read-only.
228         
229         Note that writes to the device are allowed, and will be
230         seen for the duration of the guestfs handle, but they
231         are written to a temporary file which is discarded as
232         soon as the guestfs handle is closed. We don't currently
233         have any method to enable changes to be committed,
234         although qemu can support this.
235         
236         This is equivalent to the qemu parameter "-drive
237         file=filename,snapshot=on,if=virtio".
238         
239         Note that this call checks for the existence of
240         "filename". This stops you from specifying other types
241         of drive which are supported by qemu such as "nbd:" and
242         "http:" URLs. To specify those, use the general
243         "g.config" call instead.
244         """
245         return libguestfsmod.add_drive_ro (self._o, filename)
246
247     def config (self, qemuparam, qemuvalue):
248         u"""This can be used to add arbitrary qemu command line
249         parameters of the form "-param value". Actually it's not
250         quite arbitrary - we prevent you from setting some
251         parameters which would interfere with parameters that we
252         use.
253         
254         The first character of "param" string must be a "-"
255         (dash).
256         
257         "value" can be NULL.
258         """
259         return libguestfsmod.config (self._o, qemuparam, qemuvalue)
260
261     def set_qemu (self, qemu):
262         u"""Set the qemu binary that we will use.
263         
264         The default is chosen when the library was compiled by
265         the configure script.
266         
267         You can also override this by setting the
268         "LIBGUESTFS_QEMU" environment variable.
269         
270         Setting "qemu" to "NULL" restores the default qemu
271         binary.
272         """
273         return libguestfsmod.set_qemu (self._o, qemu)
274
275     def get_qemu (self):
276         u"""Return the current qemu binary.
277         
278         This is always non-NULL. If it wasn't set already, then
279         this will return the default qemu binary name.
280         """
281         return libguestfsmod.get_qemu (self._o)
282
283     def set_path (self, path):
284         u"""Set the path that libguestfs searches for kernel and
285         initrd.img.
286         
287         The default is "$libdir/guestfs" unless overridden by
288         setting "LIBGUESTFS_PATH" environment variable.
289         
290         Setting "path" to "NULL" restores the default path.
291         """
292         return libguestfsmod.set_path (self._o, path)
293
294     def get_path (self):
295         u"""Return the current search path.
296         
297         This is always non-NULL. If it wasn't set already, then
298         this will return the default path.
299         """
300         return libguestfsmod.get_path (self._o)
301
302     def set_append (self, append):
303         u"""This function is used to add additional options to the
304         guest kernel command line.
305         
306         The default is "NULL" unless overridden by setting
307         "LIBGUESTFS_APPEND" environment variable.
308         
309         Setting "append" to "NULL" means *no* additional options
310         are passed (libguestfs always adds a few of its own).
311         """
312         return libguestfsmod.set_append (self._o, append)
313
314     def get_append (self):
315         u"""Return the additional kernel options which are added to
316         the guest kernel command line.
317         
318         If "NULL" then no options are added.
319         """
320         return libguestfsmod.get_append (self._o)
321
322     def set_autosync (self, autosync):
323         u"""If "autosync" is true, this enables autosync. Libguestfs
324         will make a best effort attempt to run "g.umount_all"
325         followed by "g.sync" when the handle is closed (also if
326         the program exits without closing handles).
327         
328         This is disabled by default (except in guestfish where
329         it is enabled by default).
330         """
331         return libguestfsmod.set_autosync (self._o, autosync)
332
333     def get_autosync (self):
334         u"""Get the autosync flag.
335         """
336         return libguestfsmod.get_autosync (self._o)
337
338     def set_verbose (self, verbose):
339         u"""If "verbose" is true, this turns on verbose messages (to
340         "stderr").
341         
342         Verbose messages are disabled unless the environment
343         variable "LIBGUESTFS_DEBUG" is defined and set to 1.
344         """
345         return libguestfsmod.set_verbose (self._o, verbose)
346
347     def get_verbose (self):
348         u"""This returns the verbose messages flag.
349         """
350         return libguestfsmod.get_verbose (self._o)
351
352     def is_ready (self):
353         u"""This returns true iff this handle is ready to accept
354         commands (in the "READY" state).
355         
356         For more information on states, see guestfs(3).
357         """
358         return libguestfsmod.is_ready (self._o)
359
360     def is_config (self):
361         u"""This returns true iff this handle is being configured
362         (in the "CONFIG" state).
363         
364         For more information on states, see guestfs(3).
365         """
366         return libguestfsmod.is_config (self._o)
367
368     def is_launching (self):
369         u"""This returns true iff this handle is launching the
370         subprocess (in the "LAUNCHING" state).
371         
372         For more information on states, see guestfs(3).
373         """
374         return libguestfsmod.is_launching (self._o)
375
376     def is_busy (self):
377         u"""This returns true iff this handle is busy processing a
378         command (in the "BUSY" state).
379         
380         For more information on states, see guestfs(3).
381         """
382         return libguestfsmod.is_busy (self._o)
383
384     def get_state (self):
385         u"""This returns the current state as an opaque integer.
386         This is only useful for printing debug and internal
387         error messages.
388         
389         For more information on states, see guestfs(3).
390         """
391         return libguestfsmod.get_state (self._o)
392
393     def set_busy (self):
394         u"""This sets the state to "BUSY". This is only used when
395         implementing actions using the low-level API.
396         
397         For more information on states, see guestfs(3).
398         """
399         return libguestfsmod.set_busy (self._o)
400
401     def set_ready (self):
402         u"""This sets the state to "READY". This is only used when
403         implementing actions using the low-level API.
404         
405         For more information on states, see guestfs(3).
406         """
407         return libguestfsmod.set_ready (self._o)
408
409     def end_busy (self):
410         u"""This sets the state to "READY", or if in "CONFIG" then
411         it leaves the state as is. This is only used when
412         implementing actions using the low-level API.
413         
414         For more information on states, see guestfs(3).
415         """
416         return libguestfsmod.end_busy (self._o)
417
418     def set_memsize (self, memsize):
419         u"""This sets the memory size in megabytes allocated to the
420         qemu subprocess. This only has any effect if called
421         before "g.launch".
422         
423         You can also change this by setting the environment
424         variable "LIBGUESTFS_MEMSIZE" before the handle is
425         created.
426         
427         For more information on the architecture of libguestfs,
428         see guestfs(3).
429         """
430         return libguestfsmod.set_memsize (self._o, memsize)
431
432     def get_memsize (self):
433         u"""This gets the memory size in megabytes allocated to the
434         qemu subprocess.
435         
436         If "g.set_memsize" was not called on this handle, and if
437         "LIBGUESTFS_MEMSIZE" was not set, then this returns the
438         compiled-in default value for memsize.
439         
440         For more information on the architecture of libguestfs,
441         see guestfs(3).
442         """
443         return libguestfsmod.get_memsize (self._o)
444
445     def mount (self, device, mountpoint):
446         u"""Mount a guest disk at a position in the filesystem.
447         Block devices are named "/dev/sda", "/dev/sdb" and so
448         on, as they were added to the guest. If those block
449         devices contain partitions, they will have the usual
450         names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
451         names can be used.
452         
453         The rules are the same as for mount(2): A filesystem
454         must first be mounted on "/" before others can be
455         mounted. Other filesystems can only be mounted on
456         directories which already exist.
457         
458         The mounted filesystem is writable, if we have
459         sufficient permissions on the underlying device.
460         
461         The filesystem options "sync" and "noatime" are set with
462         this call, in order to improve reliability.
463         """
464         return libguestfsmod.mount (self._o, device, mountpoint)
465
466     def sync (self):
467         u"""This syncs the disk, so that any writes are flushed
468         through to the underlying disk image.
469         
470         You should always call this if you have modified a disk
471         image, before closing the handle.
472         """
473         return libguestfsmod.sync (self._o)
474
475     def touch (self, path):
476         u"""Touch acts like the touch(1) command. It can be used to
477         update the timestamps on a file, or, if the file does
478         not exist, to create a new zero-length file.
479         """
480         return libguestfsmod.touch (self._o, path)
481
482     def cat (self, path):
483         u"""Return the contents of the file named "path".
484         
485         Note that this function cannot correctly handle binary
486         files (specifically, files containing "\\0" character
487         which is treated as end of string). For those you need
488         to use the "g.download" function which has a more
489         complex interface.
490         
491         Because of the message protocol, there is a transfer
492         limit of somewhere between 2MB and 4MB. To transfer
493         large files you should use FTP.
494         """
495         return libguestfsmod.cat (self._o, path)
496
497     def ll (self, directory):
498         u"""List the files in "directory" (relative to the root
499         directory, there is no cwd) in the format of 'ls -la'.
500         
501         This command is mostly useful for interactive sessions.
502         It is *not* intended that you try to parse the output
503         string.
504         """
505         return libguestfsmod.ll (self._o, directory)
506
507     def ls (self, directory):
508         u"""List the files in "directory" (relative to the root
509         directory, there is no cwd). The '.' and '..' entries
510         are not returned, but hidden files are shown.
511         
512         This command is mostly useful for interactive sessions.
513         Programs should probably use "g.readdir" instead.
514         
515         This function returns a list of strings.
516         """
517         return libguestfsmod.ls (self._o, directory)
518
519     def list_devices (self):
520         u"""List all the block devices.
521         
522         The full block device names are returned, eg. "/dev/sda"
523         
524         This function returns a list of strings.
525         """
526         return libguestfsmod.list_devices (self._o)
527
528     def list_partitions (self):
529         u"""List all the partitions detected on all block devices.
530         
531         The full partition device names are returned, eg.
532         "/dev/sda1"
533         
534         This does not return logical volumes. For that you will
535         need to call "g.lvs".
536         
537         This function returns a list of strings.
538         """
539         return libguestfsmod.list_partitions (self._o)
540
541     def pvs (self):
542         u"""List all the physical volumes detected. This is the
543         equivalent of the pvs(8) command.
544         
545         This returns a list of just the device names that
546         contain PVs (eg. "/dev/sda2").
547         
548         See also "g.pvs_full".
549         
550         This function returns a list of strings.
551         """
552         return libguestfsmod.pvs (self._o)
553
554     def vgs (self):
555         u"""List all the volumes groups detected. This is the
556         equivalent of the vgs(8) command.
557         
558         This returns a list of just the volume group names that
559         were detected (eg. "VolGroup00").
560         
561         See also "g.vgs_full".
562         
563         This function returns a list of strings.
564         """
565         return libguestfsmod.vgs (self._o)
566
567     def lvs (self):
568         u"""List all the logical volumes detected. This is the
569         equivalent of the lvs(8) command.
570         
571         This returns a list of the logical volume device names
572         (eg. "/dev/VolGroup00/LogVol00").
573         
574         See also "g.lvs_full".
575         
576         This function returns a list of strings.
577         """
578         return libguestfsmod.lvs (self._o)
579
580     def pvs_full (self):
581         u"""List all the physical volumes detected. This is the
582         equivalent of the pvs(8) command. The "full" version
583         includes all fields.
584         
585         This function returns a list of PVs. Each PV is
586         represented as a dictionary.
587         """
588         return libguestfsmod.pvs_full (self._o)
589
590     def vgs_full (self):
591         u"""List all the volumes groups detected. This is the
592         equivalent of the vgs(8) command. The "full" version
593         includes all fields.
594         
595         This function returns a list of VGs. Each VG is
596         represented as a dictionary.
597         """
598         return libguestfsmod.vgs_full (self._o)
599
600     def lvs_full (self):
601         u"""List all the logical volumes detected. This is the
602         equivalent of the lvs(8) command. The "full" version
603         includes all fields.
604         
605         This function returns a list of LVs. Each LV is
606         represented as a dictionary.
607         """
608         return libguestfsmod.lvs_full (self._o)
609
610     def read_lines (self, path):
611         u"""Return the contents of the file named "path".
612         
613         The file contents are returned as a list of lines.
614         Trailing "LF" and "CRLF" character sequences are *not*
615         returned.
616         
617         Note that this function cannot correctly handle binary
618         files (specifically, files containing "\\0" character
619         which is treated as end of line). For those you need to
620         use the "g.read_file" function which has a more complex
621         interface.
622         
623         This function returns a list of strings.
624         """
625         return libguestfsmod.read_lines (self._o, path)
626
627     def aug_init (self, root, flags):
628         u"""Create a new Augeas handle for editing configuration
629         files. If there was any previous Augeas handle
630         associated with this guestfs session, then it is closed.
631         
632         You must call this before using any other "g.aug_*"
633         commands.
634         
635         "root" is the filesystem root. "root" must not be NULL,
636         use "/" instead.
637         
638         The flags are the same as the flags defined in
639         <augeas.h>, the logical *or* of the following integers:
640         
641         "AUG_SAVE_BACKUP" = 1
642         Keep the original file with a ".augsave" extension.
643         
644         "AUG_SAVE_NEWFILE" = 2
645         Save changes into a file with extension ".augnew",
646         and do not overwrite original. Overrides
647         "AUG_SAVE_BACKUP".
648         
649         "AUG_TYPE_CHECK" = 4
650         Typecheck lenses (can be expensive).
651         
652         "AUG_NO_STDINC" = 8
653         Do not use standard load path for modules.
654         
655         "AUG_SAVE_NOOP" = 16
656         Make save a no-op, just record what would have been
657         changed.
658         
659         "AUG_NO_LOAD" = 32
660         Do not load the tree in "g.aug_init".
661         
662         To close the handle, you can call "g.aug_close".
663         
664         To find out more about Augeas, see <http://augeas.net/>.
665         """
666         return libguestfsmod.aug_init (self._o, root, flags)
667
668     def aug_close (self):
669         u"""Close the current Augeas handle and free up any
670         resources used by it. After calling this, you have to
671         call "g.aug_init" again before you can use any other
672         Augeas functions.
673         """
674         return libguestfsmod.aug_close (self._o)
675
676     def aug_defvar (self, name, expr):
677         u"""Defines an Augeas variable "name" whose value is the
678         result of evaluating "expr". If "expr" is NULL, then
679         "name" is undefined.
680         
681         On success this returns the number of nodes in "expr",
682         or 0 if "expr" evaluates to something which is not a
683         nodeset.
684         """
685         return libguestfsmod.aug_defvar (self._o, name, expr)
686
687     def aug_defnode (self, name, expr, val):
688         u"""Defines a variable "name" whose value is the result of
689         evaluating "expr".
690         
691         If "expr" evaluates to an empty nodeset, a node is
692         created, equivalent to calling "g.aug_set" "expr",
693         "value". "name" will be the nodeset containing that
694         single node.
695         
696         On success this returns a pair containing the number of
697         nodes in the nodeset, and a boolean flag if a node was
698         created.
699         
700         This function returns a tuple (int, bool).
701         """
702         return libguestfsmod.aug_defnode (self._o, name, expr, val)
703
704     def aug_get (self, path):
705         u"""Look up the value associated with "path". If "path"
706         matches exactly one node, the "value" is returned.
707         """
708         return libguestfsmod.aug_get (self._o, path)
709
710     def aug_set (self, path, val):
711         u"""Set the value associated with "path" to "value".
712         """
713         return libguestfsmod.aug_set (self._o, path, val)
714
715     def aug_insert (self, path, label, before):
716         u"""Create a new sibling "label" for "path", inserting it
717         into the tree before or after "path" (depending on the
718         boolean flag "before").
719         
720         "path" must match exactly one existing node in the tree,
721         and "label" must be a label, ie. not contain "/", "*" or
722         end with a bracketed index "[N]".
723         """
724         return libguestfsmod.aug_insert (self._o, path, label, before)
725
726     def aug_rm (self, path):
727         u"""Remove "path" and all of its children.
728         
729         On success this returns the number of entries which were
730         removed.
731         """
732         return libguestfsmod.aug_rm (self._o, path)
733
734     def aug_mv (self, src, dest):
735         u"""Move the node "src" to "dest". "src" must match exactly
736         one node. "dest" is overwritten if it exists.
737         """
738         return libguestfsmod.aug_mv (self._o, src, dest)
739
740     def aug_match (self, path):
741         u"""Returns a list of paths which match the path expression
742         "path". The returned paths are sufficiently qualified so
743         that they match exactly one node in the current tree.
744         
745         This function returns a list of strings.
746         """
747         return libguestfsmod.aug_match (self._o, path)
748
749     def aug_save (self):
750         u"""This writes all pending changes to disk.
751         
752         The flags which were passed to "g.aug_init" affect
753         exactly how files are saved.
754         """
755         return libguestfsmod.aug_save (self._o)
756
757     def aug_load (self):
758         u"""Load files into the tree.
759         
760         See "aug_load" in the Augeas documentation for the full
761         gory details.
762         """
763         return libguestfsmod.aug_load (self._o)
764
765     def aug_ls (self, path):
766         u"""This is just a shortcut for listing "g.aug_match"
767         "path/*" and sorting the resulting nodes into
768         alphabetical order.
769         
770         This function returns a list of strings.
771         """
772         return libguestfsmod.aug_ls (self._o, path)
773
774     def rm (self, path):
775         u"""Remove the single file "path".
776         """
777         return libguestfsmod.rm (self._o, path)
778
779     def rmdir (self, path):
780         u"""Remove the single directory "path".
781         """
782         return libguestfsmod.rmdir (self._o, path)
783
784     def rm_rf (self, path):
785         u"""Remove the file or directory "path", recursively
786         removing the contents if its a directory. This is like
787         the "rm -rf" shell command.
788         """
789         return libguestfsmod.rm_rf (self._o, path)
790
791     def mkdir (self, path):
792         u"""Create a directory named "path".
793         """
794         return libguestfsmod.mkdir (self._o, path)
795
796     def mkdir_p (self, path):
797         u"""Create a directory named "path", creating any parent
798         directories as necessary. This is like the "mkdir -p"
799         shell command.
800         """
801         return libguestfsmod.mkdir_p (self._o, path)
802
803     def chmod (self, mode, path):
804         u"""Change the mode (permissions) of "path" to "mode". Only
805         numeric modes are supported.
806         """
807         return libguestfsmod.chmod (self._o, mode, path)
808
809     def chown (self, owner, group, path):
810         u"""Change the file owner to "owner" and group to "group".
811         
812         Only numeric uid and gid are supported. If you want to
813         use names, you will need to locate and parse the
814         password file yourself (Augeas support makes this
815         relatively easy).
816         """
817         return libguestfsmod.chown (self._o, owner, group, path)
818
819     def exists (self, path):
820         u"""This returns "true" if and only if there is a file,
821         directory (or anything) with the given "path" name.
822         
823         See also "g.is_file", "g.is_dir", "g.stat".
824         """
825         return libguestfsmod.exists (self._o, path)
826
827     def is_file (self, path):
828         u"""This returns "true" if and only if there is a file with
829         the given "path" name. Note that it returns false for
830         other objects like directories.
831         
832         See also "g.stat".
833         """
834         return libguestfsmod.is_file (self._o, path)
835
836     def is_dir (self, path):
837         u"""This returns "true" if and only if there is a directory
838         with the given "path" name. Note that it returns false
839         for other objects like files.
840         
841         See also "g.stat".
842         """
843         return libguestfsmod.is_dir (self._o, path)
844
845     def pvcreate (self, device):
846         u"""This creates an LVM physical volume on the named
847         "device", where "device" should usually be a partition
848         name such as "/dev/sda1".
849         """
850         return libguestfsmod.pvcreate (self._o, device)
851
852     def vgcreate (self, volgroup, physvols):
853         u"""This creates an LVM volume group called "volgroup" from
854         the non-empty list of physical volumes "physvols".
855         """
856         return libguestfsmod.vgcreate (self._o, volgroup, physvols)
857
858     def lvcreate (self, logvol, volgroup, mbytes):
859         u"""This creates an LVM volume group called "logvol" on the
860         volume group "volgroup", with "size" megabytes.
861         """
862         return libguestfsmod.lvcreate (self._o, logvol, volgroup, mbytes)
863
864     def mkfs (self, fstype, device):
865         u"""This creates a filesystem on "device" (usually a
866         partition or LVM logical volume). The filesystem type is
867         "fstype", for example "ext3".
868         """
869         return libguestfsmod.mkfs (self._o, fstype, device)
870
871     def sfdisk (self, device, cyls, heads, sectors, lines):
872         u"""This is a direct interface to the sfdisk(8) program for
873         creating partitions on block devices.
874         
875         "device" should be a block device, for example
876         "/dev/sda".
877         
878         "cyls", "heads" and "sectors" are the number of
879         cylinders, heads and sectors on the device, which are
880         passed directly to sfdisk as the *-C*, *-H* and *-S*
881         parameters. If you pass 0 for any of these, then the
882         corresponding parameter is omitted. Usually for 'large'
883         disks, you can just pass 0 for these, but for small
884         (floppy-sized) disks, sfdisk (or rather, the kernel)
885         cannot work out the right geometry and you will need to
886         tell it.
887         
888         "lines" is a list of lines that we feed to "sfdisk". For
889         more information refer to the sfdisk(8) manpage.
890         
891         To create a single partition occupying the whole disk,
892         you would pass "lines" as a single element list, when
893         the single element being the string "," (comma).
894         
895         See also: "g.sfdisk_l", "g.sfdisk_N"
896         
897         This command is dangerous. Without careful use you can
898         easily destroy all your data.
899         """
900         return libguestfsmod.sfdisk (self._o, device, cyls, heads, sectors, lines)
901
902     def write_file (self, path, content, size):
903         u"""This call creates a file called "path". The contents of
904         the file is the string "content" (which can contain any
905         8 bit data), with length "size".
906         
907         As a special case, if "size" is 0 then the length is
908         calculated using "strlen" (so in this case the content
909         cannot contain embedded ASCII NULs).
910         
911         *NB.* Owing to a bug, writing content containing ASCII
912         NUL characters does *not* work, even if the length is
913         specified. We hope to resolve this bug in a future
914         version. In the meantime use "g.upload".
915         
916         Because of the message protocol, there is a transfer
917         limit of somewhere between 2MB and 4MB. To transfer
918         large files you should use FTP.
919         """
920         return libguestfsmod.write_file (self._o, path, content, size)
921
922     def umount (self, pathordevice):
923         u"""This unmounts the given filesystem. The filesystem may
924         be specified either by its mountpoint (path) or the
925         device which contains the filesystem.
926         """
927         return libguestfsmod.umount (self._o, pathordevice)
928
929     def mounts (self):
930         u"""This returns the list of currently mounted filesystems.
931         It returns the list of devices (eg. "/dev/sda1",
932         "/dev/VG/LV").
933         
934         Some internal mounts are not shown.
935         
936         This function returns a list of strings.
937         """
938         return libguestfsmod.mounts (self._o)
939
940     def umount_all (self):
941         u"""This unmounts all mounted filesystems.
942         
943         Some internal mounts are not unmounted by this call.
944         """
945         return libguestfsmod.umount_all (self._o)
946
947     def lvm_remove_all (self):
948         u"""This command removes all LVM logical volumes, volume
949         groups and physical volumes.
950         
951         This command is dangerous. Without careful use you can
952         easily destroy all your data.
953         """
954         return libguestfsmod.lvm_remove_all (self._o)
955
956     def file (self, path):
957         u"""This call uses the standard file(1) command to determine
958         the type or contents of the file. This also works on
959         devices, for example to find out whether a partition
960         contains a filesystem.
961         
962         The exact command which runs is "file -bsL path". Note
963         in particular that the filename is not prepended to the
964         output (the "-b" option).
965         """
966         return libguestfsmod.file (self._o, path)
967
968     def command (self, arguments):
969         u"""This call runs a command from the guest filesystem. The
970         filesystem must be mounted, and must contain a
971         compatible operating system (ie. something Linux, with
972         the same or compatible processor architecture).
973         
974         The single parameter is an argv-style list of arguments.
975         The first element is the name of the program to run.
976         Subsequent elements are parameters. The list must be
977         non-empty (ie. must contain a program name). Note that
978         the command runs directly, and is *not* invoked via the
979         shell (see "g.sh").
980         
981         The return value is anything printed to *stdout* by the
982         command.
983         
984         If the command returns a non-zero exit status, then this
985         function returns an error message. The error message
986         string is the content of *stderr* from the command.
987         
988         The $PATH environment variable will contain at least
989         "/usr/bin" and "/bin". If you require a program from
990         another location, you should provide the full path in
991         the first parameter.
992         
993         Shared libraries and data files required by the program
994         must be available on filesystems which are mounted in
995         the correct places. It is the caller's responsibility to
996         ensure all filesystems that are needed are mounted at
997         the right locations.
998         
999         Because of the message protocol, there is a transfer
1000         limit of somewhere between 2MB and 4MB. To transfer
1001         large files you should use FTP.
1002         """
1003         return libguestfsmod.command (self._o, arguments)
1004
1005     def command_lines (self, arguments):
1006         u"""This is the same as "g.command", but splits the result
1007         into a list of lines.
1008         
1009         See also: "g.sh_lines"
1010         
1011         This function returns a list of strings.
1012         
1013         Because of the message protocol, there is a transfer
1014         limit of somewhere between 2MB and 4MB. To transfer
1015         large files you should use FTP.
1016         """
1017         return libguestfsmod.command_lines (self._o, arguments)
1018
1019     def stat (self, path):
1020         u"""Returns file information for the given "path".
1021         
1022         This is the same as the stat(2) system call.
1023         
1024         This function returns a dictionary, with keys matching
1025         the various fields in the stat structure.
1026         """
1027         return libguestfsmod.stat (self._o, path)
1028
1029     def lstat (self, path):
1030         u"""Returns file information for the given "path".
1031         
1032         This is the same as "g.stat" except that if "path" is a
1033         symbolic link, then the link is stat-ed, not the file it
1034         refers to.
1035         
1036         This is the same as the lstat(2) system call.
1037         
1038         This function returns a dictionary, with keys matching
1039         the various fields in the stat structure.
1040         """
1041         return libguestfsmod.lstat (self._o, path)
1042
1043     def statvfs (self, path):
1044         u"""Returns file system statistics for any mounted file
1045         system. "path" should be a file or directory in the
1046         mounted file system (typically it is the mount point
1047         itself, but it doesn't need to be).
1048         
1049         This is the same as the statvfs(2) system call.
1050         
1051         This function returns a dictionary, with keys matching
1052         the various fields in the statvfs structure.
1053         """
1054         return libguestfsmod.statvfs (self._o, path)
1055
1056     def tune2fs_l (self, device):
1057         u"""This returns the contents of the ext2, ext3 or ext4
1058         filesystem superblock on "device".
1059         
1060         It is the same as running "tune2fs -l device". See
1061         tune2fs(8) manpage for more details. The list of fields
1062         returned isn't clearly defined, and depends on both the
1063         version of "tune2fs" that libguestfs was built against,
1064         and the filesystem itself.
1065         
1066         This function returns a dictionary.
1067         """
1068         return libguestfsmod.tune2fs_l (self._o, device)
1069
1070     def blockdev_setro (self, device):
1071         u"""Sets the block device named "device" to read-only.
1072         
1073         This uses the blockdev(8) command.
1074         """
1075         return libguestfsmod.blockdev_setro (self._o, device)
1076
1077     def blockdev_setrw (self, device):
1078         u"""Sets the block device named "device" to read-write.
1079         
1080         This uses the blockdev(8) command.
1081         """
1082         return libguestfsmod.blockdev_setrw (self._o, device)
1083
1084     def blockdev_getro (self, device):
1085         u"""Returns a boolean indicating if the block device is
1086         read-only (true if read-only, false if not).
1087         
1088         This uses the blockdev(8) command.
1089         """
1090         return libguestfsmod.blockdev_getro (self._o, device)
1091
1092     def blockdev_getss (self, device):
1093         u"""This returns the size of sectors on a block device.
1094         Usually 512, but can be larger for modern devices.
1095         
1096         (Note, this is not the size in sectors, use
1097         "g.blockdev_getsz" for that).
1098         
1099         This uses the blockdev(8) command.
1100         """
1101         return libguestfsmod.blockdev_getss (self._o, device)
1102
1103     def blockdev_getbsz (self, device):
1104         u"""This returns the block size of a device.
1105         
1106         (Note this is different from both *size in blocks* and
1107         *filesystem block size*).
1108         
1109         This uses the blockdev(8) command.
1110         """
1111         return libguestfsmod.blockdev_getbsz (self._o, device)
1112
1113     def blockdev_setbsz (self, device, blocksize):
1114         u"""This sets the block size of a device.
1115         
1116         (Note this is different from both *size in blocks* and
1117         *filesystem block size*).
1118         
1119         This uses the blockdev(8) command.
1120         """
1121         return libguestfsmod.blockdev_setbsz (self._o, device, blocksize)
1122
1123     def blockdev_getsz (self, device):
1124         u"""This returns the size of the device in units of 512-byte
1125         sectors (even if the sectorsize isn't 512 bytes ...
1126         weird).
1127         
1128         See also "g.blockdev_getss" for the real sector size of
1129         the device, and "g.blockdev_getsize64" for the more
1130         useful *size in bytes*.
1131         
1132         This uses the blockdev(8) command.
1133         """
1134         return libguestfsmod.blockdev_getsz (self._o, device)
1135
1136     def blockdev_getsize64 (self, device):
1137         u"""This returns the size of the device in bytes.
1138         
1139         See also "g.blockdev_getsz".
1140         
1141         This uses the blockdev(8) command.
1142         """
1143         return libguestfsmod.blockdev_getsize64 (self._o, device)
1144
1145     def blockdev_flushbufs (self, device):
1146         u"""This tells the kernel to flush internal buffers
1147         associated with "device".
1148         
1149         This uses the blockdev(8) command.
1150         """
1151         return libguestfsmod.blockdev_flushbufs (self._o, device)
1152
1153     def blockdev_rereadpt (self, device):
1154         u"""Reread the partition table on "device".
1155         
1156         This uses the blockdev(8) command.
1157         """
1158         return libguestfsmod.blockdev_rereadpt (self._o, device)
1159
1160     def upload (self, filename, remotefilename):
1161         u"""Upload local file "filename" to "remotefilename" on the
1162         filesystem.
1163         
1164         "filename" can also be a named pipe.
1165         
1166         See also "g.download".
1167         """
1168         return libguestfsmod.upload (self._o, filename, remotefilename)
1169
1170     def download (self, remotefilename, filename):
1171         u"""Download file "remotefilename" and save it as "filename"
1172         on the local machine.
1173         
1174         "filename" can also be a named pipe.
1175         
1176         See also "g.upload", "g.cat".
1177         """
1178         return libguestfsmod.download (self._o, remotefilename, filename)
1179
1180     def checksum (self, csumtype, path):
1181         u"""This call computes the MD5, SHAx or CRC checksum of the
1182         file named "path".
1183         
1184         The type of checksum to compute is given by the
1185         "csumtype" parameter which must have one of the
1186         following values:
1187         
1188         "crc"
1189         Compute the cyclic redundancy check (CRC) specified
1190         by POSIX for the "cksum" command.
1191         
1192         "md5"
1193         Compute the MD5 hash (using the "md5sum" program).
1194         
1195         "sha1"
1196         Compute the SHA1 hash (using the "sha1sum" program).
1197         
1198         "sha224"
1199         Compute the SHA224 hash (using the "sha224sum"
1200         program).
1201         
1202         "sha256"
1203         Compute the SHA256 hash (using the "sha256sum"
1204         program).
1205         
1206         "sha384"
1207         Compute the SHA384 hash (using the "sha384sum"
1208         program).
1209         
1210         "sha512"
1211         Compute the SHA512 hash (using the "sha512sum"
1212         program).
1213         
1214         The checksum is returned as a printable string.
1215         """
1216         return libguestfsmod.checksum (self._o, csumtype, path)
1217
1218     def tar_in (self, tarfile, directory):
1219         u"""This command uploads and unpacks local file "tarfile"
1220         (an *uncompressed* tar file) into "directory".
1221         
1222         To upload a compressed tarball, use "g.tgz_in".
1223         """
1224         return libguestfsmod.tar_in (self._o, tarfile, directory)
1225
1226     def tar_out (self, directory, tarfile):
1227         u"""This command packs the contents of "directory" and
1228         downloads it to local file "tarfile".
1229         
1230         To download a compressed tarball, use "g.tgz_out".
1231         """
1232         return libguestfsmod.tar_out (self._o, directory, tarfile)
1233
1234     def tgz_in (self, tarball, directory):
1235         u"""This command uploads and unpacks local file "tarball" (a
1236         *gzip compressed* tar file) into "directory".
1237         
1238         To upload an uncompressed tarball, use "g.tar_in".
1239         """
1240         return libguestfsmod.tgz_in (self._o, tarball, directory)
1241
1242     def tgz_out (self, directory, tarball):
1243         u"""This command packs the contents of "directory" and
1244         downloads it to local file "tarball".
1245         
1246         To download an uncompressed tarball, use "g.tar_out".
1247         """
1248         return libguestfsmod.tgz_out (self._o, directory, tarball)
1249
1250     def mount_ro (self, device, mountpoint):
1251         u"""This is the same as the "g.mount" command, but it mounts
1252         the filesystem with the read-only (*-o ro*) flag.
1253         """
1254         return libguestfsmod.mount_ro (self._o, device, mountpoint)
1255
1256     def mount_options (self, options, device, mountpoint):
1257         u"""This is the same as the "g.mount" command, but it allows
1258         you to set the mount options as for the mount(8) *-o*
1259         flag.
1260         """
1261         return libguestfsmod.mount_options (self._o, options, device, mountpoint)
1262
1263     def mount_vfs (self, options, vfstype, device, mountpoint):
1264         u"""This is the same as the "g.mount" command, but it allows
1265         you to set both the mount options and the vfstype as for
1266         the mount(8) *-o* and *-t* flags.
1267         """
1268         return libguestfsmod.mount_vfs (self._o, options, vfstype, device, mountpoint)
1269
1270     def debug (self, subcmd, extraargs):
1271         u"""The "g.debug" command exposes some internals of
1272         "guestfsd" (the guestfs daemon) that runs inside the
1273         qemu subprocess.
1274         
1275         There is no comprehensive help for this command. You
1276         have to look at the file "daemon/debug.c" in the
1277         libguestfs source to find out what you can do.
1278         """
1279         return libguestfsmod.debug (self._o, subcmd, extraargs)
1280
1281     def lvremove (self, device):
1282         u"""Remove an LVM logical volume "device", where "device" is
1283         the path to the LV, such as "/dev/VG/LV".
1284         
1285         You can also remove all LVs in a volume group by
1286         specifying the VG name, "/dev/VG".
1287         """
1288         return libguestfsmod.lvremove (self._o, device)
1289
1290     def vgremove (self, vgname):
1291         u"""Remove an LVM volume group "vgname", (for example "VG").
1292         
1293         This also forcibly removes all logical volumes in the
1294         volume group (if any).
1295         """
1296         return libguestfsmod.vgremove (self._o, vgname)
1297
1298     def pvremove (self, device):
1299         u"""This wipes a physical volume "device" so that LVM will
1300         no longer recognise it.
1301         
1302         The implementation uses the "pvremove" command which
1303         refuses to wipe physical volumes that contain any volume
1304         groups, so you have to remove those first.
1305         """
1306         return libguestfsmod.pvremove (self._o, device)
1307
1308     def set_e2label (self, device, label):
1309         u"""This sets the ext2/3/4 filesystem label of the
1310         filesystem on "device" to "label". Filesystem labels are
1311         limited to 16 characters.
1312         
1313         You can use either "g.tune2fs_l" or "g.get_e2label" to
1314         return the existing label on a filesystem.
1315         """
1316         return libguestfsmod.set_e2label (self._o, device, label)
1317
1318     def get_e2label (self, device):
1319         u"""This returns the ext2/3/4 filesystem label of the
1320         filesystem on "device".
1321         """
1322         return libguestfsmod.get_e2label (self._o, device)
1323
1324     def set_e2uuid (self, device, uuid):
1325         u"""This sets the ext2/3/4 filesystem UUID of the filesystem
1326         on "device" to "uuid". The format of the UUID and
1327         alternatives such as "clear", "random" and "time" are
1328         described in the tune2fs(8) manpage.
1329         
1330         You can use either "g.tune2fs_l" or "g.get_e2uuid" to
1331         return the existing UUID of a filesystem.
1332         """
1333         return libguestfsmod.set_e2uuid (self._o, device, uuid)
1334
1335     def get_e2uuid (self, device):
1336         u"""This returns the ext2/3/4 filesystem UUID of the
1337         filesystem on "device".
1338         """
1339         return libguestfsmod.get_e2uuid (self._o, device)
1340
1341     def fsck (self, fstype, device):
1342         u"""This runs the filesystem checker (fsck) on "device"
1343         which should have filesystem type "fstype".
1344         
1345         The returned integer is the status. See fsck(8) for the
1346         list of status codes from "fsck".
1347         
1348         Notes:
1349         
1350         *   Multiple status codes can be summed together.
1351         
1352         *   A non-zero return code can mean "success", for
1353         example if errors have been corrected on the
1354         filesystem.
1355         
1356         *   Checking or repairing NTFS volumes is not supported
1357         (by linux-ntfs).
1358         
1359         This command is entirely equivalent to running "fsck -a
1360         -t fstype device".
1361         """
1362         return libguestfsmod.fsck (self._o, fstype, device)
1363
1364     def zero (self, device):
1365         u"""This command writes zeroes over the first few blocks of
1366         "device".
1367         
1368         How many blocks are zeroed isn't specified (but it's
1369         *not* enough to securely wipe the device). It should be
1370         sufficient to remove any partition tables, filesystem
1371         superblocks and so on.
1372         
1373         See also: "g.scrub_device".
1374         """
1375         return libguestfsmod.zero (self._o, device)
1376
1377     def grub_install (self, root, device):
1378         u"""This command installs GRUB (the Grand Unified
1379         Bootloader) on "device", with the root directory being
1380         "root".
1381         """
1382         return libguestfsmod.grub_install (self._o, root, device)
1383
1384     def cp (self, src, dest):
1385         u"""This copies a file from "src" to "dest" where "dest" is
1386         either a destination filename or destination directory.
1387         """
1388         return libguestfsmod.cp (self._o, src, dest)
1389
1390     def cp_a (self, src, dest):
1391         u"""This copies a file or directory from "src" to "dest"
1392         recursively using the "cp -a" command.
1393         """
1394         return libguestfsmod.cp_a (self._o, src, dest)
1395
1396     def mv (self, src, dest):
1397         u"""This moves a file from "src" to "dest" where "dest" is
1398         either a destination filename or destination directory.
1399         """
1400         return libguestfsmod.mv (self._o, src, dest)
1401
1402     def drop_caches (self, whattodrop):
1403         u"""This instructs the guest kernel to drop its page cache,
1404         and/or dentries and inode caches. The parameter
1405         "whattodrop" tells the kernel what precisely to drop,
1406         see <http://linux-mm.org/Drop_Caches>
1407         
1408         Setting "whattodrop" to 3 should drop everything.
1409         
1410         This automatically calls sync(2) before the operation,
1411         so that the maximum guest memory is freed.
1412         """
1413         return libguestfsmod.drop_caches (self._o, whattodrop)
1414
1415     def dmesg (self):
1416         u"""This returns the kernel messages ("dmesg" output) from
1417         the guest kernel. This is sometimes useful for extended
1418         debugging of problems.
1419         
1420         Another way to get the same information is to enable
1421         verbose messages with "g.set_verbose" or by setting the
1422         environment variable "LIBGUESTFS_DEBUG=1" before running
1423         the program.
1424         """
1425         return libguestfsmod.dmesg (self._o)
1426
1427     def ping_daemon (self):
1428         u"""This is a test probe into the guestfs daemon running
1429         inside the qemu subprocess. Calling this function checks
1430         that the daemon responds to the ping message, without
1431         affecting the daemon or attached block device(s) in any
1432         other way.
1433         """
1434         return libguestfsmod.ping_daemon (self._o)
1435
1436     def equal (self, file1, file2):
1437         u"""This compares the two files "file1" and "file2" and
1438         returns true if their content is exactly equal, or false
1439         otherwise.
1440         
1441         The external cmp(1) program is used for the comparison.
1442         """
1443         return libguestfsmod.equal (self._o, file1, file2)
1444
1445     def strings (self, path):
1446         u"""This runs the strings(1) command on a file and returns
1447         the list of printable strings found.
1448         
1449         This function returns a list of strings.
1450         
1451         Because of the message protocol, there is a transfer
1452         limit of somewhere between 2MB and 4MB. To transfer
1453         large files you should use FTP.
1454         """
1455         return libguestfsmod.strings (self._o, path)
1456
1457     def strings_e (self, encoding, path):
1458         u"""This is like the "g.strings" command, but allows you to
1459         specify the encoding.
1460         
1461         See the strings(1) manpage for the full list of
1462         encodings.
1463         
1464         Commonly useful encodings are "l" (lower case L) which
1465         will show strings inside Windows/x86 files.
1466         
1467         The returned strings are transcoded to UTF-8.
1468         
1469         This function returns a list of strings.
1470         
1471         Because of the message protocol, there is a transfer
1472         limit of somewhere between 2MB and 4MB. To transfer
1473         large files you should use FTP.
1474         """
1475         return libguestfsmod.strings_e (self._o, encoding, path)
1476
1477     def hexdump (self, path):
1478         u"""This runs "hexdump -C" on the given "path". The result
1479         is the human-readable, canonical hex dump of the file.
1480         
1481         Because of the message protocol, there is a transfer
1482         limit of somewhere between 2MB and 4MB. To transfer
1483         large files you should use FTP.
1484         """
1485         return libguestfsmod.hexdump (self._o, path)
1486
1487     def zerofree (self, device):
1488         u"""This runs the *zerofree* program on "device". This
1489         program claims to zero unused inodes and disk blocks on
1490         an ext2/3 filesystem, thus making it possible to
1491         compress the filesystem more effectively.
1492         
1493         You should not run this program if the filesystem is
1494         mounted.
1495         
1496         It is possible that using this program can damage the
1497         filesystem or data on the filesystem.
1498         """
1499         return libguestfsmod.zerofree (self._o, device)
1500
1501     def pvresize (self, device):
1502         u"""This resizes (expands or shrinks) an existing LVM
1503         physical volume to match the new size of the underlying
1504         device.
1505         """
1506         return libguestfsmod.pvresize (self._o, device)
1507
1508     def sfdisk_N (self, device, partnum, cyls, heads, sectors, line):
1509         u"""This runs sfdisk(8) option to modify just the single
1510         partition "n" (note: "n" counts from 1).
1511         
1512         For other parameters, see "g.sfdisk". You should usually
1513         pass 0 for the cyls/heads/sectors parameters.
1514         
1515         This command is dangerous. Without careful use you can
1516         easily destroy all your data.
1517         """
1518         return libguestfsmod.sfdisk_N (self._o, device, partnum, cyls, heads, sectors, line)
1519
1520     def sfdisk_l (self, device):
1521         u"""This displays the partition table on "device", in the
1522         human-readable output of the sfdisk(8) command. It is
1523         not intended to be parsed.
1524         """
1525         return libguestfsmod.sfdisk_l (self._o, device)
1526
1527     def sfdisk_kernel_geometry (self, device):
1528         u"""This displays the kernel's idea of the geometry of
1529         "device".
1530         
1531         The result is in human-readable format, and not designed
1532         to be parsed.
1533         """
1534         return libguestfsmod.sfdisk_kernel_geometry (self._o, device)
1535
1536     def sfdisk_disk_geometry (self, device):
1537         u"""This displays the disk geometry of "device" read from
1538         the partition table. Especially in the case where the
1539         underlying block device has been resized, this can be
1540         different from the kernel's idea of the geometry (see
1541         "g.sfdisk_kernel_geometry").
1542         
1543         The result is in human-readable format, and not designed
1544         to be parsed.
1545         """
1546         return libguestfsmod.sfdisk_disk_geometry (self._o, device)
1547
1548     def vg_activate_all (self, activate):
1549         u"""This command activates or (if "activate" is false)
1550         deactivates all logical volumes in all volume groups. If
1551         activated, then they are made known to the kernel, ie.
1552         they appear as "/dev/mapper" devices. If deactivated,
1553         then those devices disappear.
1554         
1555         This command is the same as running "vgchange -a y|n"
1556         """
1557         return libguestfsmod.vg_activate_all (self._o, activate)
1558
1559     def vg_activate (self, activate, volgroups):
1560         u"""This command activates or (if "activate" is false)
1561         deactivates all logical volumes in the listed volume
1562         groups "volgroups". If activated, then they are made
1563         known to the kernel, ie. they appear as "/dev/mapper"
1564         devices. If deactivated, then those devices disappear.
1565         
1566         This command is the same as running "vgchange -a y|n
1567         volgroups..."
1568         
1569         Note that if "volgroups" is an empty list then all
1570         volume groups are activated or deactivated.
1571         """
1572         return libguestfsmod.vg_activate (self._o, activate, volgroups)
1573
1574     def lvresize (self, device, mbytes):
1575         u"""This resizes (expands or shrinks) an existing LVM
1576         logical volume to "mbytes". When reducing, data in the
1577         reduced part is lost.
1578         """
1579         return libguestfsmod.lvresize (self._o, device, mbytes)
1580
1581     def resize2fs (self, device):
1582         u"""This resizes an ext2 or ext3 filesystem to match the
1583         size of the underlying device.
1584         
1585         *Note:* It is sometimes required that you run
1586         "g.e2fsck_f" on the "device" before calling this
1587         command. For unknown reasons "resize2fs" sometimes gives
1588         an error about this and sometimes not. In any case, it
1589         is always safe to call "g.e2fsck_f" before calling this
1590         function.
1591         """
1592         return libguestfsmod.resize2fs (self._o, device)
1593
1594     def find (self, directory):
1595         u"""This command lists out all files and directories,
1596         recursively, starting at "directory". It is essentially
1597         equivalent to running the shell command "find directory
1598         -print" but some post-processing happens on the output,
1599         described below.
1600         
1601         This returns a list of strings *without any prefix*.
1602         Thus if the directory structure was:
1603         
1604         /tmp/a
1605         /tmp/b
1606         /tmp/c/d
1607         
1608         then the returned list from "g.find" "/tmp" would be 4
1609         elements:
1610         
1611         a
1612         b
1613         c
1614         c/d
1615         
1616         If "directory" is not a directory, then this command
1617         returns an error.
1618         
1619         The returned list is sorted.
1620         
1621         This function returns a list of strings.
1622         """
1623         return libguestfsmod.find (self._o, directory)
1624
1625     def e2fsck_f (self, device):
1626         u"""This runs "e2fsck -p -f device", ie. runs the ext2/ext3
1627         filesystem checker on "device", noninteractively ("-p"),
1628         even if the filesystem appears to be clean ("-f").
1629         
1630         This command is only needed because of "g.resize2fs"
1631         (q.v.). Normally you should use "g.fsck".
1632         """
1633         return libguestfsmod.e2fsck_f (self._o, device)
1634
1635     def sleep (self, secs):
1636         u"""Sleep for "secs" seconds.
1637         """
1638         return libguestfsmod.sleep (self._o, secs)
1639
1640     def ntfs_3g_probe (self, rw, device):
1641         u"""This command runs the ntfs-3g.probe(8) command which
1642         probes an NTFS "device" for mountability. (Not all NTFS
1643         volumes can be mounted read-write, and some cannot be
1644         mounted at all).
1645         
1646         "rw" is a boolean flag. Set it to true if you want to
1647         test if the volume can be mounted read-write. Set it to
1648         false if you want to test if the volume can be mounted
1649         read-only.
1650         
1651         The return value is an integer which 0 if the operation
1652         would succeed, or some non-zero value documented in the
1653         ntfs-3g.probe(8) manual page.
1654         """
1655         return libguestfsmod.ntfs_3g_probe (self._o, rw, device)
1656
1657     def sh (self, command):
1658         u"""This call runs a command from the guest filesystem via
1659         the guest's "/bin/sh".
1660         
1661         This is like "g.command", but passes the command to:
1662         
1663         /bin/sh -c "command"
1664         
1665         Depending on the guest's shell, this usually results in
1666         wildcards being expanded, shell expressions being
1667         interpolated and so on.
1668         
1669         All the provisos about "g.command" apply to this call.
1670         """
1671         return libguestfsmod.sh (self._o, command)
1672
1673     def sh_lines (self, command):
1674         u"""This is the same as "g.sh", but splits the result into a
1675         list of lines.
1676         
1677         See also: "g.command_lines"
1678         
1679         This function returns a list of strings.
1680         """
1681         return libguestfsmod.sh_lines (self._o, command)
1682
1683     def glob_expand (self, pattern):
1684         u"""This command searches for all the pathnames matching
1685         "pattern" according to the wildcard expansion rules used
1686         by the shell.
1687         
1688         If no paths match, then this returns an empty list
1689         (note: not an error).
1690         
1691         It is just a wrapper around the C glob(3) function with
1692         flags "GLOB_MARK|GLOB_BRACE". See that manual page for
1693         more details.
1694         
1695         This function returns a list of strings.
1696         """
1697         return libguestfsmod.glob_expand (self._o, pattern)
1698
1699     def scrub_device (self, device):
1700         u"""This command writes patterns over "device" to make data
1701         retrieval more difficult.
1702         
1703         It is an interface to the scrub(1) program. See that
1704         manual page for more details.
1705         
1706         This command is dangerous. Without careful use you can
1707         easily destroy all your data.
1708         """
1709         return libguestfsmod.scrub_device (self._o, device)
1710
1711     def scrub_file (self, file):
1712         u"""This command writes patterns over a file to make data
1713         retrieval more difficult.
1714         
1715         The file is *removed* after scrubbing.
1716         
1717         It is an interface to the scrub(1) program. See that
1718         manual page for more details.
1719         """
1720         return libguestfsmod.scrub_file (self._o, file)
1721
1722     def scrub_freespace (self, dir):
1723         u"""This command creates the directory "dir" and then fills
1724         it with files until the filesystem is full, and scrubs
1725         the files as for "g.scrub_file", and deletes them. The
1726         intention is to scrub any free space on the partition
1727         containing "dir".
1728         
1729         It is an interface to the scrub(1) program. See that
1730         manual page for more details.
1731         """
1732         return libguestfsmod.scrub_freespace (self._o, dir)
1733
1734     def mkdtemp (self, template):
1735         u"""This command creates a temporary directory. The
1736         "template" parameter should be a full pathname for the
1737         temporary directory name with the final six characters
1738         being "XXXXXX".
1739         
1740         For example: "/tmp/myprogXXXXXX" or
1741         "/Temp/myprogXXXXXX", the second one being suitable for
1742         Windows filesystems.
1743         
1744         The name of the temporary directory that was created is
1745         returned.
1746         
1747         The temporary directory is created with mode 0700 and is
1748         owned by root.
1749         
1750         The caller is responsible for deleting the temporary
1751         directory and its contents after use.
1752         
1753         See also: mkdtemp(3)
1754         """
1755         return libguestfsmod.mkdtemp (self._o, template)
1756
1757     def wc_l (self, path):
1758         u"""This command counts the lines in a file, using the "wc
1759         -l" external command.
1760         """
1761         return libguestfsmod.wc_l (self._o, path)
1762
1763     def wc_w (self, path):
1764         u"""This command counts the words in a file, using the "wc
1765         -w" external command.
1766         """
1767         return libguestfsmod.wc_w (self._o, path)
1768
1769     def wc_c (self, path):
1770         u"""This command counts the characters in a file, using the
1771         "wc -c" external command.
1772         """
1773         return libguestfsmod.wc_c (self._o, path)
1774
1775     def head (self, path):
1776         u"""This command returns up to the first 10 lines of a file
1777         as a list of strings.
1778         
1779         This function returns a list of strings.
1780         
1781         Because of the message protocol, there is a transfer
1782         limit of somewhere between 2MB and 4MB. To transfer
1783         large files you should use FTP.
1784         """
1785         return libguestfsmod.head (self._o, path)
1786
1787     def head_n (self, nrlines, path):
1788         u"""If the parameter "nrlines" is a positive number, this
1789         returns the first "nrlines" lines of the file "path".
1790         
1791         If the parameter "nrlines" is a negative number, this
1792         returns lines from the file "path", excluding the last
1793         "nrlines" lines.
1794         
1795         If the parameter "nrlines" is zero, this returns an
1796         empty list.
1797         
1798         This function returns a list of strings.
1799         
1800         Because of the message protocol, there is a transfer
1801         limit of somewhere between 2MB and 4MB. To transfer
1802         large files you should use FTP.
1803         """
1804         return libguestfsmod.head_n (self._o, nrlines, path)
1805
1806     def tail (self, path):
1807         u"""This command returns up to the last 10 lines of a file
1808         as a list of strings.
1809         
1810         This function returns a list of strings.
1811         
1812         Because of the message protocol, there is a transfer
1813         limit of somewhere between 2MB and 4MB. To transfer
1814         large files you should use FTP.
1815         """
1816         return libguestfsmod.tail (self._o, path)
1817
1818     def tail_n (self, nrlines, path):
1819         u"""If the parameter "nrlines" is a positive number, this
1820         returns the last "nrlines" lines of the file "path".
1821         
1822         If the parameter "nrlines" is a negative number, this
1823         returns lines from the file "path", starting with the
1824         "-nrlines"th line.
1825         
1826         If the parameter "nrlines" is zero, this returns an
1827         empty list.
1828         
1829         This function returns a list of strings.
1830         
1831         Because of the message protocol, there is a transfer
1832         limit of somewhere between 2MB and 4MB. To transfer
1833         large files you should use FTP.
1834         """
1835         return libguestfsmod.tail_n (self._o, nrlines, path)
1836
1837     def df (self):
1838         u"""This command runs the "df" command to report disk space
1839         used.
1840         
1841         This command is mostly useful for interactive sessions.
1842         It is *not* intended that you try to parse the output
1843         string. Use "statvfs" from programs.
1844         """
1845         return libguestfsmod.df (self._o)
1846
1847     def df_h (self):
1848         u"""This command runs the "df -h" command to report disk
1849         space used in human-readable format.
1850         
1851         This command is mostly useful for interactive sessions.
1852         It is *not* intended that you try to parse the output
1853         string. Use "statvfs" from programs.
1854         """
1855         return libguestfsmod.df_h (self._o)
1856
1857     def du (self, path):
1858         u"""This command runs the "du -s" command to estimate file
1859         space usage for "path".
1860         
1861         "path" can be a file or a directory. If "path" is a
1862         directory then the estimate includes the contents of the
1863         directory and all subdirectories (recursively).
1864         
1865         The result is the estimated size in *kilobytes* (ie.
1866         units of 1024 bytes).
1867         """
1868         return libguestfsmod.du (self._o, path)
1869
1870     def initrd_list (self, path):
1871         u"""This command lists out files contained in an initrd.
1872         
1873         The files are listed without any initial "/" character.
1874         The files are listed in the order they appear (not
1875         necessarily alphabetical). Directory names are listed as
1876         separate items.
1877         
1878         Old Linux kernels (2.4 and earlier) used a compressed
1879         ext2 filesystem as initrd. We *only* support the newer
1880         initramfs format (compressed cpio files).
1881         
1882         This function returns a list of strings.
1883         """
1884         return libguestfsmod.initrd_list (self._o, path)
1885
1886     def mount_loop (self, file, mountpoint):
1887         u"""This command lets you mount "file" (a filesystem image
1888         in a file) on a mount point. It is entirely equivalent
1889         to the command "mount -o loop file mountpoint".
1890         """
1891         return libguestfsmod.mount_loop (self._o, file, mountpoint)
1892
1893     def mkswap (self, device):
1894         u"""Create a swap partition on "device".
1895         """
1896         return libguestfsmod.mkswap (self._o, device)
1897
1898     def mkswap_L (self, label, device):
1899         u"""Create a swap partition on "device" with label "label".
1900         """
1901         return libguestfsmod.mkswap_L (self._o, label, device)
1902
1903     def mkswap_U (self, uuid, device):
1904         u"""Create a swap partition on "device" with UUID "uuid".
1905         """
1906         return libguestfsmod.mkswap_U (self._o, uuid, device)
1907
1908     def mknod (self, mode, devmajor, devminor, path):
1909         u"""This call creates block or character special devices, or
1910         named pipes (FIFOs).
1911         
1912         The "mode" parameter should be the mode, using the
1913         standard constants. "devmajor" and "devminor" are the
1914         device major and minor numbers, only used when creating
1915         block and character special devices.
1916         """
1917         return libguestfsmod.mknod (self._o, mode, devmajor, devminor, path)
1918
1919     def mkfifo (self, mode, path):
1920         u"""This call creates a FIFO (named pipe) called "path" with
1921         mode "mode". It is just a convenient wrapper around
1922         "g.mknod".
1923         """
1924         return libguestfsmod.mkfifo (self._o, mode, path)
1925
1926     def mknod_b (self, mode, devmajor, devminor, path):
1927         u"""This call creates a block device node called "path" with
1928         mode "mode" and device major/minor "devmajor" and
1929         "devminor". It is just a convenient wrapper around
1930         "g.mknod".
1931         """
1932         return libguestfsmod.mknod_b (self._o, mode, devmajor, devminor, path)
1933
1934     def mknod_c (self, mode, devmajor, devminor, path):
1935         u"""This call creates a char device node called "path" with
1936         mode "mode" and device major/minor "devmajor" and
1937         "devminor". It is just a convenient wrapper around
1938         "g.mknod".
1939         """
1940         return libguestfsmod.mknod_c (self._o, mode, devmajor, devminor, path)
1941
1942     def umask (self, mask):
1943         u"""This function sets the mask used for creating new files
1944         and device nodes to "mask & 0777".
1945         
1946         Typical umask values would be 022 which creates new
1947         files with permissions like "-rw-r--r--" or
1948         "-rwxr-xr-x", and 002 which creates new files with
1949         permissions like "-rw-rw-r--" or "-rwxrwxr-x".
1950         
1951         The default umask is 022. This is important because it
1952         means that directories and device nodes will be created
1953         with 0644 or 0755 mode even if you specify 0777.
1954         
1955         See also umask(2), "g.mknod", "g.mkdir".
1956         
1957         This call returns the previous umask.
1958         """
1959         return libguestfsmod.umask (self._o, mask)
1960
1961     def readdir (self, dir):
1962         u"""This returns the list of directory entries in directory
1963         "dir".
1964         
1965         All entries in the directory are returned, including "."
1966         and "..". The entries are *not* sorted, but returned in
1967         the same order as the underlying filesystem.
1968         
1969         This function is primarily intended for use by programs.
1970         To get a simple list of names, use "g.ls". To get a
1971         printable directory for human consumption, use "g.ll".
1972         
1973         This function returns a list of directory entries. Each
1974         directory entry is represented as a dictionary.
1975         """
1976         return libguestfsmod.readdir (self._o, dir)
1977