summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-18 15:31:53 +0100
committerRichard Jones <rjones@redhat.com>2009-04-18 15:31:53 +0100
commitef499de8946cf4b8120ef7917b2e5d7f9115041f (patch)
tree8972aedf961b05a1d836ab15dcf946e837d12b42 /python
parentad1d84a142169baaed293de71fb9430178d9f999 (diff)
downloadlibguestfs-ef499de8946cf4b8120ef7917b2e5d7f9115041f.tar.gz
libguestfs-ef499de8946cf4b8120ef7917b2e5d7f9115041f.tar.xz
libguestfs-ef499de8946cf4b8120ef7917b2e5d7f9115041f.zip
Separate out the high-level API actions.
- Split out the high-level API actions so that they are in a separate file, and use the defined guestfs C API, instead of fiddling around with internal structures.
Diffstat (limited to 'python')
-rw-r--r--python/guestfs-py.c120
-rw-r--r--python/guestfs.py41
2 files changed, 161 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c
index 09d42707..d1f0a9e7 100644
--- a/python/guestfs-py.c
+++ b/python/guestfs-py.c
@@ -681,6 +681,121 @@ py_guestfs_get_verbose (PyObject *self, PyObject *args)
}
static PyObject *
+py_guestfs_is_ready (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+
+ if (!PyArg_ParseTuple (args, (char *) "O:guestfs_is_ready",
+ &py_g))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_is_ready (g);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ py_r = PyInt_FromLong ((long) r);
+ return py_r;
+}
+
+static PyObject *
+py_guestfs_is_config (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+
+ if (!PyArg_ParseTuple (args, (char *) "O:guestfs_is_config",
+ &py_g))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_is_config (g);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ py_r = PyInt_FromLong ((long) r);
+ return py_r;
+}
+
+static PyObject *
+py_guestfs_is_launching (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+
+ if (!PyArg_ParseTuple (args, (char *) "O:guestfs_is_launching",
+ &py_g))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_is_launching (g);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ py_r = PyInt_FromLong ((long) r);
+ return py_r;
+}
+
+static PyObject *
+py_guestfs_is_busy (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+
+ if (!PyArg_ParseTuple (args, (char *) "O:guestfs_is_busy",
+ &py_g))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_is_busy (g);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ py_r = PyInt_FromLong ((long) r);
+ return py_r;
+}
+
+static PyObject *
+py_guestfs_get_state (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+
+ if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_state",
+ &py_g))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_get_state (g);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ py_r = PyInt_FromLong ((long) r);
+ return py_r;
+}
+
+static PyObject *
py_guestfs_mount (PyObject *self, PyObject *args)
{
PyObject *py_g;
@@ -2336,6 +2451,11 @@ static PyMethodDef methods[] = {
{ (char *) "get_autosync", py_guestfs_get_autosync, METH_VARARGS, NULL },
{ (char *) "set_verbose", py_guestfs_set_verbose, METH_VARARGS, NULL },
{ (char *) "get_verbose", py_guestfs_get_verbose, METH_VARARGS, NULL },
+ { (char *) "is_ready", py_guestfs_is_ready, METH_VARARGS, NULL },
+ { (char *) "is_config", py_guestfs_is_config, METH_VARARGS, NULL },
+ { (char *) "is_launching", py_guestfs_is_launching, METH_VARARGS, NULL },
+ { (char *) "is_busy", py_guestfs_is_busy, METH_VARARGS, NULL },
+ { (char *) "get_state", py_guestfs_get_state, METH_VARARGS, NULL },
{ (char *) "mount", py_guestfs_mount, METH_VARARGS, NULL },
{ (char *) "sync", py_guestfs_sync, METH_VARARGS, NULL },
{ (char *) "touch", py_guestfs_touch, METH_VARARGS, NULL },
diff --git a/python/guestfs.py b/python/guestfs.py
index 0a4c3960..943f80a7 100644
--- a/python/guestfs.py
+++ b/python/guestfs.py
@@ -193,6 +193,47 @@ class GuestFS:
"""
return libguestfsmod.get_verbose (self._o)
+ def is_ready (self):
+ u"""This returns true iff this handle is ready to accept
+ commands (in the "READY" state).
+
+ For more information on states, see guestfs(3).
+ """
+ return libguestfsmod.is_ready (self._o)
+
+ def is_config (self):
+ u"""This returns true iff this handle is being configured
+ (in the "CONFIG" state).
+
+ For more information on states, see guestfs(3).
+ """
+ return libguestfsmod.is_config (self._o)
+
+ def is_launching (self):
+ u"""This returns true iff this handle is launching the
+ subprocess (in the "LAUNCHING" state).
+
+ For more information on states, see guestfs(3).
+ """
+ return libguestfsmod.is_launching (self._o)
+
+ def is_busy (self):
+ u"""This returns true iff this handle is busy processing a
+ command (in the "BUSY" state).
+
+ For more information on states, see guestfs(3).
+ """
+ return libguestfsmod.is_busy (self._o)
+
+ def get_state (self):
+ u"""This returns the current state as an opaque integer.
+ This is only useful for printing debug and internal
+ error messages.
+
+ For more information on states, see guestfs(3).
+ """
+ return libguestfsmod.get_state (self._o)
+
def mount (self, device, mountpoint):
u"""Mount a guest disk at a position in the filesystem.
Block devices are named "/dev/sda", "/dev/sdb" and so